diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/glue/translator/PhysicalPlanTranslator.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/glue/translator/PhysicalPlanTranslator.java index 1f58cd8d695f9c..b0734abc5fd980 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/glue/translator/PhysicalPlanTranslator.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/glue/translator/PhysicalPlanTranslator.java @@ -91,6 +91,7 @@ import org.apache.doris.nereids.trees.plans.physical.PhysicalCTEAnchor; import org.apache.doris.nereids.trees.plans.physical.PhysicalCTEConsumer; import org.apache.doris.nereids.trees.plans.physical.PhysicalCTEProducer; +import org.apache.doris.nereids.trees.plans.physical.PhysicalCatalogRelation; import org.apache.doris.nereids.trees.plans.physical.PhysicalDeferMaterializeOlapScan; import org.apache.doris.nereids.trees.plans.physical.PhysicalDeferMaterializeResultSink; import org.apache.doris.nereids.trees.plans.physical.PhysicalDeferMaterializeTopN; @@ -425,7 +426,9 @@ public PlanFragment visitPhysicalFileScan(PhysicalFileScan fileScan, PlanTransla } else { throw new RuntimeException("do not support table type " + table.getType()); } + scanNode.addConjuncts(translateToLegacyConjuncts(fileScan.getConjuncts())); + scanNode.setPushDownAggNoGrouping(context.getTablePushAggOp(table.getId())); TableName tableName = new TableName(null, "", ""); TableRef ref = new TableRef(tableName, null, null); @@ -785,9 +788,7 @@ public PlanFragment visitPhysicalStorageLayerAggregate( || storageLayerAggregate.getRelation() instanceof PhysicalFileScan), "PhysicalStorageLayerAggregate only support PhysicalOlapScan and PhysicalFileScan: " + storageLayerAggregate.getRelation().getClass().getName()); - PlanFragment planFragment = storageLayerAggregate.getRelation().accept(this, context); - ScanNode scanNode = (ScanNode) planFragment.getPlanRoot(); TPushAggOp pushAggOp; switch (storageLayerAggregate.getAggOp()) { case COUNT: @@ -806,7 +807,12 @@ public PlanFragment visitPhysicalStorageLayerAggregate( throw new AnalysisException("Unsupported storage layer aggregate: " + storageLayerAggregate.getAggOp()); } - scanNode.setPushDownAggNoGrouping(pushAggOp); + + context.setTablePushAggOp( + ((PhysicalCatalogRelation) storageLayerAggregate.getRelation()).getTable().getId(), pushAggOp); + + PlanFragment planFragment = storageLayerAggregate.getRelation().accept(this, context); + updateLegacyPlanIdToPhysicalPlan(planFragment.getPlanRoot(), storageLayerAggregate); return planFragment; } diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/glue/translator/PlanTranslatorContext.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/glue/translator/PlanTranslatorContext.java index d3a6450d211290..7617402127eb1d 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/glue/translator/PlanTranslatorContext.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/glue/translator/PlanTranslatorContext.java @@ -39,6 +39,7 @@ import org.apache.doris.planner.PlanNode; import org.apache.doris.planner.PlanNodeId; import org.apache.doris.planner.ScanNode; +import org.apache.doris.thrift.TPushAggOp; import com.google.common.annotations.VisibleForTesting; import com.google.common.collect.Lists; @@ -87,6 +88,8 @@ public class PlanTranslatorContext { private final Map cteProducerMap = Maps.newHashMap(); + private final Map tablePushAggOp = Maps.newHashMap(); + public PlanTranslatorContext(CascadesContext ctx) { this.translator = new RuntimeFilterTranslator(ctx.getRuntimeFilterContext()); } @@ -221,4 +224,12 @@ public TupleDescriptor getTupleDesc(TupleId tupleId) { public DescriptorTable getDescTable() { return descTable; } + + public void setTablePushAggOp(Long tableId, TPushAggOp aggOp) { + tablePushAggOp.put(tableId, aggOp); + } + + public TPushAggOp getTablePushAggOp(Long tableId) { + return tablePushAggOp.getOrDefault(tableId, TPushAggOp.NONE); + } }