morrySnow commented on code in PR #40181: URL: https://github.com/apache/doris/pull/40181#discussion_r1741611259
########## fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/BindRelation.java: ########## @@ -215,7 +236,103 @@ private LogicalPlan makeOlapScan(TableIf table, UnboundRelation unboundRelation, unboundRelation.getTableSample()); } } - return checkAndAddDeleteSignFilter(scan, ConnectContext.get(), (OlapTable) table); + if (needGenerateLogicalAggForRandomDistAggTable(scan)) { + return preAggForRandomDistribution(scan); + } else { + return checkAndAddDeleteSignFilter(scan, ConnectContext.get(), (OlapTable) table); + } + } + + private boolean needGenerateLogicalAggForRandomDistAggTable(LogicalOlapScan olapScan) { + if (ConnectContext.get() != null && ConnectContext.get().getState() != null + && ConnectContext.get().getState().isQuery()) { Review Comment: add comments to explain why only query ########## fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/executor/Analyzer.java: ########## @@ -163,8 +162,6 @@ private static List<RewriteJob> buildAnalyzerJobs(Optional<CustomTableResolver> topDown(new EliminateGroupByConstant()), topDown(new SimplifyAggGroupBy()), - // run BuildAggForRandomDistributedTable before NormalizeAggregate in order to optimize the agg plan - topDown(new BuildAggForRandomDistributedTable()), Review Comment: remove this file BuildAggForRandomDistributedTable and rule type for it ########## fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/BindRelation.java: ########## @@ -215,7 +236,103 @@ private LogicalPlan makeOlapScan(TableIf table, UnboundRelation unboundRelation, unboundRelation.getTableSample()); } } - return checkAndAddDeleteSignFilter(scan, ConnectContext.get(), (OlapTable) table); + if (needGenerateLogicalAggForRandomDistAggTable(scan)) { + return preAggForRandomDistribution(scan); + } else { + return checkAndAddDeleteSignFilter(scan, ConnectContext.get(), (OlapTable) table); Review Comment: add comments to explain why these two function is mutually -- 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