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

morrysnow pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-2.0 by this push:
     new 0fb626398df [fix](Nereids) adjust nullable for set operation may cause 
IndexOutOfBound (#35589)
0fb626398df is described below

commit 0fb626398df897cae5fced69c0d485a8ed9d202c
Author: morrySnow <[email protected]>
AuthorDate: Wed May 29 18:44:02 2024 +0800

    [fix](Nereids) adjust nullable for set operation may cause IndexOutOfBound 
(#35589)
    
    pick from master #35588
    
    after we refactor set oepration, let it has projection ability, its
    output size may diff with its child's output size. so we should use it
    output size as nullable flag list size to ensure it has same size with
    set operation's output.
---
 .../nereids/rules/rewrite/AdjustNullable.java      |  2 +-
 .../adjust_nullable/set_operation.groovy           | 46 ++++++++++++++++++++++
 2 files changed, 47 insertions(+), 1 deletion(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/AdjustNullable.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/AdjustNullable.java
index c5c9b8520fe..03274defb75 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/AdjustNullable.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/AdjustNullable.java
@@ -145,7 +145,7 @@ public class AdjustNullable extends 
DefaultPlanRewriter<Map<ExprId, Slot>> imple
         ImmutableList.Builder<List<SlotReference>> newChildrenOutputs = 
ImmutableList.builder();
         List<Boolean> inputNullable = null;
         if (!setOperation.children().isEmpty()) {
-            inputNullable = setOperation.child(0).getOutput().stream()
+            inputNullable = setOperation.getRegularChildOutput(0).stream()
                     
.map(ExpressionTrait::nullable).collect(Collectors.toList());
             for (int i = 0; i < setOperation.arity(); i++) {
                 List<Slot> childOutput = setOperation.child(i).getOutput();
diff --git 
a/regression-test/suites/nereids_rules_p0/adjust_nullable/set_operation.groovy 
b/regression-test/suites/nereids_rules_p0/adjust_nullable/set_operation.groovy
new file mode 100644
index 00000000000..1eba278c6b4
--- /dev/null
+++ 
b/regression-test/suites/nereids_rules_p0/adjust_nullable/set_operation.groovy
@@ -0,0 +1,46 @@
+// 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_operation_adjust_nullable") {
+
+    sql """
+        DROP TABLE IF EXISTS t1
+    """
+    sql """
+        DROP TABLE IF EXISTS t2
+    """
+
+    sql """
+        CREATE TABLE t1(c1 varchar) DISTRIBUTED BY hash(c1) PROPERTIES 
("replication_num" = "1");
+    """
+
+    sql """
+        CREATE TABLE t2(c2 date) DISTRIBUTED BY hash(c2) PROPERTIES 
("replication_num" = "1");
+    """
+
+    sql """
+        insert into t1 values('+06-00');
+    """
+
+    sql """
+        insert into t2 values('1990-11-11');
+    """
+
+    sql """
+        SELECT c1, c1 FROM t1 EXCEPT SELECT c2, c2 FROM t2;
+    """
+}


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

Reply via email to