morrySnow commented on code in PR #30870: URL: https://github.com/apache/doris/pull/30870#discussion_r1527777531
########## fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVCache.java: ########## @@ -62,13 +75,27 @@ public static MTMVCache from(MTMV mtmv, ConnectContext connectContext) { mvSqlStatementContext.getConnectContext().setStatementContext(mvSqlStatementContext); } Plan originPlan = planner.plan(unboundMvPlan, PhysicalProperties.ANY, ExplainLevel.REWRITTEN_PLAN); + // change result sink to table sink for eliminate sort Plan mvPlan = originPlan.accept(new DefaultPlanRewriter<Object>() { @Override - public Plan visit(Plan plan, Object context) { - if (plan instanceof LogicalResultSink) { - return ((LogicalResultSink<Plan>) plan).child(); - } - return super.visit(plan, context); + public Plan visitLogicalResultSink(LogicalResultSink<? extends Plan> logicalResultSink, Object context) { + return new LogicalOlapTableSink<>(new Database(), mtmv, mtmv.getBaseSchema(), + mtmv.getPartitionIds(), + logicalResultSink.getOutput() + .stream().map(NamedExpression.class::cast).collect(Collectors.toList()), + mtmv.isPartitionedTable(), DMLCommandType.NONE, logicalResultSink.child()); Review Comment: why not replace result sink to unbound table sink on `unboundMvPlan` to avoid call ELIMINATE_SORT explicity -- 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