Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update RPAD scalar function to support Utf8View #11942

Merged
merged 3 commits into from
Aug 14, 2024

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

datafusion/functions/src/unicode/rpad.rs Outdated Show resolved Hide resolved
@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.

}
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

datafusion/functions/src/unicode/rpad.rs Outdated Show resolved Hide resolved
@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
24 checks passed
@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 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