github-actions[bot] commented on code in PR #62742:
URL: https://github.com/apache/doris/pull/62742#discussion_r3129526808
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/PushDownJoinOtherCondition.java:
##########
@@ -75,7 +75,16 @@ public Rule build() {
Set<Expression> rightConjuncts = Sets.newHashSet();
for (Expression otherConjunct : otherJoinConjuncts) {
- if
(PUSH_DOWN_LEFT_VALID_TYPE.contains(join.getJoinType())
+ // A conjunct that contains a unique (non-idempotent)
function such as
+ // rand()/uuid() must NOT be pushed into a single
child. Evaluating it
+ // per-input-row instead of per-join-pair changes
semantics (every
+ // surviving row has the filter re-drawn once instead
of once per pair).
+ // In addition, a predicate like `rand() > 0.5` has
empty input slots,
+ // so `allCoveredBy(..., child.getOutputSet())` would
otherwise wrongly
+ // return true because `Set.containsAll(emptySet) ==
true`.
+ if (otherConjunct.containsUniqueFunction()) {
Review Comment:
This fixes the direct AST case, but I think a normalized-slot path is still
open. `ProjectOtherJoinConditionForNestedLoopJoin` can later rewrite a
one-sided predicate like `t2.id * random(1, 100) between 100 and 200` into a
child-local boolean slot; the final `PUSH_DOWN_FILTERS` pass then sees only
that slot and pushes it into the child because `containsUniqueFunction()` is
now false. The updated
`regression-test/data/nereids_rules_p0/unique_function/add_project_for_unique_function.out`
still shows exactly that for `join_1` (and likewise pushes `random(1, 100)
between 1 and 10` to the left child), which changes evaluation from once per
joined pair to once per input row. This is distinct from the already-raised
direct `containsUniqueFunction()` thread because the unique function has
already been hidden behind a slot by the time the later pushdown runs.
--
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]