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

feat: add center function #282

Merged
merged 2 commits into from
Sep 2, 2022
Merged

Conversation

richtia
Copy link
Member

@richtia richtia commented Aug 8, 2022

PR to add center function.

Originally worked on in #248.

Instead of allowing a string with multiple characters to be used as padding, like lpad and rpad, center will only allow a single character for padding.

Copy link
Contributor

@jvanstraten jvanstraten left a comment

Choose a reason for hiding this comment

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

The description is not very explicit about it needing to be a single character; character vs characters could easily be misinterpreted as a typo. This is especially problematic because the prototypes allow anything from 0 to 2^31-1 characters to be specified for character. The varchar<L2> could at least be made a varchar<1> to make it 0 or 1 character in that case, though that doesn't really solve the problem completely and doesn't solve anything for the string variant... The closest thing to a character type that Substrait has is fixedchar<1>, but using that bends the rules of #251.

I'm on the fence about what the right approach is, but if we stick to the implementations as currently defined, the description should state what happens if != 1 characters are passed to the character argument (throw error that fails the whole query? return null? use first character for >1 and use space for 0 characters? something else? explicitly undefined/up to the consumer to decide?)

@richtia
Copy link
Member Author

richtia commented Aug 16, 2022

The description is not very explicit about it needing to be a single character; character vs characters could easily be misinterpreted as a typo. This is especially problematic because the prototypes allow anything from 0 to 2^31-1 characters to be specified for character. The varchar<L2> could at least be made a varchar<1> to make it 0 or 1 character in that case, though that doesn't really solve the problem completely and doesn't solve anything for the string variant... The closest thing to a character type that Substrait has is fixedchar<1>, but using that bends the rules of #251.

I'm on the fence about what the right approach is, but if we stick to the implementations as currently defined, the description should state what happens if != 1 characters are passed to the character argument (throw error that fails the whole query? return null? use first character for >1 and use space for 0 characters? something else? explicitly undefined/up to the consumer to decide?)

Updated the description and arg implementation to specify 1 character. For now, i've also just explicitly stated the undefined behavior if the number of characters passed to the character argument is not 1.

Copy link
Contributor

@jvanstraten jvanstraten left a comment

Choose a reason for hiding this comment

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

LGTM. CI failure is due to a network failure.

@jvanstraten jvanstraten merged commit 7697d39 into substrait-io:main Sep 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants