Skip to content

Commit 27bdf46

Browse files
committed
[CALCITE-7274] Code Review
1 parent e2404c9 commit 27bdf46

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

core/src/main/java/org/apache/calcite/sql2rel/SqlToRelConverter.java

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3103,12 +3103,25 @@ protected RelNode createJoin(
31033103
p.id, requiredCols, joinType);
31043104
}
31053105

3106-
final RelNode node =
3106+
RelNode node =
31073107
relBuilder.push(leftRel)
31083108
.push(rightRel)
31093109
.join(joinType, joinCond)
31103110
.build();
31113111

3112+
final CorrelationUse correlationUseInJoin = getCorrelationUse(bb, node);
3113+
if (correlationUseInJoin != null) {
3114+
assert correlationUseInJoin.r instanceof Join;
3115+
Join joinRelTemp = (Join) correlationUseInJoin.r;
3116+
node =
3117+
LogicalJoin.create(joinRelTemp.getLeft(),
3118+
joinRelTemp.getRight(),
3119+
joinRelTemp.getHints(),
3120+
joinRelTemp.getCondition(),
3121+
ImmutableSet.of(correlationUseInJoin.id),
3122+
joinRelTemp.getJoinType());
3123+
}
3124+
31123125
// If join conditions are pushed down, update the leaves.
31133126
if (node instanceof Project) {
31143127
final Join newJoin = (Join) node.getInputs().get(0);
@@ -3377,7 +3390,7 @@ private void convertJoin(Blackboard bb, SqlJoin join) {
33773390
}
33783391
condition = simplifyPredicate(condition);
33793392

3380-
RelNode joinRel;
3393+
final RelNode joinRel;
33813394
if (joinType == JoinType.ASOF || joinType == JoinType.LEFT_ASOF) {
33823395
SqlNode sqlMatchCondition =
33833396
requireNonNull(((SqlAsofJoin) join).getMatchCondition(),
@@ -3395,18 +3408,6 @@ private void convertJoin(Blackboard bb, SqlJoin join) {
33953408
joinRel =
33963409
createJoin(fromBlackboard, leftRel, rightRel, condition,
33973410
convertJoinType(joinType));
3398-
final CorrelationUse p = getCorrelationUse(bb, joinRel);
3399-
if (joinRel instanceof Join && p != null) {
3400-
assert p.r instanceof Join;
3401-
Join joinRelTemp = (Join) p.r;
3402-
joinRel =
3403-
LogicalJoin.create(joinRelTemp.getLeft(),
3404-
joinRelTemp.getRight(),
3405-
joinRelTemp.getHints(),
3406-
joinRelTemp.getCondition(),
3407-
ImmutableSet.of(p.id),
3408-
joinRelTemp.getJoinType());
3409-
}
34103411
}
34113412
relBuilder.push(joinRel);
34123413
relBuilder.project(relBuilder.fields());

0 commit comments

Comments
 (0)