airborne12 opened a new pull request, #69560:
URL: https://github.com/apache/doris/pull/69560
### What problem does this PR solve?
Related PR: #69399
Problem Summary: Backport #69399 to `branch-4.2`.
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, `LogicalPlanDeepCopier` imports
`LogicalOlapScan`, which master already imported, and
`LogicalPlanDeepCopierTest` keeps the tests of the branch and adds the two
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.2` at ecbc5feab9), in a local ASAN build:
- PASS: FE unit tests `LogicalPlanDeepCopierTest`, `CTEInlineTest`,
`InferPredicateByReplaceTest`, `InferPredicatesTest`,
`UnequalPredicateInferTest`, `BindScoreToOlapScanTest`, `SearchExpressionTest`,
`TopNRuntimeFilterTest`, `PullUpProjectExprUnderTopNTest` and
`MaterializedViewUtilsTest` (280 tests), and FE Checkstyle.
- PASS: `./build.sh --fe --be`.
- PASS: BE unit tests `SegmentIteratorScoreCommonExprTest`,
`SegmentIteratorApplyIndexExprTest` and `VirtualSlotRefTest` (31 tests);
clang-format 16 on the changed BE files.
- PASS: the 23 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`, with unchanged `.out`
files.
🤖 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]