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

commit e041fa5b81ffa896d6bb05af6d423ffaa614f123
Author: AKIRA <[email protected]>
AuthorDate: Sat Feb 18 20:39:56 2023 +0800

    [fix](planner) Nullable of slot descriptor is mistaken and cause BE crash 
#16862
---
 .../org/apache/doris/planner/SetOperationNode.java | 12 +++
 .../data/query_p0/operator/test_set_operator.out   | 15 ++++
 .../query_p0/operator/test_set_operator.groovy     | 91 ++++++++++++++++++++++
 3 files changed, 118 insertions(+)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/planner/SetOperationNode.java 
b/fe/fe-core/src/main/java/org/apache/doris/planner/SetOperationNode.java
index 5d806215d4..11760f79b4 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/planner/SetOperationNode.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/planner/SetOperationNode.java
@@ -207,6 +207,18 @@ public abstract class SetOperationNode extends PlanNode {
             }
             materializedConstExprLists.add(newExprList);
         }
+        if (!resultExprLists.isEmpty()) {
+            List<Expr> exprs = resultExprLists.get(0);
+            TupleDescriptor tupleDescriptor = analyzer.getTupleDesc(tupleId);
+            for (int i = 0; i < exprs.size(); i++) {
+                boolean isNullable = exprs.get(i).isNullable();
+                for (int j = 1; j < resultExprLists.size(); j++) {
+                    isNullable = isNullable || 
resultExprLists.get(j).get(i).isNullable();
+                }
+                tupleDescriptor.getSlots().get(i).setIsNullable(isNullable);
+                tupleDescriptor.computeMemLayout();
+            }
+        }
     }
 
     @Override
diff --git a/regression-test/data/query_p0/operator/test_set_operator.out 
b/regression-test/data/query_p0/operator/test_set_operator.out
new file mode 100644
index 0000000000..1d8bc5ef93
--- /dev/null
+++ b/regression-test/data/query_p0/operator/test_set_operator.out
@@ -0,0 +1,15 @@
+-- This file is automatically generated. You should know what you did if you 
want to edit this
+-- !select --
+1
+1
+3
+4
+5
+5
+5
+51
+6
+7
+9
+9
+
diff --git a/regression-test/suites/query_p0/operator/test_set_operator.groovy 
b/regression-test/suites/query_p0/operator/test_set_operator.groovy
new file mode 100644
index 0000000000..8a9512e977
--- /dev/null
+++ b/regression-test/suites/query_p0/operator/test_set_operator.groovy
@@ -0,0 +1,91 @@
+// 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("test_set_operators", "query,p0") {
+
+    sql """
+        DROP TABLE IF EXISTS t1;
+    """
+
+    sql """
+        CREATE TABLE t1 (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 t1 values(1, 2, 3);
+    """
+
+    sql """insert into t1 values(4, 5, 6);"""
+    sql """insert into t1 values(7, 1, 9);"""
+    sql """insert into t1 values(3, 8, 2);"""
+    sql """insert into t1 values(5, 2, 1);"""
+
+    sql """
+        DROP TABLE IF EXISTS t2;
+    """
+    sql """
+        CREATE TABLE t2 (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 """
+        DROP TABLE IF EXISTS t3;
+    """
+    sql """
+        CREATE TABLE t3 (col1 varchar(32) 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 t3 values('21',5,1,7);"""
+    sql """insert into t3 values('7',9,1,5);"""
+    sql """insert into t3 values('3',5,3,4);"""
+    sql """insert into t3 values('9',8,0,7);"""
+
+    sql """insert into t2 values('1',5,1,7);"""
+    sql """insert into t2 values('51',9,1,5);"""
+    sql """insert into t2 values('6',5,3,4);"""
+    sql """insert into t2 values('9',8,0,7);"""
+
+    order_qt_select """
+        select
+            col1
+        from
+             t1
+        union all
+        select
+            coalesce(t2.col1, t3.col2)  c
+        from
+            t2
+        full join
+            t3 
+            on t2.col1=t3.col1;
+    """
+}
\ No newline at end of file


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to