-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Int64 as default type for make_array function empty or null case #10790
Conversation
Signed-off-by: jayzhan211 <[email protected]>
Signed-off-by: jayzhan211 <[email protected]>
@@ -346,8 +346,8 @@ AS VALUES | |||
(arrow_cast(make_array([[1,2]], [[3, 4]]), 'FixedSizeList(2, List(List(Int64)))'), arrow_cast(make_array([1], [2]), 'FixedSizeList(2, List(Int64))')), | |||
(arrow_cast(make_array([[1,2]], [[4, 4]]), 'FixedSizeList(2, List(List(Int64)))'), arrow_cast(make_array([1,2], [3, 4]), 'FixedSizeList(2, List(Int64))')), | |||
(arrow_cast(make_array([[1,2]], [[4, 4]]), 'FixedSizeList(2, List(List(Int64)))'), arrow_cast(make_array([1,2,3], [1]), 'FixedSizeList(2, List(Int64))')), | |||
(arrow_cast(make_array([[1], [2]], []), 'FixedSizeList(2, List(List(Int64)))'), arrow_cast(make_array([2], [3]), 'FixedSizeList(2, List(Int64))')), | |||
(arrow_cast(make_array([[1], [2]], []), 'FixedSizeList(2, List(List(Int64)))'), arrow_cast(make_array([1], [2]), 'FixedSizeList(2, List(Int64))')), | |||
(arrow_cast(make_array([[1], [2]], [[]]), 'FixedSizeList(2, List(List(Int64)))'), arrow_cast(make_array([2], [3]), 'FixedSizeList(2, List(Int64))')), |
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.
Now they should have same dimension unlike null type
@@ -2666,19 +2679,19 @@ select array_concat(make_array(), make_array(2, 3)); | |||
query ? | |||
select array_concat(make_array(make_array(1, 2), make_array(3, 4)), make_array(make_array())); | |||
---- | |||
[[1, 2], [3, 4]] | |||
[[1, 2], [3, 4], []] |
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.
Consistent with duckdb
query ? | ||
select array_sort([]); | ||
---- | ||
[] |
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.
free fix because of changing default type to i64
query ? | ||
select array_concat([]); | ||
---- | ||
[] |
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.
free fix because of changing default type to i64
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.
Fixed #10200 👍
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 like a reasonable change to me. Thanks @jayzhan211
BTW I tested in duckdb and it seems like the default type is actually int32
but I think int64
is close enough
D select [];
┌───────────────────┐
│ main.list_value() │
│ int32[] │
├───────────────────┤
│ [] │
└───────────────────┘
Yes, they use i32. The reason I choose i64 is that the default value in datafusion is mostly i64 so we can avoid the cast for most of the case. We can easily convert it to i32 anytime if there is any need |
Thanks @alamb |
…che#10790) * set default type i64 Signed-off-by: jayzhan211 <[email protected]> * fmt Signed-off-by: jayzhan211 <[email protected]> --------- Signed-off-by: jayzhan211 <[email protected]>
it seems counter-intuitive to me to infer Int64 where it was not provided by a user nor schema of tables a query operates on. It might be transparent to the user, in which case it's probably fine, but it's also likely that this will transpire to some error message, when an array made form make_array is used in some later processing.
Also, it's likely to affect coercion rules in the future. |
I think any type is coercible for Null. Int64(Null) has no problem to be AnyType(Null) because it is |
Which issue does this PR close?
Closes #10789 .
Rationale for this change
What changes are included in this PR?
Are these changes tested?
Are there any user-facing changes?