From 3e7d64e4db4978c04ef09ae2f4fc51c52369157c Mon Sep 17 00:00:00 2001 From: airborne12 Date: Thu, 31 Aug 2023 11:49:55 +0800 Subject: [PATCH] [Fix](PhysicalPlanTranslator) forget setPushDownAggNoGrouping in OlapScanNode (#23675) * [Fix](PhysicalPlanTranslator) forget setPushDownAggNoGrouping in OlapScanNode * use relation id instead of table id --- .../glue/translator/PhysicalPlanTranslator.java | 8 ++++---- .../glue/translator/PlanTranslatorContext.java | 11 ++++++----- 2 files changed, 10 insertions(+), 9 deletions(-) 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 b0734abc5fd980..406dda54859714 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,7 +91,6 @@ 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; @@ -428,7 +427,7 @@ public PlanFragment visitPhysicalFileScan(PhysicalFileScan fileScan, PlanTransla } scanNode.addConjuncts(translateToLegacyConjuncts(fileScan.getConjuncts())); - scanNode.setPushDownAggNoGrouping(context.getTablePushAggOp(table.getId())); + scanNode.setPushDownAggNoGrouping(context.getRelationPushAggOp(fileScan.getRelationId())); TableName tableName = new TableName(null, "", ""); TableRef ref = new TableRef(tableName, null, null); @@ -564,6 +563,7 @@ public PlanFragment visitPhysicalOlapScan(PhysicalOlapScan olapScan, PlanTransla expr, olapScanNode, context) ) ); + olapScanNode.setPushDownAggNoGrouping(context.getRelationPushAggOp(olapScan.getRelationId())); // TODO: we need to remove all finalizeForNereids olapScanNode.finalizeForNereids(); // Create PlanFragment @@ -808,8 +808,8 @@ public PlanFragment visitPhysicalStorageLayerAggregate( + storageLayerAggregate.getAggOp()); } - context.setTablePushAggOp( - ((PhysicalCatalogRelation) storageLayerAggregate.getRelation()).getTable().getId(), pushAggOp); + context.setRelationPushAggOp( + storageLayerAggregate.getRelation().getRelationId(), pushAggOp); PlanFragment planFragment = storageLayerAggregate.getRelation().accept(this, context); 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 7617402127eb1d..256b37d70572e4 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 @@ -32,6 +32,7 @@ import org.apache.doris.nereids.trees.expressions.ExprId; import org.apache.doris.nereids.trees.expressions.SlotReference; import org.apache.doris.nereids.trees.expressions.VirtualSlotReference; +import org.apache.doris.nereids.trees.plans.RelationId; import org.apache.doris.nereids.trees.plans.physical.PhysicalCTEProducer; import org.apache.doris.nereids.trees.plans.physical.PhysicalHashAggregate; import org.apache.doris.planner.PlanFragment; @@ -88,7 +89,7 @@ public class PlanTranslatorContext { private final Map cteProducerMap = Maps.newHashMap(); - private final Map tablePushAggOp = Maps.newHashMap(); + private final Map tablePushAggOp = Maps.newHashMap(); public PlanTranslatorContext(CascadesContext ctx) { this.translator = new RuntimeFilterTranslator(ctx.getRuntimeFilterContext()); @@ -225,11 +226,11 @@ public DescriptorTable getDescTable() { return descTable; } - public void setTablePushAggOp(Long tableId, TPushAggOp aggOp) { - tablePushAggOp.put(tableId, aggOp); + public void setRelationPushAggOp(RelationId relationId, TPushAggOp aggOp) { + tablePushAggOp.put(relationId, aggOp); } - public TPushAggOp getTablePushAggOp(Long tableId) { - return tablePushAggOp.getOrDefault(tableId, TPushAggOp.NONE); + public TPushAggOp getRelationPushAggOp(RelationId relationId) { + return tablePushAggOp.getOrDefault(relationId, TPushAggOp.NONE); } }