From 4692a62e47616e7d19bf0132d76a45c7c490982d Mon Sep 17 00:00:00 2001 From: starocean999 <40539150+starocean999@users.noreply.github.com> Date: Tue, 2 Jan 2024 15:53:28 +0800 Subject: [PATCH] [fix](planner)nullable info of agg node's intermediate and output slots should be same (#29315) --- .../apache/doris/planner/AggregationNode.java | 1 + .../correctness_p0/test_agg_materialize.out | 3 + .../test_agg_materialize.groovy | 55 +++++++++++++++++++ 3 files changed, 59 insertions(+) diff --git a/fe/fe-core/src/main/java/org/apache/doris/planner/AggregationNode.java b/fe/fe-core/src/main/java/org/apache/doris/planner/AggregationNode.java index f0e31157d3f957..23522625bb8da2 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/planner/AggregationNode.java +++ b/fe/fe-core/src/main/java/org/apache/doris/planner/AggregationNode.java @@ -374,6 +374,7 @@ public void finalize(Analyzer analyzer) throws UserException { List groupingExprs = aggInfo.getGroupingExprs(); for (int i = 0; i < groupingExprs.size(); i++) { aggInfo.getOutputTupleDesc().getSlots().get(i).setIsNullable(groupingExprs.get(i).isNullable()); + aggInfo.getIntermediateTupleDesc().getSlots().get(i).setIsNullable(groupingExprs.get(i).isNullable()); aggInfo.getOutputTupleDesc().computeMemLayout(); } } diff --git a/regression-test/data/correctness_p0/test_agg_materialize.out b/regression-test/data/correctness_p0/test_agg_materialize.out index 26c36a0045e46b..d74ca4811b48a2 100644 --- a/regression-test/data/correctness_p0/test_agg_materialize.out +++ b/regression-test/data/correctness_p0/test_agg_materialize.out @@ -6,3 +6,6 @@ 1 qycs +-- !selectx -- +1 1 + diff --git a/regression-test/suites/correctness_p0/test_agg_materialize.groovy b/regression-test/suites/correctness_p0/test_agg_materialize.groovy index eb44b85fafc522..06c0e26b8c581b 100644 --- a/regression-test/suites/correctness_p0/test_agg_materialize.groovy +++ b/regression-test/suites/correctness_p0/test_agg_materialize.groovy @@ -100,4 +100,59 @@ suite("test_agg_materialize") { ORDER BY SPJ.org_code; """ sql """drop table if exists c5749_bug_t;""" + + sql """drop table if exists table_test_count_distinct;""" + sql """CREATE TABLE `table_test_count_distinct` ( + `special_zone_name` VARCHAR(65532) NULL, + `day` VARCHAR(65532) NOT NULL + ) ENGINE=OLAP + DUPLICATE KEY(`special_zone_name`) + COMMENT 'OLAP' + DISTRIBUTED BY HASH(`special_zone_name`) BUCKETS 1 + PROPERTIES ( + "replication_allocation" = "tag.location.default: 1" + );""" + sql """insert into + table_test_count_distinct + values + ( + 'a', + "2023-12-01" + );""" + qt_selectx"""SELECT + (COUNT(DISTINCT descript)) as c475859316, + (COUNT(DISTINCT day)) as c125327027 + FROM + ( + SELECT + descript, + day + FROM + ( + with tmp2 as ( + select + special_zone_name as descript, + cast(day as datev2) as day + from + table_test_count_distinct + union + all + select + special_zone_name as descript, + + cast(day as datev2) as day + from + table_test_count_distinct + ) + select + t1.descript, + t1.day + from + tmp2 t1 + + ) t665446993 + ) t1600566476 + GROUP BY + day;""" + sql """drop table if exists table_test_count_distinct;""" }