From 8fc5aabbd5f96536a9ee61e4521793ce1d2f7b3f Mon Sep 17 00:00:00 2001 From: minghong Date: Thu, 9 Jan 2025 12:46:35 +0800 Subject: [PATCH] fix --- .../nereids/glue/translator/PhysicalPlanTranslator.java | 8 +++++++- .../processor/post/ProjectAggregateExpressionsForCse.java | 2 +- 2 files changed, 8 insertions(+), 2 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 85243c4b545420..bfc7d06d27a720 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 @@ -957,7 +957,13 @@ public PlanFragment visitPhysicalHashAggregate( // 1. generate slot reference for each group expression List groupSlots = collectGroupBySlots(groupByExpressions, outputExpressions); ArrayList execGroupingExpressions = groupByExpressions.stream() - .map(e -> ExpressionTranslator.translate(e, context)) + .map(e -> { + Expr result = ExpressionTranslator.translate(e, context); + if (result == null) { + throw new RuntimeException("translate " + e + " failed"); + } + return result; + }) .collect(Collectors.toCollection(ArrayList::new)); // 2. collect agg expressions and generate agg function to slot reference map List aggFunctionOutput = Lists.newArrayList(); diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/processor/post/ProjectAggregateExpressionsForCse.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/processor/post/ProjectAggregateExpressionsForCse.java index 382f21c996a21d..d2db34be51fa9f 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/processor/post/ProjectAggregateExpressionsForCse.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/processor/post/ProjectAggregateExpressionsForCse.java @@ -105,7 +105,7 @@ public Plan visitPhysicalHashAggregate(PhysicalHashAggregate agg PhysicalProject project = (PhysicalProject) aggregate.child(); List newProjections = Lists.newArrayList(); for (NamedExpression expr : project.getProjects()) { - if (aggOutputReplaced.contains(expr)) { + if (!(expr instanceof SlotReference) || aggOutputReplaced.contains(expr)) { newProjections.add(expr); } }