Uh oh!
There was an error while loading. Please reload this page.
[Feature](function) Support function cross_product of DuckDB - #59223
[Feature](function) Support function cross_product of DuckDB#59223juruo-c wants to merge 2 commits into
Conversation
Thearas
commented
Dec 21, 2025
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| 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
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| 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.
Uh oh!
There was an error while loading. Please reload this page.
zclllyybb
commented
Dec 21, 2025
and remember to format your code ~ |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
3e5e023 to
58fb654Compare
zclllyybb
left a comment
There was a problem hiding this comment.
Hi, there's still some problem. besides some reply of previous comments
Uh oh!
There was an error while loading. Please reload this page.
| 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
c0b84d3Comparec0b84d3 to
402901bCompare| "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.
Issue Number: #48203 Related PR: #59223 doc: apache/doris-website#3891 Problem Summary: Support function `ARRAY_CROSS_PRODUCT` ```sql Doris> SELECT CROSS_PRODUCT([1, 2, 3], [2, 3, 4]); +-------------------------------------+ | CROSS_PRODUCT([1, 2, 3], [2, 3, 4]) | +-------------------------------------+ | [-1, 2, -1] | +-------------------------------------+ 1 row in set (0.021 sec) Doris> SELECT CROSS_PRODUCT([1, 2, 3], NULL); +--------------------------------+ | CROSS_PRODUCT([1, 2, 3], NULL) | +--------------------------------+ | NULL | +--------------------------------+ 1 row in set (0.009 sec) Doris> SELECT CROSS_PRODUCT([1, NULL, 3], [1, 2, 3]); ERROR 1105 (HY000): errCode = 2, detailMessage = (127.0.0.1)[INVALID_ARGUMENT]function array_cross_product cannot have null Doris> SELECT CROSS_PRODUCT([1, 2, 3, 4], [1, 2, 3, 4]); ERROR 1105 (HY000): errCode = 2, detailMessage = (127.0.0.1)[INVALID_ARGUMENT]function array_cross_product requires both input arrays to have exactly 3 elements, got 4 and 4 ```
Issue Number: apache#48203 Related PR: apache#59223 doc: apache/doris-website#3891 Problem Summary: Support function `ARRAY_CROSS_PRODUCT` ```sql Doris> SELECT CROSS_PRODUCT([1, 2, 3], [2, 3, 4]); +-------------------------------------+ | CROSS_PRODUCT([1, 2, 3], [2, 3, 4]) | +-------------------------------------+ | [-1, 2, -1] | +-------------------------------------+ 1 row in set (0.021 sec) Doris> SELECT CROSS_PRODUCT([1, 2, 3], NULL); +--------------------------------+ | CROSS_PRODUCT([1, 2, 3], NULL) | +--------------------------------+ | NULL | +--------------------------------+ 1 row in set (0.009 sec) Doris> SELECT CROSS_PRODUCT([1, NULL, 3], [1, 2, 3]); ERROR 1105 (HY000): errCode = 2, detailMessage = (127.0.0.1)[INVALID_ARGUMENT]function array_cross_product cannot have null Doris> SELECT CROSS_PRODUCT([1, 2, 3, 4], [1, 2, 3, 4]); ERROR 1105 (HY000): errCode = 2, detailMessage = (127.0.0.1)[INVALID_ARGUMENT]function array_cross_product requires both input arrays to have exactly 3 elements, got 4 and 4 ```
We're closing this PR because it hasn't been updated in a while. |
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)