github-actions[bot] commented on code in PR #70471:
URL: https://github.com/apache/doris/pull/70471#discussion_r4655961062
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/OrExpansion.java:
##########
@@ -160,19 +162,23 @@ public Plan visitLogicalJoin(LogicalJoin<? extends Plan,
? extends Plan> join, O
joins.addAll(expandInnerJoin(ctx.cascadesContext,
hashOtherConditions,
join, leftProducer, rightProducer, leftCloneToLeft,
rightCloneToRight));
} else if (join.getJoinType().isOuterJoin()) {
- // left outer join = inner join union left anti join
+ // Outer join = matching rows union unmatched rows from each
preserved side.
joins.addAll(expandInnerJoin(ctx.cascadesContext,
hashOtherConditions,
join, leftProducer, rightProducer, leftCloneToLeft,
rightCloneToRight));
- joins.add(expandLeftAntiJoin(ctx.cascadesContext,
- hashOtherConditions, join, leftProducer, rightProducer,
leftCloneToLeft, rightCloneToRight));
- if (join.getJoinType().equals(JoinType.FULL_OUTER_JOIN)) {
- // full outer join = inner join union left anti join union
right anti join
+ if (join.getJoinType().isLeftOuterJoin() ||
join.getJoinType().isFullOuterJoin()) {
+ joins.add(expandLeftAntiJoin(ctx.cascadesContext,
+ hashOtherConditions, join, leftProducer,
rightProducer, leftCloneToLeft, rightCloneToRight));
Review Comment:
[P1] Do not expand right joins when retained ON predicates are volatile or
non-movable. For `RIGHT OUTER JOIN ... ON (l.k = r.k OR l.a = r.a) AND rand() <
0.5`, `splitOrCondition` keeps `rand() < 0.5` in `otherConditions`, then
`expandInnerJoin` and the swapped `expandLeftAntiJoin` copy it into every
branch/anti step. The original evaluates `rand()` once per candidate pair; the
expanded plan can evaluate it again while deciding whether a right row is
unmatched, producing a match plus a null-extended row or suppressing one
depending on later random values. Reject this expansion or materialize the
predicate once before branching (also cover `NoneMovableFunction`).
--
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]