-
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
Support internal cast for BuiltinScalarFunction::MakeArray #6607
Conversation
Signed-off-by: jayzhan211 <jayzhan211@gmail.com>
Signed-off-by: jayzhan211 <jayzhan211@gmail.com>
Signed-off-by: jayzhan211 <jayzhan211@gmail.com>
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 @jayzhan211 -- I left some comments
@@ -85,7 +87,18 @@ fn array_array(args: &[ArrayRef]) -> Result<ArrayRef> { | |||
)); | |||
} | |||
|
|||
let data_type = args[0].data_type(); | |||
let data_type = args |
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 we are trying to avoid casting in the physical-exprs and instead want to cast in the analyze
pass (so the rest of the optimizer passes see the correct types)
I think this is the relevant code:
Perhaps it needs to be taught about array arguments 🤔
Signed-off-by: jayzhan211 <jayzhan211@gmail.com>
Signed-off-by: jayzhan211 <jayzhan211@gmail.com>
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 @jayzhan211 -- this looks good to me
Any thoughts @izveigor ?
@@ -602,6 +603,39 @@ fn coerce_arguments_for_signature( | |||
.collect::<Result<Vec<_>>>() | |||
} | |||
|
|||
fn coerce_arguments_for_fun( |
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.
LGTM. If you have more time, you can add more sql logic tests.
Specifically, I think adding coverage for NULL and arrays would be helpful: select make_array(null, 1.0) select make_array(1.0, '2', null) create table foo (x int, y double) as values (1, 2.0);
select make_array(x, y) from foo; |
I plan to merge this PR tomorrow, unless @jayzhan211 would like more time to add tests |
Let me add some tests |
Signed-off-by: jayzhan211 <jayzhan211@gmail.com>
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 great -- thank you @jayzhan211
Which issue does this PR close?
Closes #6558.
Rationale for this change
BuiltinScalarFunction::MakeArray with different kinds of DataType is not supported yet
What changes are included in this PR?
BuiltinScalarFunction::MakeArray use
array()
indatafusion/physical-expr/src/array_expressions.rs
, we support casting internally inarray_array()
.Type coercion is based on
datafusion_expr::comparison_coercion
Cast is based on
arrow-cast
Are these changes tested?
unit tests are added
sqllogictest for float is added
make_array(Int64(1), Int32(2))
is not included in sqllogictest, since Int64() is not supported yet and not trivial for me to support in this PR, also no other way to differentiate value from int64 and int32.Are there any user-facing changes?