morrySnow commented on code in PR #62742:
URL: https://github.com/apache/doris/pull/62742#discussion_r3339024337
##########
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())
+ // Keep slot-free volatile predicates in
otherJoinConjuncts. Otherwise
+ // `allCoveredBy(..., child.getOutputSet())` would
arbitrarily push
+ // `rand() > 0.5` into one side because empty slots
are covered by both
+ // children. Side-specific volatile predicates are
still pushed down for
+ // performance, matching PostgreSQL's treatment of
single-relation INNER
+ // JOIN ON quals as base restrictions.
+ if (otherConjunct.containsVolatileExpression()
Review Comment:
This guard is still too narrow for volatile ON predicates. A one-sided
condition such as `t1.id + rand() > 0.5` has non-empty input slots, so it falls
through to `allCoveredBy(...)` and is pushed into one child. For an INNER/CROSS
JOIN, though, the ON predicate is evaluated per joined pair; after this rewrite
the random value is evaluated once per input row and reused for every matching
row from the other side. With one left row joining two right rows, the original
plan can keep one pair and drop the other, while the pushed plan can only keep
both or none. `PushDownFilterThroughJoin` already keeps all
`containsVolatileExpression()` predicates above the join for this reason, so
this path should not push side-specific volatile ON conjuncts either.
--
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]