-
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 'substr_index' string function #8272
Changes from all commits
0b8a3cc
03b8d15
eb206bd
d5be382
5fccd49
407cf4b
b296f19
f3abde6
b5286fa
c0ceb37
89f9e4f
ec5f723
5a34984
33a2db2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -877,3 +877,78 @@ query ? | |
SELECT levenshtein(NULL, NULL) | ||
---- | ||
NULL | ||
|
||
query T | ||
SELECT substr_index('www.apache.org', '.', 1) | ||
---- | ||
www | ||
|
||
query T | ||
SELECT substr_index('www.apache.org', '.', 2) | ||
---- | ||
www.apache | ||
|
||
query T | ||
SELECT substr_index('www.apache.org', '.', -1) | ||
---- | ||
org | ||
|
||
query T | ||
SELECT substr_index('www.apache.org', '.', -2) | ||
---- | ||
apache.org | ||
|
||
query T | ||
SELECT substr_index('www.apache.org', 'ac', 1) | ||
---- | ||
www.ap | ||
|
||
query T | ||
SELECT substr_index('www.apache.org', 'ac', -1) | ||
---- | ||
he.org | ||
|
||
query T | ||
SELECT substr_index('www.apache.org', 'ac', 2) | ||
---- | ||
www.apache.org | ||
|
||
query T | ||
SELECT substr_index('www.apache.org', 'ac', -2) | ||
---- | ||
www.apache.org | ||
|
||
query ? | ||
SELECT substr_index(NULL, 'ac', 1) | ||
---- | ||
NULL | ||
|
||
query T | ||
SELECT substr_index('www.apache.org', NULL, 1) | ||
---- | ||
NULL | ||
|
||
query T | ||
SELECT substr_index('www.apache.org', 'ac', NULL) | ||
---- | ||
NULL | ||
|
||
query T | ||
SELECT substr_index('', 'ac', 1) | ||
---- | ||
(empty) | ||
|
||
query T | ||
SELECT substr_index('www.apache.org', '', 1) | ||
---- | ||
(empty) | ||
|
||
query T | ||
SELECT substr_index('www.apache.org', 'ac', 0) | ||
---- | ||
(empty) | ||
|
||
query ? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. awesome, can we also have the same tests with empty strings as input and search token? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add empty string tests and 0 count tests |
||
SELECT substr_index(NULL, NULL, NULL) | ||
---- | ||
NULL |
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.
we need to add a defense check args is exactly 3 elements
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, I add the args len check