-
Notifications
You must be signed in to change notification settings - Fork 2.4k
[CALCITE-5831] Add SOUNDEX function (enabled in Spark library) #3307
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
Conversation
1c1aaa1
to
ac8961a
Compare
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.
Looks pretty good I think. Is the behavior for the other dialects correct? I would imagine so but on the off chance it's not, we could avoid adding a whole extra operator. Otherwise just left a couple small comments.
@@ -227,6 +227,7 @@ | |||
import static org.apache.calcite.sql.fun.SqlLibraryOperators.SINH; | |||
import static org.apache.calcite.sql.fun.SqlLibraryOperators.SORT_ARRAY; | |||
import static org.apache.calcite.sql.fun.SqlLibraryOperators.SOUNDEX; | |||
import static org.apache.calcite.sql.fun.SqlLibraryOperators.SOUNDEX2; |
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.
I feel like SOUNDEX2 implies it takes 2 arguments, maybe SOUNDEX_SPARK would be a better name? Similar to the SUBSTR or FLOOR/CEIL functions.
@chucheng92 Please make the commit info stay the same as the Jira summary. |
@NobiGo thanks. I added a commit for letting commiters to review. should i merge to one commit and force-push it? |
Maybe the behavior is still a bit different, such as calcite mysql library(it limits 4 chars) now
And mysql:
But this behavior is also different from spark, so we may need to deal with each dialect separately later. Given that these issues are orthogonal, I prepare to create another issue to address it. WDYT? |
@tanclary thanks for reviewing. I have updated this pr. please take a look. |
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.
I think this is looking good, I just left one comment about the operator table entry. If you wouldn't mind changing the commit message from Soundex->SOUNDEX whenever you squash your commits that'd be great. Thank you!
6c98a97
to
b680dc3
Compare
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.
I think this looks great! Thanks for addressing all the comments. If no one has other suggestions I will merge later today.
@tanclary Hi, tanner. Main Code freeze has been closed. Can you help to merge this? |
I saw you opened an issue for making an addition to SqlBasicFunction and I believe you referenced this case. Should we resolve that so this case can use that logic? |
ok, it makes sense, thanks. |
@tanclary hi, tanner. I have added a method of |
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.
I think this looks good and is just about ready. Would you mind writing a RelToSqlConverter test and ensure that it gets unparsed as SOUNDEX(..) and not SOUNDEX_SPARK(..)? Sorry for the delay in review I have been out the past few days.
Hi, @tanclary I got your point. I have added it. PTAL. |
Looks good. Squash your commits please and I will merge soon. |
a8511cf
to
3a8bf52
Compare
Done. thanks again. |
Kudos, SonarCloud Quality Gate passed! |
What is the purpose of the change
Returns Soundex code of the string.
details pls see: https://issues.apache.org/jira/browse/CALCITE-5831
note: spark soundex not throw exception but return original string if the input string can't be mapped.
Brief change log
Add soundex function (enabled in Spark Library)
Verifying this change
SqlOperatorTests#testSoundex2Func()