[fix](be) Fix ANN query vector extraction to handle all constant expression types#62637
Conversation
|
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
|
run buildall |
|
better we add a regression test to test if it's valid @zhiqiang-hhhh |
|
PR approved by at least one committer and no changes requested. |
|
PR approved by anyone and no changes requested. |
|
run buildall |
|
run buildall |
2 similar comments
|
run buildall |
|
run buildall |
…ession types ### What problem does this PR solve? Problem Summary: The `extract_query_vector` function in `ann_topn_runtime.cpp` only accepted `VArrayLiteral` or `VCastExpr` as the query vector expression. This caused ANN index queries to fail when FE produced other constant expression types (e.g., `ColumnConst` wrapping). The fix removes the rigid type check and instead uses `get_const_col()` + `ColumnConst` unwrapping, which works for any constant expression that materializes to an array column. ### Release note Fix ANN vector index query failure when the query vector expression is not a direct array literal or CAST expression. ### Check List (For Author) - Test: Regression test - Behavior changed: No - Does this need documentation: No
### What problem does this PR solve? Problem Summary: Add BE unit tests and regression coverage for ANN query vectors produced by constant expressions such as `array_repeat` and `array_with_constant`, and update the NULL-array expectation to match the new extraction behavior. ### Release note None ### Check List (For Author) - Test: Unit Test and Regression test - Behavior changed: No - Does this need documentation: No
### What problem does this PR solve? Issue Number: None Related PR: None Problem Summary: Fix the ANN query vector unit test build failure caused by a stale MockConstVExpr override that no longer matches the current VExpr interface. ### Release note None ### Check List (For Author) - Test: No need to test (compile-only fix; full build not rerun in this session) - Behavior changed: No - Does this need documentation: No
### What problem does this PR solve?
Issue Number: None
Related PR: None
Problem Summary: Fix the ANN extract_query_vector unit test compile failure in CI by updating the mock expression to match the current VExpr execution interface.
### Release note
None
### Check List (For Author)
- Test: Unit Test
- Built extract_query_vector_test.cpp object and vector_search_test in be/ut_build_ASAN
- Behavior changed: No
- Does this need documentation: No
eb2cd14 to
66ba080
Compare
|
run buildall |
### What problem does this PR solve?
Issue Number: None
Related PR: None
Problem Summary: Fix the remaining BE UT compile failure in CI by matching MockConstVExpr to the current VExpr selector signature, where execute_column_impl takes const Selector*.
### Release note
None
### Check List (For Author)
- Test: Manual test
- Verified latest TeamCity failure and aligned the mock signature with the VExpr API used in CI
- Behavior changed: No
- Does this need documentation: No
|
run buildall |
BE UT Coverage ReportIncrement line coverage Increment coverage report
|
|
run cloud_p0 |
BE Regression && UT Coverage ReportIncrement line coverage Increment coverage report
|
1 similar comment
BE Regression && UT Coverage ReportIncrement line coverage Increment coverage report
|
BE Regression && UT Coverage ReportIncrement line coverage Increment coverage report
|
|
PR approved by at least one committer and no changes requested. |
…ession types (#62637) ## Proposed changes Fix `extract_query_vector` in `ann_topn_runtime.cpp` to handle all constant expression types instead of only `VArrayLiteral` and `VCastExpr`. ### What problem does this PR solve? Issue Number: close #xxx Problem Summary: The `extract_query_vector` function previously checked whether the query vector argument was specifically a `VArrayLiteral` or `VCastExpr` via `dynamic_pointer_cast`. When FE produced other constant expression forms (e.g., after expression rewrites), ANN index queries would fail with `InvalidArgument: Constant must be ArrayLiteral or CAST to array`. The fix removes the rigid type check and instead: 1. Calls `get_const_col()` to materialize the constant expression 2. Unwraps `ColumnConst` via `check_and_get_column<ColumnConst>` to get the underlying data column 3. Validates the resulting column shape (Nullable → Array → Float32) This approach works for any constant expression that materializes to an array column, regardless of the expression node type. ### Release note Fix ANN vector index query failure when the query vector expression is not a direct array literal or CAST expression. ### Check List (For Author) - Test: Regression test - Behavior changed: No - Does this need documentation: No
Proposed changes
Fix
extract_query_vectorinann_topn_runtime.cppto handle all constant expression types instead of onlyVArrayLiteralandVCastExpr.What problem does this PR solve?
Issue Number: close #xxx
Problem Summary:
The
extract_query_vectorfunction previously checked whether the query vector argument was specifically aVArrayLiteralorVCastExprviadynamic_pointer_cast. When FE produced other constant expression forms (e.g., after expression rewrites), ANN index queries would fail withInvalidArgument: Constant must be ArrayLiteral or CAST to array.The fix removes the rigid type check and instead:
get_const_col()to materialize the constant expressionColumnConstviacheck_and_get_column<ColumnConst>to get the underlying data columnThis approach works for any constant expression that materializes to an array column, regardless of the expression node type.
Release note
Fix ANN vector index query failure when the query vector expression is not a direct array literal or CAST expression.
Check List (For Author)