Uh oh!
There was an error while loading. Please reload this page.
make array_union/array_except/array_intersect handle empty/null arrays rightly - #8269
Conversation
Signed-off-by: veeupup <code@tanweime.com>
@jayzhan211 maybe you can check the behavior for these functions now cc @alamb |
Signed-off-by: veeupup <code@tanweime.com>
array_union handle empty/null arrays rightlyarray_union/array_except/array_intersect handle empty/null arrays rightlySigned-off-by: veeupup <code@tanweime.com>
9ed1fca to
c08d6cbCompare
jayzhan211
left a comment
There was a problem hiding this comment.
I think we need to fix here.
if data_types.is_empty(){// ListArray[NullArray(0)], the same as `make_array()`.let array = new_null_array(&DataType::Null,0);let array = Arc::new(array_into_list_array(array));Ok(lit(ScalarValue::List(array)))}elseif data_types.len() > 1{Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
jayzhan211
commented
Nov 20, 2023
Update: I found we can easily reuse MakeArray for sql_array_literal Ok(Expr::ScalarFunction(ScalarFunction::new(BuiltinScalarFunction::MakeArray,
values,))) |
Veeupup
commented
Nov 20, 2023
@jayzhan211 Thanks for your constructive comments!I suppose we make it in a right way : ) |
Signed-off-by: veeupup <code@tanweime.com>
a76beaa to
be32301CompareUh oh!
There was an error while loading. Please reload this page.
We can move |
7fa005b to
e154eadCompare
alamb
left a comment
There was a problem hiding this comment.
Thank you very much @Veeupup and @jayzhan211 - this looks really nice and exactly correct 🙏
| BuiltinScalarFunction::ArrayIntersect => Ok(input_expr_types[0].clone()), | ||
| BuiltinScalarFunction::ArrayUnion => Ok(input_expr_types[0].clone()), | ||
| BuiltinScalarFunction::ArrayUnion | BuiltinScalarFunction::ArrayIntersect => { | ||
| match (input_expr_types[0].clone(), input_expr_types[1].clone()) { |
| SELECT ARRAY_AGG([]) | ||
| ---- | ||
| [] | ||
| [[]] |
| { | ||
| if !args.iter().all(|arg| { | ||
| arg.data_type().equals_datatype(data_type) | ||
| || arg.data_type().equals_datatype(&DataType::Null) |
There was a problem hiding this comment.
@Veeupup Why do we need Null checking here, which function failed without this?
There was a problem hiding this comment.
when it comes to handle multi arrays functions,their input types maybe like null, List(Int32).... Then, but we should handle null type in function body rather than return error here.
Which issue does this PR close?
Closes#8181.
for
array_union:for
array_except:for
array_intersect:Rationale for this change
What changes are included in this PR?
Are these changes tested?
Are there any user-facing changes?