Skip to content

Conversation

@juruo-c
Copy link

@juruo-c juruo-c commented Dec 21, 2025

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.

SELECT CROSS_PRODUCT([1, 2, 3], [2, 3, 4]), CROSS_PRODUCT([1, 0, 0], [0, 1, 0]);
+-------------------------------------+-------------------------------------+
| CROSS_PRODUCT([1, 2, 3], [2, 3, 4]) | CROSS_PRODUCT([1, 0, 0], [0, 1, 0]) |
+-------------------------------------+-------------------------------------+
| [-1, 2, -1]                         | [0, 0, 1]                           |
+-------------------------------------+-------------------------------------+

Check List (For Author)

  • Test

    • Regression test
    • Unit Test
    • Manual test (add detailed scripts or steps below)
    • No need to test or manual test. Explain why:
      • This is a refactor/code format and no logic has been changed.
      • Previous test can cover this change.
      • No code files have been changed.
      • Other reason
  • Behavior changed:

    • No.
    • Yes.
  • Does this need documentation?

Check List (For Reviewer who merge this PR)

  • Confirm the release note
  • Confirm test cases
  • Confirm document
  • Add branch pick label

@juruo-c juruo-c requested a review from zclllyybb as a code owner December 21, 2025 14:11
@Thearas
Copy link
Contributor

Thearas commented Dec 21, 2025

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR.

Please clearly describe your PR:

  1. What problem was fixed (it's best to include specific error reporting information). How it was fixed.
  2. Which behaviors were modified. What was the previous behavior, what is it now, why was it modified, and what possible impacts might there be.
  3. What features were added. Why was this function added?
  4. Which code was refactored and why was this part of the code refactored?
  5. Which functions were optimized and what is the difference before and after the optimization?

@zclllyybb zclllyybb self-assigned this Dec 21, 2025
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();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use vector_const and const_vector to deal constancy

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes. convert_to_full_column_if_const will lead to performance problem

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

get_name(), size1, size2);
}

if (size1 != 3 || size2 != 3) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

L156 and L162 are same check?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so. One ensures length consistency between the two inputs, while the other enforces a fixed-size 3 requirement.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@zclllyybb
Copy link
Contributor

and remember to format your code ~

@juruo-c juruo-c force-pushed the feature/array-cross-product branch from 3e5e023 to 58fb654 Compare January 15, 2026 01:01
Copy link
Contributor

@zclllyybb zclllyybb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, there's still some problem. besides some reply of previous comments

ssize_t size2 = offset2->get_data()[row] - prev_offset2;

if (size1 == 0 || size2 == 0) {
current_offset += 3;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nested_data.resize didn't write the default value. so I think you should also set nested_data here

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done


if (arr1->get_data_ptr()->is_nullable()) {
if (arr1->get_data_ptr()->has_null()) {
throw doris::Exception(ErrorCode::INVALID_ARGUMENT,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replace all throw with return status in this function

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

get_name(), size1, size2);
}

if (size1 != 3 || size2 != 3) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@juruo-c juruo-c force-pushed the feature/array-cross-product branch from 58fb654 to c0b84d3 Compare January 16, 2026 01:12
@juruo-c juruo-c force-pushed the feature/array-cross-product branch from c0b84d3 to 402901b Compare January 16, 2026 01:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants