From 37b90021b7964a87deefd2fdd02380e062d09f05 Mon Sep 17 00:00:00 2001 From: starocean999 <40539150+starocean999@users.noreply.github.com> Date: Fri, 25 Aug 2023 11:21:35 +0800 Subject: [PATCH] [fix](planner)literal expr should do nothing in substituteImpl() method (#23438) substitute a literal expr is pointless and wrong. This pr keep literal expr unchanged during substitute process --- .../org/apache/doris/analysis/LiteralExpr.java | 6 ++++++ .../correctness_p0/test_subquery_with_agg.out | 3 +++ .../correctness_p0/test_subquery_with_agg.groovy | 15 +++++++++++++++ 3 files changed, 24 insertions(+) diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/LiteralExpr.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/LiteralExpr.java index bde041aeef..2e2eed316b 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/analysis/LiteralExpr.java +++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/LiteralExpr.java @@ -402,4 +402,10 @@ public abstract class LiteralExpr extends Expr implements Comparable exprs, SelectStmt stmt, boolean ignoreAlias, TupleDescriptor tuple) { return true; } + + @Override + protected Expr substituteImpl(ExprSubstitutionMap smap, ExprSubstitutionMap disjunctsMap, + Analyzer analyzer) { + return this; + } } diff --git a/regression-test/data/correctness_p0/test_subquery_with_agg.out b/regression-test/data/correctness_p0/test_subquery_with_agg.out index 4c443b8493..d055dbd668 100644 --- a/regression-test/data/correctness_p0/test_subquery_with_agg.out +++ b/regression-test/data/correctness_p0/test_subquery_with_agg.out @@ -4,3 +4,6 @@ 2 3 +-- !select2 -- +0 2.0 + diff --git a/regression-test/suites/correctness_p0/test_subquery_with_agg.groovy b/regression-test/suites/correctness_p0/test_subquery_with_agg.groovy index 260cf111cb..e0592830ff 100644 --- a/regression-test/suites/correctness_p0/test_subquery_with_agg.groovy +++ b/regression-test/suites/correctness_p0/test_subquery_with_agg.groovy @@ -63,6 +63,21 @@ suite("test_subquery_with_agg") { subq_1.gid; """ + qt_select2 """ + select + 0 as row_number, + round(sum(num) / 10, 0) as org_id + from + ( + select + num + from + agg_subquery_table + ) t + group by + 1; + """ + sql """ drop table if exists agg_subquery_table; """