You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by mo...@apache.org on 2020/11/22 12:58:14 UTC

[incubator-doris] branch master updated: [Bug] Fix the bug of NULL do not show in CTE statement. (#4932)

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

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


The following commit(s) were added to refs/heads/master by this push:
     new 584b33f  [Bug] Fix the bug of NULL do not show in CTE statement. (#4932)
584b33f is described below

commit 584b33f95b047533fb95d9224c7d6af6e03da694
Author: HappenLee <ha...@hotmail.com>
AuthorDate: Sun Nov 22 20:58:03 2020 +0800

    [Bug] Fix the bug of NULL do not show in CTE statement. (#4932)
    
    All Column create in inlineView will set `allowNull = false`, which will cause `NULL` data in CTE be process will be ignore.
    So we should set column in inlineView allowNull to make sure correct of query.
---
 .../java/org/apache/doris/analysis/InlineViewRef.java     |  4 +++-
 .../test/java/org/apache/doris/planner/PlannerTest.java   | 15 +++++++++++++++
 2 files changed, 18 insertions(+), 1 deletion(-)

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 d2a947e..4e3cb88 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
@@ -266,7 +266,9 @@ public class InlineViewRef extends TableRef {
             }
 
             columnSet.add(colAlias);
-            columnList.add(new Column(colAlias, selectItemExpr.getType().getPrimitiveType()));
+            // TODO: inlineView threat all column is nullable to make sure query results are correct
+            // we should judge column whether is nullable by selectItemExpr in the future
+            columnList.add(new Column(colAlias, selectItemExpr.getType().getPrimitiveType(), true));
         }
         InlineView inlineView = (view != null) ? new InlineView(view, columnList) : new InlineView(getExplicitAlias(), columnList);
 
diff --git a/fe/fe-core/src/test/java/org/apache/doris/planner/PlannerTest.java b/fe/fe-core/src/test/java/org/apache/doris/planner/PlannerTest.java
index 900f735..3fc7f8c 100644
--- a/fe/fe-core/src/test/java/org/apache/doris/planner/PlannerTest.java
+++ b/fe/fe-core/src/test/java/org/apache/doris/planner/PlannerTest.java
@@ -309,4 +309,19 @@ public class PlannerTest {
 
     }
 
+    @Test
+    public void testWithStmtSoltIsAllowNull() throws Exception {
+        // union
+        String sql1 = "with a as (select NULL as user_id ), " +
+                "b as ( select '543' as user_id) " +
+                "select user_id from a union all select user_id from b";
+
+        StmtExecutor stmtExecutor1 = new StmtExecutor(ctx, sql1);
+        stmtExecutor1.execute();
+        Planner planner1 = stmtExecutor1.planner();
+        List<PlanFragment> fragments1 = planner1.getFragments();
+        String plan1 = planner1.getExplainString(fragments1, TExplainLevel.VERBOSE);
+        Assert.assertEquals(3, StringUtils.countMatches(plan1, "nullIndicatorBit=0"));
+    }
+
 }


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