This is an automated email from the ASF dual-hosted git repository.

morningman pushed a commit to branch branch-1.2-lts
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-1.2-lts by this push:
     new 5259892dd1 [fix](planner) Fix incosistency between groupby expression 
and output of aggregation node (#17583)
5259892dd1 is described below

commit 5259892dd176bb03bbf4eb5175fd757daeaf1e67
Author: AKIRA <33112463+kikyou1...@users.noreply.github.com>
AuthorDate: Thu Mar 9 16:52:10 2023 +0900

    [fix](planner) Fix incosistency between groupby expression and output of 
aggregation node (#17583)
    
    pick from #17438
---
 .../org/apache/doris/planner/AggregationNode.java  | 10 ++++
 .../query_p0/aggregate/nullablity_consistency.out  |  4 ++
 .../aggregate/nullablity_consistency.groovy        | 63 ++++++++++++++++++++++
 3 files changed, 77 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 da1492c253..685430cd5c 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
@@ -362,4 +362,14 @@ public class AggregationNode extends PlanNode {
         }
         return result;
     }
+
+    @Override
+    public void finalize(Analyzer analyzer) throws UserException {
+        super.finalize(analyzer);
+        List<Expr> groupingExprs = aggInfo.getGroupingExprs();
+        for (int i = 0; i < groupingExprs.size(); i++) {
+            
aggInfo.getOutputTupleDesc().getSlots().get(i).setIsNullable(groupingExprs.get(i).isNullable());
+            aggInfo.getOutputTupleDesc().computeMemLayout();
+        }
+    }
 }
diff --git a/regression-test/data/query_p0/aggregate/nullablity_consistency.out 
b/regression-test/data/query_p0/aggregate/nullablity_consistency.out
new file mode 100644
index 0000000000..e011475a94
--- /dev/null
+++ b/regression-test/data/query_p0/aggregate/nullablity_consistency.out
@@ -0,0 +1,4 @@
+-- This file is automatically generated. You should know what you did if you 
want to edit this
+-- !sql --
+\N
+
diff --git 
a/regression-test/suites/query_p0/aggregate/nullablity_consistency.groovy 
b/regression-test/suites/query_p0/aggregate/nullablity_consistency.groovy
new file mode 100644
index 0000000000..6f4cc1a4a9
--- /dev/null
+++ b/regression-test/suites/query_p0/aggregate/nullablity_consistency.groovy
@@ -0,0 +1,63 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+suite("aggregate_nullability_consistency") {
+    sql """DROP TABLE IF EXISTS t114;"""
+    sql """CREATE TABLE t114 (col1 varchar(11451) not null, col2 int not null, 
col3 int not null)
+    UNIQUE KEY(col1)
+    DISTRIBUTED BY HASH(col1)
+    BUCKETS 3
+    PROPERTIES(
+            "replication_num"="1",
+            "enable_unique_key_merge_on_write"="true"
+    );"""
+    sql """insert into t114 values('1994',1644, 1994);"""
+
+    sql """DROP TABLE IF EXISTS t115;"""
+    sql """CREATE TABLE t115 (col1 varchar(32) not null, col2 int not null, 
col3 int not null, col4 int not null)
+    DISTRIBUTED BY HASH(col3)
+    BUCKETS 3
+    PROPERTIES(
+            "replication_num"="1"
+    );"""
+
+    sql """insert into t115 values("1994", 1994, 1995, 1996);"""
+
+    qt_sql """WITH a_cte AS (
+            SELECT *
+                    FROM   t114
+    )
+
+    SELECT
+    col1
+    FROM      (
+            SELECT
+            lower(b.col1) col1
+                    FROM      a_cte a
+                    LEFT JOIN t115 b
+                    ON        a.col2=b.col2
+                    UNION ALL
+                    SELECT
+                    lower(b.col1) col1
+                    FROM      a_cte a
+                    LEFT JOIN t115 b
+                    ON        a.col2=b.col2) tt
+    GROUP BY
+    col1"""
+
+
+}
\ No newline at end of file


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to