From 9cc7fd3d6cc6362a025e1e7eb09255be5c3c2cfe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A7=9C=E5=87=AF?= Date: Wed, 30 Aug 2023 18:40:27 +0800 Subject: [PATCH 1/2] [Fix](PhysicalPlanTranslator) forget setPushDownAggNoGrouping in OlapScanNode --- .../doris/nereids/glue/translator/PhysicalPlanTranslator.java | 1 + 1 file changed, 1 insertion(+) 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 e16e851fe324da..959de5e3435fb6 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 @@ -576,6 +576,7 @@ public PlanFragment visitPhysicalOlapScan(PhysicalOlapScan olapScan, PlanTransla expr, olapScanNode, context) ) ); + olapScanNode.setPushDownAggNoGrouping(context.getTablePushAggOp(olapTable.getId())); // TODO: we need to remove all finalizeForNereids olapScanNode.finalizeForNereids(); // Create PlanFragment From 00ea3d0141d44bc5eb7b66398bb218cac6084919 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A7=9C=E5=87=AF?= Date: Wed, 30 Aug 2023 21:55:16 +0800 Subject: [PATCH 2/2] use relation id instead of table id --- .../glue/translator/PhysicalPlanTranslator.java | 9 ++++----- .../glue/translator/PlanTranslatorContext.java | 11 ++++++----- 2 files changed, 10 insertions(+), 10 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 959de5e3435fb6..c8b4a701a3b9bb 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; @@ -437,7 +436,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); @@ -576,7 +575,7 @@ public PlanFragment visitPhysicalOlapScan(PhysicalOlapScan olapScan, PlanTransla expr, olapScanNode, context) ) ); - olapScanNode.setPushDownAggNoGrouping(context.getTablePushAggOp(olapTable.getId())); + olapScanNode.setPushDownAggNoGrouping(context.getRelationPushAggOp(olapScan.getRelationId())); // TODO: we need to remove all finalizeForNereids olapScanNode.finalizeForNereids(); // Create PlanFragment @@ -818,8 +817,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 4e90d3eea251ae..4136def7017988 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.PhysicalCTEConsumer; import org.apache.doris.nereids.trees.plans.physical.PhysicalCTEProducer; import org.apache.doris.nereids.trees.plans.physical.PhysicalHashAggregate; @@ -94,7 +95,7 @@ public class PlanTranslatorContext { private final Map cteScanNodeMap = Maps.newHashMap(); - private final Map tablePushAggOp = Maps.newHashMap(); + private final Map tablePushAggOp = Maps.newHashMap(); public PlanTranslatorContext(CascadesContext ctx) { this.translator = new RuntimeFilterTranslator(ctx.getRuntimeFilterContext()); @@ -239,11 +240,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); } }