[Feature](function) Support function cross_product of DuckDB#59223
[Feature](function) Support function cross_product of DuckDB#59223juruo-c wants to merge 2 commits intoapache:masterfrom
Conversation
|
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
...-test/suites/query_p0/sql_functions/array_functions/test_array_cross_product_function.groovy
Outdated
Show resolved
Hide resolved
...-test/suites/query_p0/sql_functions/array_functions/test_array_cross_product_function.groovy
Show resolved
Hide resolved
.../src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/CrossProduct.java
Outdated
Show resolved
Hide resolved
| const auto& arg1 = block.get_by_position(arguments[0]); | ||
| const auto& arg2 = block.get_by_position(arguments[1]); | ||
|
|
||
| auto col1 = arg1.column->convert_to_full_column_if_const(); |
There was a problem hiding this comment.
use vector_const and const_vector to deal constancy
There was a problem hiding this comment.
I want to confirm my understanding:
should I explicitly handle ColumnConst instead of calling convert_to_full_column_if_const()?
If my understanding is incorrect, I would appreciate your guidance on how to handle this.
There was a problem hiding this comment.
yes. convert_to_full_column_if_const will lead to performance problem
| get_name(), size1, size2); | ||
| } | ||
|
|
||
| if (size1 != 3 || size2 != 3) { |
There was a problem hiding this comment.
L156 and L162 are same check?
There was a problem hiding this comment.
I don't think so. One ensures length consistency between the two inputs, while the other enforces a fixed-size 3 requirement.
There was a problem hiding this comment.
I mean, if if (size1 != 3 || size2 != 3) get false, then if (size1 != size2) must be false, right? they are entailment relationship. so just remove the first.
|
and remember to format your code ~ |
.../src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/CrossProduct.java
Outdated
Show resolved
Hide resolved
.../src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/CrossProduct.java
Outdated
Show resolved
Hide resolved
3e5e023 to
58fb654
Compare
zclllyybb
left a comment
There was a problem hiding this comment.
Hi, there's still some problem. besides some reply of previous comments
|
|
||
| if (arr1->get_data_ptr()->is_nullable()) { | ||
| if (arr1->get_data_ptr()->has_null()) { | ||
| throw doris::Exception(ErrorCode::INVALID_ARGUMENT, |
There was a problem hiding this comment.
replace all throw with return status in this function
| get_name(), size1, size2); | ||
| } | ||
|
|
||
| if (size1 != 3 || size2 != 3) { |
There was a problem hiding this comment.
I mean, if if (size1 != 3 || size2 != 3) get false, then if (size1 != size2) must be false, right? they are entailment relationship. so just remove the first.
58fb654 to
c0b84d3
Compare
c0b84d3 to
402901b
Compare
| "Arguments for function {} must be arrays", get_name()); | ||
| } | ||
|
|
||
| // return ARRAY<DOUBLE> |
There was a problem hiding this comment.
why not the array float recheck the duckdb logic ?
| "Second argument for function {} cannot have null elements", get_name()); | ||
| } | ||
| auto nullable2 = assert_cast<const ColumnNullable*>(arr2->get_data_ptr().get()); | ||
| float2 = assert_cast<const ColumnFloat64*>(nullable2->get_nested_column_ptr().get()); |
There was a problem hiding this comment.
should dispose the nullable2 value is null case, it the value is null, the float2 maybe have invalid element
zclllyybb
left a comment
There was a problem hiding this comment.
Here's still an important thing: by default implementation framework of nulls, we unwrap nullmap and directly send nested column to function's impl. if there's a check of nested value validity in your function (size=3), it will be false positive alarm. so in this function you should deal null without our default framework. like #59897.
What problem does this PR solve?
Issue Number: #48203
Related PR: #xxx
Problem Summary:
Release note
doc: apache/doris-website#3209
The CROSS_PRODUCT function is used to compute the cross product of two arrays of size 3.
Check List (For Author)
Test
Behavior changed:
Does this need documentation?
Check List (For Reviewer who merge this PR)