-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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:implement postgres style 'overlay' string function #8117
Conversation
Thank you for your contribution! Could you move tests to sqllogictest, and add SQL reference? |
I agree -- thank you @Syleechan |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for this contribution @Syleechan - I agree with @2010YOUY01 that all this needs are some end to end sql tests (in sqllogictest): https://github.com/apache/arrow-datafusion/tree/main/datafusion/sqllogictest
# Conflicts: # datafusion/expr/src/built_in_function.rs # datafusion/physical-expr/src/functions.rs # datafusion/proto/proto/datafusion.proto # datafusion/proto/src/generated/pbjson.rs # datafusion/proto/src/generated/prost.rs # datafusion/proto/src/logical_plan/from_proto.rs
Thanks @2010YOUY01, @alamb . I have added the sqllogic test and sql reference. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for this contribution @Syleechan -- I think this is looking very nice
I had a few small suggestions, but they can also be done as follow on PRs if you prefer.
Thanks again!
('123', 'abc', 4, 5), | ||
('abcdefg', 'qwertyasdfg', 1, 7), | ||
('xyz', 'ijk', 1, 2), | ||
('Txxxxas', 'hom', 2, 4) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please also test NULL
handling here? I think your code handles it properly, but it would be good to have this in the SQL tests. We can do this as a follow on PR if you prefer.
Specifically
('Txxxxas', 'hom', 2, 4) | |
('Txxxxas', 'hom', 2, 4), | |
(NULL, 'hom', 2, 4), -- expect NULL output | |
('Txxxxas', 'hom', NULL, 4), -- expect NULL output | |
('Txxxxas', 'hom', 2, NULL) -- expect NULL output |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have added these cases, thanks.
- **str**: String expression to operate on. | ||
- **substr**: the string to replace part of str. | ||
- **pos**: the start position to replace of str. | ||
- **count**: the count of characters to be replaced from start position of str.If not specified, will use substr length instead. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- **count**: the count of characters to be replaced from start position of str.If not specified, will use substr length instead. | |
- **count**: the count of characters to be replaced from start position of str. If not specified, will use substr length instead. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
resolved, thanks.
``` | ||
overlay(str PLACING substr FROM pos [FOR count]) | ||
``` | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having the example made it much easier for me to see what was going on in postgres. Can we add an example here as well?
For example, `overlay('Txxxxas' placing 'hom' from 2 for 4) → Thomas` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To resolve the conflict, I have added this, thanks
# Conflicts: # datafusion/proto/proto/datafusion.proto # datafusion/proto/src/generated/pbjson.rs # datafusion/proto/src/generated/prost.rs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Syleechan lgtm, thx, will merge this, some pr is depend on this,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great -- thank you @Syleechan and @Ted-Jiang
Which issue does this PR close?
https://www.postgresql.org/docs/current/functions-string.html#:~:text=overlay%20(%20string,4)%20%E2%86%92%20Thomas
Closes #.
Rationale for this change
What changes are included in this PR?
Are these changes tested?
Are there any user-facing changes?