-
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
Cast Utf8View
to Utf8
to support ||
from StringViewArray
#11796
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -379,3 +379,56 @@ select t.dt from dates t where arrow_cast('2024-01-01', 'Utf8View') < t.dt; | |
|
||
statement ok | ||
drop table dates; | ||
|
||
statement ok | ||
create table temp as values | ||
('value1', arrow_cast('rust', 'Utf8View'), arrow_cast('fast', 'Utf8View')), | ||
('value2', arrow_cast('datafusion', 'Utf8View'), arrow_cast('cool', 'Utf8View')); | ||
|
||
query T | ||
select column2||' is fast' from temp; | ||
---- | ||
rust is fast | ||
datafusion is fast | ||
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. ❤️ |
||
|
||
|
||
query T | ||
select column2 || ' is ' || column3 from temp; | ||
---- | ||
rust is fast | ||
datafusion is cool | ||
|
||
query TT | ||
explain select column2 || 'is' || column3 from temp; | ||
---- | ||
logical_plan | ||
01)Projection: CAST(temp.column2 AS Utf8) || Utf8("is") || CAST(temp.column3 AS Utf8) | ||
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. This would be a better plan (likely faster) if the casting was to 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. I agree |
||
02)--TableScan: temp projection=[column2, column3] | ||
|
||
|
||
query TT | ||
explain select column2||' is fast' from temp; | ||
---- | ||
logical_plan | ||
01)Projection: CAST(temp.column2 AS Utf8) || Utf8(" is fast") | ||
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. likewise here it would be better to use Utf8View |
||
02)--TableScan: temp projection=[column2] | ||
|
||
|
||
query T | ||
select column2||column3 from temp; | ||
---- | ||
rustfast | ||
datafusioncool | ||
|
||
query TT | ||
explain select column2||column3 from temp; | ||
---- | ||
logical_plan | ||
01)Projection: CAST(temp.column2 AS Utf8) || CAST(temp.column3 AS Utf8) | ||
02)--TableScan: temp projection=[column2, column3] | ||
|
||
query T | ||
select column2|| ' ' ||column3 from temp; | ||
---- | ||
rust fast | ||
datafusion cool |
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 it would be better to coerce to
Utf8View
as that coercsion will often be faster (it is faster to cast Utf8 -> Utf8View than the other way around)Is that possible?
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.
Agree, similar to this policy:
datafusion/datafusion/expr/src/type_coercion/binary.rs
Lines 935 to 947 in b50887f
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 we do in a seperate PR. Previously, we were coerced to
Utf8View
, so concat was failing. As a temporary workaround to resolve the issue, I've coerce Utf8 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.
Make sense!
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.
filed #11881 to track