morrySnow commented on code in PR #34771: URL: https://github.com/apache/doris/pull/34771#discussion_r1599276476
########## fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/OrExpansion.java: ########## @@ -73,63 +80,109 @@ public class OrExpansion extends OneExplorationRuleFactory { .build(); @Override - public Rule build() { - return logicalJoin(any(), any()).when(JoinUtils::shouldNestedLoopJoin) - .whenNot(LogicalJoin::isMarkJoin) - .when(join -> supportJoinType.contains(join.getJoinType()) - && ConnectContext.get().getSessionVariable().getEnablePipelineEngine()) - .thenApply(ctx -> { - LogicalJoin<? extends Plan, ? extends Plan> join = ctx.root; - Preconditions.checkArgument(join.getHashJoinConjuncts().isEmpty(), - "Only Expansion nest loop join without hashCond"); + public Plan rewriteRoot(Plan plan, JobContext jobContext) { + OrExpandsionContext ctx = new OrExpandsionContext( + jobContext.getCascadesContext().getStatementContext(), jobContext.getCascadesContext()); + if (!(plan instanceof LogicalResultSink)) { Review Comment: if we have cte in sql, the root may not be LogicalResultSink. the plan could be ``` CteAnchor1 +-- CteProducer1 +-- CteAnchor2 +-- CteProducer2 +-- ResultSink +-- ... ``` ########## fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/OrExpansion.java: ########## @@ -73,63 +80,109 @@ public class OrExpansion extends OneExplorationRuleFactory { .build(); @Override - public Rule build() { - return logicalJoin(any(), any()).when(JoinUtils::shouldNestedLoopJoin) - .whenNot(LogicalJoin::isMarkJoin) - .when(join -> supportJoinType.contains(join.getJoinType()) - && ConnectContext.get().getSessionVariable().getEnablePipelineEngine()) - .thenApply(ctx -> { - LogicalJoin<? extends Plan, ? extends Plan> join = ctx.root; - Preconditions.checkArgument(join.getHashJoinConjuncts().isEmpty(), - "Only Expansion nest loop join without hashCond"); + public Plan rewriteRoot(Plan plan, JobContext jobContext) { + OrExpandsionContext ctx = new OrExpandsionContext( + jobContext.getCascadesContext().getStatementContext(), jobContext.getCascadesContext()); + if (!(plan instanceof LogicalResultSink)) { Review Comment: BTW, u should use `LogicalSink` to support insert into -- 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: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org