-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Add tests for StringView / character functions, fix regexp_like
and regexp_match
to work with StringView
#11753
Conversation
264523b
to
45117f6
Compare
regexp_like
and regexp_match
to work with StringView
"The regexp_like function can only accept strings. Got {other}" | ||
); | ||
} | ||
_ => Boolean, |
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.
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.
Shouldn't we return error for non-string type?
LargeUtf8 | Utf8 | Utf8View => Boolean
Null => Null
other => not supported
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 was thinking the type coercion already handles, in theory, ensuring the correct types are passed in, so the extra check was not necessary. I can put back the explicit check if you prefer
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.
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 was thinking the type coercion already handles, in theory, ensuring the correct types are passed in, so the extra check was not necessary. I can put back the explicit check if you prefer
I think you are right, we don't need another type check in return_type
.
it is very counter intuitive to return a Boolean because that case shouldn't exists.
The type check should be handled in signature before return_type
. We could improve docs about how the types and length check are handled in UDF/UDAF
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.
How about I'll at least add some comments to make it clear why this isn't doing the typechecks here
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.
Should we use 'unreachable!' ?
I prefer using internal error when possible as unreachable!
will panic. But now that you mention this, the function is going to panic at runtime anyways 🤔
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.
My bad I mixed up two things. In the thread about better error handling I think we agreed to return a planning error in this scenario, and some form of unreachable within the invoke function to signal that branch should never be executed
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 added comments in ead4a7c
|
||
|
||
## Ensure no casts for ASCII | ||
## TODO file ticket |
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 plan to file tickets for these functions as follow ons -- see #11787 (comment) for details
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.
Here's the one for ASCII: #11834
I don't have the ability to update the label, so maybe it could be changed to a good first issue? Might help it get picked up sooner, and with the examples, it's not doing it from scratch.
## TODO file ticket | ||
query TT | ||
EXPLAIN SELECT | ||
BTRIM(column1_utf8view, 'foo') AS l |
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.
BTRIM: #11835
## TODO file ticket | ||
query TT | ||
EXPLAIN SELECT | ||
CHARACTER_LENGTH(column1_utf8view) AS l |
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.
Done in #11677
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.
🤔 but for some reason the argument is still cast to Utf8
01)Projection: character_length(CAST(test.column1_utf8view AS Utf8)) AS l
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 debugged and fixed it here: f42aa84
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.
Ah, thanks!
## TODO file ticket | ||
query TT | ||
EXPLAIN SELECT | ||
concat(column1_utf8view, column2_utf8view) as c |
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.
CONCAT: #11836
## TODO file ticket | ||
query TT | ||
EXPLAIN SELECT | ||
concat_ws(', ', column1_utf8view, column2_utf8view) as c |
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.
## TODO file ticket | ||
query TT | ||
EXPLAIN SELECT | ||
CONTAINS(column1_utf8view, 'foo') as c1, |
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.
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.
Next batch
## TODO file ticket | ||
query TT | ||
EXPLAIN SELECT | ||
ENDS_WITH(column1_utf8view, 'foo') as c1, |
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.
## TODO file ticket | ||
query TT | ||
EXPLAIN SELECT | ||
INITCAP(column1_utf8view) as c |
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.
## TODO file ticket | ||
query TT | ||
EXPLAIN SELECT | ||
levenshtein(column1_utf8view, 'foo') as c1, |
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.
## TODO file ticket | ||
query TT | ||
EXPLAIN SELECT | ||
LOWER(column1_utf8view) as c1 |
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.
## TODO file ticket | ||
query TT | ||
EXPLAIN SELECT | ||
LTRIM(column1_utf8view) as c1 |
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.
## TODO file ticket | ||
query TT | ||
EXPLAIN SELECT | ||
LPAD(column1_utf8view, 12, ' ') as c1 |
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.
## TODO file ticket | ||
query TT | ||
EXPLAIN SELECT | ||
OCTET_LENGTH(column1_utf8view) as c1 |
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.
## TODO file ticket | ||
query TT | ||
EXPLAIN SELECT | ||
STARTS_WITH(column1_utf8view, 'foo') as c, |
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.
Done in #11787
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.
👍
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 @tshauck @jayzhan211 and others who helped with this PR
I updated the tests / added the ticket links, and I now plan to merge this PR once the CI is green
@@ -425,102 +425,26 @@ logical_plan | |||
01)Projection: starts_with(test.column1_utf8view, Utf8View("äöüß")) AS c1, starts_with(test.column1_utf8view, Utf8View("")) AS c2, starts_with(test.column1_utf8view, Utf8View(NULL)) AS c3, starts_with(Utf8View(NULL), test.column1_utf8view) AS c4 | |||
02)--TableScan: test projection=[column1_utf8view] | |||
|
|||
statement ok |
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 just moved these tests down to the other test for ASCII
Thanks again@ |
## TODO file ticket | ||
query TT | ||
EXPLAIN SELECT | ||
OVERLAY(column1_utf8view PLACING 'foo' FROM 2 ) as c1 |
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.
## Ensure no casts for REGEXP_LIKE | ||
query TT | ||
EXPLAIN SELECT | ||
REGEXP_LIKE(column1_utf8view, '^https?://(?:www\.)?([^/]+)/.*$') AS k |
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.
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.
another batch
## Ensure no casts for REGEXP_MATCH | ||
query TT | ||
EXPLAIN SELECT | ||
REGEXP_MATCH(column1_utf8view, '^https?://(?:www\.)?([^/]+)/.*$') AS k |
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.
## Ensure no casts for REGEXP_REPLACE | ||
query TT | ||
EXPLAIN SELECT | ||
REGEXP_REPLACE(column1_utf8view, '^https?://(?:www\.)?([^/]+)/.*$', '\1') AS k |
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.
## TODO file ticket | ||
query TT | ||
EXPLAIN SELECT | ||
REPLACE(column1_utf8view, 'foo', 'bar') as c1, |
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.
## TODO file ticket | ||
query TT | ||
EXPLAIN SELECT | ||
REPEAT(column1_utf8view, 2) as c1 |
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.
## TODO file ticket | ||
query TT | ||
EXPLAIN SELECT | ||
REVERSE(column1_utf8view) as c1 |
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.
## TODO file ticket | ||
query TT | ||
EXPLAIN SELECT | ||
RTRIM(column1_utf8view) as c1, |
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.
## TODO file ticket | ||
query TT | ||
EXPLAIN SELECT | ||
RTRIM(column1_utf8view) as c, |
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.
RTRIM is here twice, ticket: #11916
## TODO file ticket | ||
query TT | ||
EXPLAIN SELECT | ||
RIGHT(column1_utf8view, 3) as c2 |
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.
## TODO file ticket | ||
query TT | ||
EXPLAIN SELECT | ||
RPAD(column1_utf8view, 1) as c1, |
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.
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.
final batch
## TODO file ticket | ||
query TT | ||
EXPLAIN SELECT | ||
SPLIT_PART(column1_utf8view, 'f', 1) as c |
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.
## TODO file ticket | ||
query TT | ||
EXPLAIN SELECT | ||
STRPOS(column1_utf8view, 'f') as c, |
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.
## TODO file ticket | ||
query TT | ||
EXPLAIN SELECT | ||
SUBSTR(column1_utf8view, 1) as c, |
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.
## TODO file ticket | ||
query TT | ||
EXPLAIN SELECT | ||
TRANSLATE(column1_utf8view, 'foo', 'bar') as c |
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.
## TODO file ticket | ||
query TT | ||
EXPLAIN SELECT | ||
FIND_IN_SET(column1_utf8view, 'a,b,c,d') as c |
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.
('value2', arrow_cast('datafusion', 'Utf8View'), arrow_cast('cool', 'Utf8View')); | ||
|
||
query T | ||
select column2||' is fast' from temp; |
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.
Ticket for concat operator is at: #11766
You are the best @tshauck -- given how fast these implementations are pouring in I am not even going to try and update the URLs in the text :) |
Which issue does this PR close?
Part of #11752
Part of #11790
Rationale for this change
I am trying to write up the remaining work for StringView, and one remaining item is add StringView support for StringFunctions. I want to know what functions already support StringView
It turns out we have a lot of string functions that probably need work to convert to natively support string view
What changes are included in this PR?
string_view.slt
showing if functions support StringView or notAre these changes tested?
All tests
Are there any user-facing changes?