Skip to content

Conversation

@Lordworms
Copy link
Contributor

Which issue does this PR close?

Closes #11918

Rationale for this change

What changes are included in this PR?

Are these changes tested?

Are there any user-facing changes?

@github-actions github-actions bot added the sqllogictest SQL Logic Tests (.slt) label Aug 12, 2024
Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @Lordworms 🙏 . I had a few questions about this PR but it is looking close

}
_ => Ok(None),
})
.collect::<Result<GenericStringArray<T>>>()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This means the result of rpad is always GenericStringArray (Utf8Array) right?

I wonder if it would make sense to produce the same output type as the first argument 🤔 For the string view case eventually I could imagine reusing the same underlying buffers if the string had nothing to pad.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lpad was the same here iirc

@Omega359
Copy link
Contributor

You may want to look at the tests I added in #11941 as an example to verify that all the signature variants are tested.

@Lordworms
Copy link
Contributor Author

You may want to look at the tests I added in #11941 as an example to verify that all the signature variants are tested.

I'll add that, thanks for reminding

@Lordworms
Copy link
Contributor Author

You may want to look at the tests I added in #11941 as an example to verify that all the signature variants are tested.

I may directly reference the test case there, is it ok?

@Omega359
Copy link
Contributor

You may want to look at the tests I added in #11941 as an example to verify that all the signature variants are tested.

I may directly reference the test case there, is it ok?

It currently hardcodes the LPadFunc in it so it'll require a refactor but given how close these two functions are I can't see an issue off the top of my head.

@github-actions github-actions bot added the functions Changes to functions implementation label Aug 12, 2024
}
macro_rules! process_rpad {
// For the two-argument case
($string_array:expr, $length_array:expr, $is_view:expr) => {{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is_view looks to be unused and it always passed in true. Should be removed unless I missed something.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree -- removing it would simplify this PR

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I'll remove it soon

@alamb
Copy link
Contributor

alamb commented Aug 13, 2024

Thank you @Lordworms and @Omega359

Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me @Lordworms and @Omega359

An epic journey of macros 🚀

I can't help but think this function could be made much faster by using a StringBuilder rather than creating a bunch of Strings which are then copied.

However, that could be some future pR

@alamb alamb merged commit 02bfefe into apache:main Aug 14, 2024
@alamb
Copy link
Contributor

alamb commented Aug 14, 2024

Looks good to me @Lordworms and @Omega359

An epic journey of macros 🚀

I can't help but think this function could be made much faster by using a StringBuilder rather than creating a bunch of Strings which are then copied.

However, that could be some future pR

@Omega359's PR here is a pretty good example of how to do this #11987

@Lordworms
Copy link
Contributor Author

Looks good to me @Lordworms and @Omega359
An epic journey of macros 🚀
I can't help but think this function could be made much faster by using a StringBuilder rather than creating a bunch of Strings which are then copied.
However, that could be some future pR

@Omega359's PR here is a pretty good example of how to do this #11987

Sure, I'll add a PR for it tomorrow.

@alamb
Copy link
Contributor

alamb commented Aug 14, 2024

Filed

Looks good to me @Lordworms and @Omega359
An epic journey of macros 🚀
I can't help but think this function could be made much faster by using a StringBuilder rather than creating a bunch of Strings which are then copied.
However, that could be some future pR

@Omega359's PR here is a pretty good example of how to do this #11987

Sure, I'll add a PR for it tomorrow.

Filed #11997 to track

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

functions Changes to functions implementation sqllogictest SQL Logic Tests (.slt)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update RPAD scalar function to support Utf8View

3 participants