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 4f27692898 [fix](inlineview)the inlineview's slots' nullability 
property is not set correctly (#12681)
4f27692898 is described below

commit 4f2769289892b43de3cadbf30177a04b163166ba
Author: starocean999 <40539150+starocean...@users.noreply.github.com>
AuthorDate: Tue Sep 20 09:29:15 2022 +0800

    [fix](inlineview)the inlineview's slots' nullability property is not set 
correctly (#12681)
    
    The output slots of inline view may come from an outer join nullable side 
table. So it's should be nullable.
---
 .../org/apache/doris/analysis/InlineViewRef.java   |  3 ++
 .../test_outer_join_with_order_by.out              |  3 ++
 .../test_outer_join_with_order_by.groovy           | 42 ++++++++++++++++++++++
 3 files changed, 48 insertions(+)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/analysis/InlineViewRef.java 
b/fe/fe-core/src/main/java/org/apache/doris/analysis/InlineViewRef.java
index 2fcf3681f8..8adc8047f0 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/InlineViewRef.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/InlineViewRef.java
@@ -218,11 +218,13 @@ public class InlineViewRef extends TableRef {
         // would alter the results of the analytic functions (see IMPALA-1243)
         // TODO: relax this a bit by allowing propagation out of the inline 
view (but
         // not into it)
+        List<SlotDescriptor> slots = 
analyzer.changeSlotToNullableOfOuterJoinedTuples();
         for (int i = 0; i < getColLabels().size(); ++i) {
             String colName = getColLabels().get(i);
             SlotDescriptor slotDesc = 
analyzer.registerColumnRef(getAliasAsName(), colName);
             Expr colExpr = queryStmt.getResultExprs().get(i);
             slotDesc.setSourceExpr(colExpr);
+            slotDesc.setIsNullable(slotDesc.getIsNullable() || 
colExpr.isNullable());
             SlotRef slotRef = new SlotRef(slotDesc);
             sMap.put(slotRef, colExpr);
             baseTblSmap.put(slotRef, queryStmt.getBaseTblResultExprs().get(i));
@@ -230,6 +232,7 @@ public class InlineViewRef extends TableRef {
                 analyzer.createAuxEquivPredicate(new SlotRef(slotDesc), 
colExpr.clone());
             }
         }
+        analyzer.changeSlotsToNotNullable(slots);
         if (LOG.isDebugEnabled()) {
             LOG.debug("inline view " + getUniqueAlias() + " smap: " + 
sMap.debugString());
             LOG.debug("inline view " + getUniqueAlias() + " baseTblSmap: " + 
baseTblSmap.debugString());
diff --git 
a/regression-test/data/correctness_p0/test_outer_join_with_order_by.out 
b/regression-test/data/correctness_p0/test_outer_join_with_order_by.out
index 72d126351a..875d88ccc5 100644
--- a/regression-test/data/correctness_p0/test_outer_join_with_order_by.out
+++ b/regression-test/data/correctness_p0/test_outer_join_with_order_by.out
@@ -2,3 +2,6 @@
 -- !select --
 1
 
+-- !select --
+1
+
diff --git 
a/regression-test/suites/correctness_p0/test_outer_join_with_order_by.groovy 
b/regression-test/suites/correctness_p0/test_outer_join_with_order_by.groovy
index ae250e8d20..312529afcd 100644
--- a/regression-test/suites/correctness_p0/test_outer_join_with_order_by.groovy
+++ b/regression-test/suites/correctness_p0/test_outer_join_with_order_by.groovy
@@ -24,6 +24,10 @@ suite("test_outer_join_with_order_by") {
         drop table if exists outerjoin_B;
     """
 
+    sql """
+        drop table if exists outerjoin_C;
+    """
+
     sql """
         create table outerjoin_A ( a int not null )
         ENGINE=OLAP
@@ -46,6 +50,17 @@ suite("test_outer_join_with_order_by") {
         );
     """
 
+    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 );
     """
@@ -54,11 +69,34 @@ suite("test_outer_join_with_order_by") {
         insert into outerjoin_B values( 1 );
     """
 
+    sql """
+        insert into outerjoin_C values( 1 );
+    """
+
     qt_select """
         select case when outerjoin_A.a <= outerjoin_A.a then outerjoin_A.a 
else outerjoin_A.a end as r
         from outerjoin_A right join outerjoin_B on outerjoin_A.a = 
outerjoin_B.a order by outerjoin_A.a;
     """
 
+    qt_select """
+        select
+        case
+            when subq_10.`c9` is not NULL then subq_10.`c9`
+            else subq_10.`c9`
+        end as c3
+        from
+        (
+            select
+            ref_420.a as c9
+            from
+            outerjoin_A as ref_420 
+            right join outerjoin_B as ref_421 on (ref_420.a = ref_421.a)
+        ) as subq_10
+        left join outerjoin_C as ref_687 on (subq_10.`c9` = ref_687.a)
+        order by
+        subq_10.`c9` desc;
+    """
+
     sql """
         drop table if exists outerjoin_A;
     """
@@ -66,4 +104,8 @@ suite("test_outer_join_with_order_by") {
     sql """
         drop table if exists outerjoin_B;
     """
+
+    sql """
+        drop table if exists outerjoin_C;
+    """
 }
\ 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