-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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 sql style 'find_in_set' string function #8328
Conversation
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 the contribution @Syleechan -- this PR seems pretty mysql specific and maybe it belong in a downstream system given:
- There is already a function like
array_contains
- DataFusion isn't trying to replicate the full function library of existing databases
@@ -1170,6 +1171,20 @@ substr_index(str, delim, count) | |||
- **delim**: the string to find in str to split str. | |||
- **count**: The number of times to search for the delimiter. Can be both a positive or negative number. | |||
|
|||
### `find_in_set` |
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.
What do you think about using one of the existing array union functions instead? What about array_contains
?
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.
Thanks @alamb . I have checked that the array functions input args type are different from the string function find_in_set.Actually, we use calcite to transfer to datafusion to compute data, and calcite also has array_contains, array_position functions.But Calcite take them as different functions, array functions process array input args and string functions process string input args.
https://calcite.apache.org/docs/reference.html#:~:text=ARRAY_POSITION(array%2C%20element)
https://calcite.apache.org/docs/reference.html#:~:text=FIND_IN_SET(matchStr%2C%20textStr)
these are calcite style functions in the 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.
LGTM, thx @Syleechan. @alamb this is the last str_func user case in our system, but we want to introduce more array_func, @Syleechan could you plz help list the need list.
# Conflicts: # datafusion/expr/src/built_in_function.rs
Thanks again @Syleechan |
Which issue does this PR close?
https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_find-in-set:~:text=FIND_IN_SET(str%2Cstrlist)
Rationale for this change
What changes are included in this PR?
Are these changes tested?
Are there any user-facing changes?