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

Improve rpad udf by using a GenericStringBuilder #12070

Merged
merged 3 commits into from
Aug 21, 2024

Conversation

Lordworms
Copy link
Contributor

Which issue does this PR close?

Closes #11997

Rationale for this change

What changes are included in this PR?

Are these changes tested?

Are there any user-facing changes?

@Lordworms
Copy link
Contributor Author

Lordworms commented Aug 20, 2024

Sorry for the late update, got some personal issue last week

@Omega359
Copy link
Contributor

lgtm

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.

Likewise this looks good to me -- thank you @Lordworms

We just need to sort out the cargo fmt CI Error

maybe we could make two separate macros? Or use StringArrayType to make generic functions instead -- see #12027

@Lordworms
Copy link
Contributor Author

Sure

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.

Awesome -- very nice @Lordworms

Thank you for the review and help @Omega359

let length = if length < 0 { 0 } else { length as usize };
let graphemes = string.graphemes(true).collect::<Vec<&str>>();
let fill_chars = fill.chars().collect::<Vec<char>>();
pub fn rpad<StringArrayLen: OffsetSizeTrait, FillArrayLen: OffsetSizeTrait>(
Copy link
Contributor

Choose a reason for hiding this comment

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

😍 -- 100% for no more macros!

@alamb alamb merged commit 7eeac2f into apache:main Aug 21, 2024
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Speed up rpad implementation to use StringBuilder
3 participants