You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by ca...@apache.org on 2021/12/06 08:17:25 UTC

[incubator-doris] branch master updated: [fix](select join) Make selected slotRef nullable when slotRef is from nullable tuple in outer join sql block (#7290)

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

caiconghui 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 8660bf6  [fix](select join) Make selected slotRef nullable when slotRef is from nullable tuple in outer join sql block (#7290)
8660bf6 is described below

commit 8660bf69ff9a4ee143f3e621d64f22a4debde1b2
Author: caiconghui <55...@users.noreply.github.com>
AuthorDate: Mon Dec 6 16:17:10 2021 +0800

    [fix](select join) Make selected slotRef nullable when slotRef is from nullable tuple in outer join sql block (#7290)
---
 .../src/main/java/org/apache/doris/analysis/Analyzer.java     |  2 +-
 .../test/java/org/apache/doris/analysis/SelectStmtTest.java   | 11 ++++++++++-
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/Analyzer.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/Analyzer.java
index 9e8f9e6..df0dd87 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/Analyzer.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/Analyzer.java
@@ -660,7 +660,7 @@ public class Analyzer {
         }
         result = globalState.descTbl.addSlotDescriptor(d);
         result.setColumn(col);
-        if (true == col.isAllowNull()) {
+        if (col.isAllowNull() || globalState.outerJoinedTupleIds.containsKey(d.getId())) {
             result.setIsNullable(true);
         } else {
             result.setIsNullable(false);
diff --git a/fe/fe-core/src/test/java/org/apache/doris/analysis/SelectStmtTest.java b/fe/fe-core/src/test/java/org/apache/doris/analysis/SelectStmtTest.java
index 103ab98..9dce62f 100755
--- a/fe/fe-core/src/test/java/org/apache/doris/analysis/SelectStmtTest.java
+++ b/fe/fe-core/src/test/java/org/apache/doris/analysis/SelectStmtTest.java
@@ -111,7 +111,7 @@ public class SelectStmtTest {
         String tbl2 = "CREATE TABLE db1.table2 (\n" +
                 "  `siteid` int(11) NULL DEFAULT \"10\" COMMENT \"\",\n" +
                 "  `citycode` smallint(6) NULL COMMENT \"\",\n" +
-                "  `username` varchar(32) NULL DEFAULT \"\" COMMENT \"\",\n" +
+                "  `username` varchar(32) NOT NULL DEFAULT \"\" COMMENT \"\",\n" +
                 "  `pv` bigint(20) NULL DEFAULT \"0\" COMMENT \"\"\n" +
                 ") ENGINE=OLAP\n" +
                 "UNIQUE KEY(`siteid`, `citycode`, `username`)\n" +
@@ -755,4 +755,13 @@ public class SelectStmtTest {
         Assert.assertTrue(stmt2.toSql().contains("WITH v1 AS (SELECT `t1`.`k1` AS `k1` FROM " +
                 "`default_cluster:db1`.`tbl1` t1),v2 AS (SELECT `t2`.`k1` AS `k1` FROM `default_cluster:db1`.`tbl1` t2)"));
     }
+
+    @Test
+    public void testSelectOuterJoinSql() throws Exception {
+        ConnectContext ctx = UtFrameUtils.createDefaultCtx();
+        String sql1 = "select l.citycode, group_concat(r.username) from db1.table1 l left join db1.table2 r on l.citycode=r.citycode group by l.citycode";
+        SelectStmt stmt1 = (SelectStmt) UtFrameUtils.parseAndAnalyzeStmt(sql1, ctx);
+        Assert.assertTrue(stmt1.getAnalyzer().getSlotDesc(new SlotId(2)).getIsNullable());
+        Assert.assertTrue(stmt1.getAnalyzer().getSlotDescriptor("r.username").getIsNullable());
+    }
 }

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