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

yiguolei pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/master by this push:
     new 3cdd19821d [fix](sort)the slot in sort node should be nullable if it's 
outer joined (#12193)
3cdd19821d is described below

commit 3cdd19821d386255af3c133482068a84594c4d13
Author: starocean999 <[email protected]>
AuthorDate: Wed Aug 31 14:34:14 2022 +0800

    [fix](sort)the slot in sort node should be nullable if it's outer joined 
(#12193)
    
    The sort node's output expr should be nullable if it is outer joined.
---
 .../java/org/apache/doris/analysis/SortInfo.java   |   4 +
 .../data/correctness_p0/test_outer_join_sort.out   |   4 +
 .../correctness_p0/test_outer_join_sort.groovy     | 106 +++++++++++++++++++++
 3 files changed, 114 insertions(+)

diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/SortInfo.java 
b/fe/fe-core/src/main/java/org/apache/doris/analysis/SortInfo.java
index 01173a2433..f090c2af80 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/SortInfo.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/SortInfo.java
@@ -242,6 +242,10 @@ public class SortInfo {
                 SlotDescriptor origSlotDesc = origSlotRef.getDesc();
                 SlotDescriptor materializedDesc =
                         analyzer.copySlotDescriptor(origSlotDesc, 
sortTupleDesc);
+                // set to nullable if the origSlot is outer joined
+                if (analyzer.isOuterJoined(origSlotDesc.getParent().getId())) {
+                    materializedDesc.setIsNullable(true);
+                }
                 SlotRef cloneRef = new SlotRef(materializedDesc);
                 substOrderBy.put(origSlotRef, cloneRef);
                 sortTupleExprs.add(origSlotRef);
diff --git a/regression-test/data/correctness_p0/test_outer_join_sort.out 
b/regression-test/data/correctness_p0/test_outer_join_sort.out
new file mode 100644
index 0000000000..72d126351a
--- /dev/null
+++ b/regression-test/data/correctness_p0/test_outer_join_sort.out
@@ -0,0 +1,4 @@
+-- This file is automatically generated. You should know what you did if you 
want to edit this
+-- !select --
+1
+
diff --git a/regression-test/suites/correctness_p0/test_outer_join_sort.groovy 
b/regression-test/suites/correctness_p0/test_outer_join_sort.groovy
new file mode 100644
index 0000000000..93b575627f
--- /dev/null
+++ b/regression-test/suites/correctness_p0/test_outer_join_sort.groovy
@@ -0,0 +1,106 @@
+// 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_outer_join_sort") {
+    sql """
+        drop table if exists outerjoin_A;
+    """
+
+    sql """
+        drop table if exists outerjoin_B;
+    """
+
+    sql """
+        drop table if exists outerjoin_C;
+    """
+
+    sql """
+        create table outerjoin_A ( a int not null )
+        ENGINE=OLAP
+        DISTRIBUTED BY HASH(a) BUCKETS 1
+        PROPERTIES (
+        "replication_allocation" = "tag.location.default: 1",
+        "in_memory" = "false",
+        "storage_format" = "V2"
+        );
+    """
+
+    sql """
+        create table outerjoin_B ( a int not null )
+        ENGINE=OLAP
+        DISTRIBUTED BY HASH(a) BUCKETS 1
+        PROPERTIES (
+        "replication_allocation" = "tag.location.default: 1",
+        "in_memory" = "false",
+        "storage_format" = "V2"
+        );
+    """
+
+    sql """
+        create table outerjoin_C ( a int not null )
+        ENGINE=OLAP
+        DISTRIBUTED BY HASH(a) BUCKETS 1
+        PROPERTIES (
+        "replication_allocation" = "tag.location.default: 1",
+        "in_memory" = "false",
+        "storage_format" = "V2"
+        );
+    """
+
+    sql """
+        insert into outerjoin_A values( 1 );
+    """
+
+    sql """
+        insert into outerjoin_B values( 1 );
+    """
+
+    sql """
+        insert into outerjoin_C values( 1 );
+    """
+
+    qt_select """
+        select  
+        bitand(
+        outerjoin_A.`a` ,
+        outerjoin_A.`a` ) as c0
+        from 
+            outerjoin_A
+
+            inner join (select  
+                outerjoin_B.a as c3
+                from 
+                outerjoin_B
+                    ) as subq_0
+            on (outerjoin_A.a = subq_0.c3 )
+            right join outerjoin_C as ref_83
+            on (subq_0.c3 = ref_83.a )
+        order by subq_0.`c3`;
+    """
+
+    sql """
+        drop table if exists outerjoin_A;
+    """
+
+    sql """
+        drop table if exists outerjoin_B;
+    """
+
+    sql """
+        drop table if exists outerjoin_C;
+    """
+}


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

Reply via email to