airborne12 opened a new pull request, #69563:
URL: https://github.com/apache/doris/pull/69563
### What problem does this PR solve?
Related PR: #69399
Problem Summary: Backport #69399 to `branch-4.1`.
A CTE fails to plan with "A expression contains slot not from children" when
the optimizer inlines it after one of its scans got a virtual column: a CTE
that orders by `score()` or by an ANN distance with a LIMIT, or that has MATCH
in its select list and is inlined after rewrite. `LogicalPlanDeepCopier` gave
each virtual column two ids, copied them in list order, kept the old slot in
the output of the copied scan and left the score and ANN order keys on the old
slots. The copier now maps every virtual column to its new id before copying
their expressions and remaps the order keys, and
`LogicalOlapScan.withVirtualColumns` replaces the old virtual slots in the
output.
#### Branch adaptations
The branch has no table streams, so the change to
`LogicalOlapTableStreamScan` is dropped. `withVirtualColumns` keeps the
constructor call of the branch, and `LogicalPlanDeepCopierTest` and
`CTEInlineTest` keep the tests of the branch and add the tests of #69399.
### Release note
Fix "A expression contains slot not from children" for a CTE that orders by
`score()` or by an ANN distance with a LIMIT, or that has MATCH in its select
list and is inlined after rewrite.
### Check List (For Author)
- Test
- [x] Regression test
- [x] Unit Test
- [ ] Manual test
- Behavior changed:
- [x] No.
- Does this need documentation?
- [x] No.
### Validation
Validated together with the other two backports (#69399, #69419 and #69292
on `branch-4.1` at 3f911d030b), in a local ASAN build:
- PASS: FE unit tests `LogicalPlanDeepCopierTest`, `CTEInlineTest`,
`InferPredicateByReplaceTest`, `InferPredicatesTest`,
`UnequalPredicateInferTest`, `BindScoreToOlapScanTest`, `SearchExpressionTest`,
`TopNRuntimeFilterTest` and `MaterializedViewUtilsTest` (228 tests), and FE
Checkstyle.
- PASS: `./build.sh --be` and `./build.sh --fe`.
- PASS: BE unit tests `SegmentIteratorScoreCommonExprTest`,
`SegmentIteratorApplyIndexExprTest` and `VirtualSlotRefTest` (31 tests);
clang-format 16 on the changed BE files.
- PASS: the 16 regression suites of the branch that use `score()`, including
`test_cte_inline_virtual_column`, `infer_match_predicate`,
`test_score_filter_usage` and `test_score_filter_matrix`. The framework
regenerated the `.out` of `test_score_filter_matrix` on this branch: it drops
the 46 SNII cases and keeps the 94 V2 and V3 cases of master unchanged. The
other `.out` files are unchanged.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]