@ -104,6 +104,31 @@ public class OrExpansion extends DefaultPlanRewriter<OrExpandsionContext> implem
|
||||
return hasNewChildren ? plan.withChildren(newChildren) : plan;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Plan visitLogicalCTEAnchor(
|
||||
LogicalCTEAnchor<? extends Plan, ? extends Plan> anchor, OrExpandsionContext ctx) {
|
||||
Plan child1 = this.visit(anchor.child(0), ctx);
|
||||
// Consumer's CTE must be child of the cteAnchor in this case:
|
||||
// anchor
|
||||
// +-producer1
|
||||
// +-agg(consumer1) join agg(consumer1)
|
||||
// ------------>
|
||||
// anchor
|
||||
// +-producer1
|
||||
// +-anchor
|
||||
// +--producer2(agg2(consumer1))
|
||||
// +--producer3(agg3(consumer1))
|
||||
// +-consumer2 join consumer3
|
||||
OrExpandsionContext consumerContext =
|
||||
new OrExpandsionContext(ctx.statementContext, ctx.cascadesContext);
|
||||
Plan child2 = this.visit(anchor.child(1), consumerContext);
|
||||
for (int i = consumerContext.cteProducerList.size() - 1; i >= 0; i--) {
|
||||
LogicalCTEProducer<? extends Plan> producer = consumerContext.cteProducerList.get(i);
|
||||
child2 = new LogicalCTEAnchor<>(producer.getCteId(), producer, child2);
|
||||
}
|
||||
return anchor.withChildren(ImmutableList.of(child1, child2));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Plan visitLogicalJoin(LogicalJoin<? extends Plan, ? extends Plan> join, OrExpandsionContext ctx) {
|
||||
join = (LogicalJoin<? extends Plan, ? extends Plan>) this.visit(join, ctx);
|
||||
|
||||
@ -340,8 +340,14 @@ public class LogicalPlanDeepCopier extends DefaultPlanRewriter<DeepCopierContext
|
||||
List<Expression> markJoinConjuncts = join.getMarkJoinConjuncts().stream()
|
||||
.map(c -> ExpressionDeepCopier.INSTANCE.deepCopy(c, context))
|
||||
.collect(ImmutableList.toImmutableList());
|
||||
Optional<MarkJoinSlotReference> markJoinSlotReference = Optional.empty();
|
||||
if (join.getMarkJoinSlotReference().isPresent()) {
|
||||
markJoinSlotReference = Optional.of((MarkJoinSlotReference) ExpressionDeepCopier.INSTANCE
|
||||
.deepCopy(join.getMarkJoinSlotReference().get(), context));
|
||||
|
||||
}
|
||||
return new LogicalJoin<>(join.getJoinType(), hashJoinConjuncts, otherJoinConjuncts, markJoinConjuncts,
|
||||
join.getDistributeHint(), join.getMarkJoinSlotReference(), children, join.getJoinReorderContext());
|
||||
join.getDistributeHint(), markJoinSlotReference, children, join.getJoinReorderContext());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user