Skip to content

branch-4.1: [fix](be) Fix ANN query vector extraction to handle all constant expression types #62637#62926

Open
github-actions[bot] wants to merge 1 commit intobranch-4.1from
auto-pick-62637-branch-4.1
Open

branch-4.1: [fix](be) Fix ANN query vector extraction to handle all constant expression types #62637#62926
github-actions[bot] wants to merge 1 commit intobranch-4.1from
auto-pick-62637-branch-4.1

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

Cherry-picked from #62637

…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
@github-actions github-actions Bot requested a review from yiguolei as a code owner April 29, 2026 05:05
@yiguolei
Copy link
Copy Markdown
Contributor

run buildall

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants