starocean999 opened a new pull request, #66681:
URL: https://github.com/apache/doris/pull/66681
### What problem does this PR solve?
Issue Number: close #xxx
Related PR: #xxx
Problem Summary:
A `NoneMovableFunction` (e.g. `assert_true`) has side effects: it throws
errors during evaluation, and its result depends on the exact row it is
evaluated on. Several rewrite rules only guarded against volatile expressions
(`containsVolatileExpression`) when deciding whether a predicate may be
moved,
duplicated or pruned. As a result, a `NoneMovableFunction` conjunct could be
relocated to a different row domain (pushed below a join/aggregation/window/
generate/set-operation/partition-top-n, turned into a join condition, pushed
through a limit, reordered inside a join cluster, or cloned into sibling
branches), where it would be evaluated on a different — usually superset —
set
of rows, silently changing its error behavior or query results.
For example, `SELECT ... FROM t1 JOIN t2 ON ... WHERE assert_true(t1.a > 0)`
must keep `assert_true` above the join: pushing it into a join child would
make
it fail for rows that the join would otherwise filter out.
This PR adds `ExpressionTrait::containsNoneMovableOrVolatile()`, which is
true
when an expression contains a volatile expression or a `NoneMovableFunction`,
and updates all affected rewrite rules to treat both kinds identically:
- Filter pushdown through join, aggregation, generate, window, set-operation,
partition-top-n and project
- Join other-condition pushdown (`PushDownJoinOtherCondition`,
`ProjectOtherJoinConditionForNestedLoopJoin`)
- `PushFilterInsideJoin`, `JoinExtractOrFromCaseWhen`
- Join reorder (`ReorderJoin`)
- Predicate inference (`InferPredicates`, `CollectFilterAboveConsumer`)
- `PushDownProjectThroughLimit`
- Eager aggregation (`EagerAggRewriter`)
Such expressions are now kept above row-changing operators and are never
cloned.
None
### Check List (For Author)
- Test <!-- At least one of them must be included. -->
- [ ] 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 <!-- Add your reason? -->
- Behavior changed:
- [ ] No.
- [ ] Yes. <!-- Explain the behavior change -->
- Does this need documentation?
- [ ] No.
- [ ] Yes. <!-- Add document PR link here. eg:
https://github.com/apache/doris-website/pull/1214 -->
### Check List (For Reviewer who merge this PR)
- [ ] Confirm the release note
- [ ] Confirm test cases
- [ ] Confirm document
- [ ] Add branch pick label <!-- Add branch pick label that this PR should
merge into -->
--
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]