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 23d673a178 [fix](vectorized) Fix bug of outer join with delete column 
(#9315)
23d673a178 is described below

commit 23d673a178696272ffbfa9fad3573e3ab2524c9c
Author: HappenLee <happen...@hotmail.com>
AuthorDate: Thu May 5 09:42:48 2022 +0800

    [fix](vectorized) Fix bug of outer join with delete column (#9315)
---
 .../java/org/apache/doris/analysis/Analyzer.java   |  4 +++
 .../org/apache/doris/planner/OlapScanNode.java     |  1 +
 .../sql/test_outer_join_with_delete_column.out     | 33 ++++++++++++++++++++++
 regression-test/suites/query/join/ddl/table_1.sql  | 12 ++++++++
 regression-test/suites/query/join/ddl/table_2.sql  | 12 ++++++++
 regression-test/suites/query/join/load.groovy      |  5 +++-
 .../sql/test_outer_join_with_delete_column.sql     | 17 +++++++++++
 7 files changed, 83 insertions(+), 1 deletion(-)

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 c296fba022..101b6fe636 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
@@ -1381,6 +1381,10 @@ public class Analyzer {
         return globalState.fullOuterJoinedTupleIds.containsKey(tid);
     }
 
+    public boolean isOuterMaterializedJoined(TupleId tid) {
+        return globalState.outerJoinedMaterializedTupleIds.contains(tid);
+    }
+
     public boolean isFullOuterJoined(SlotId sid) {
         return isFullOuterJoined(getTupleId(sid));
     }
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/planner/OlapScanNode.java 
b/fe/fe-core/src/main/java/org/apache/doris/planner/OlapScanNode.java
index 6a1fc49b03..eacb4f7a37 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/planner/OlapScanNode.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/planner/OlapScanNode.java
@@ -904,6 +904,7 @@ public class OlapScanNode extends ScanNode {
             SlotRef deleteSignSlot = new SlotRef(desc.getAliasAsName(), 
Column.DELETE_SIGN);
             deleteSignSlot.analyze(analyzer);
             deleteSignSlot.getDesc().setIsMaterialized(true);
+            
deleteSignSlot.getDesc().setIsNullable(analyzer.isOuterMaterializedJoined(desc.getId()));
             Expr conjunct = new BinaryPredicate(BinaryPredicate.Operator.EQ, 
deleteSignSlot, new IntLiteral(0));
             conjunct.analyze(analyzer);
             conjuncts.add(conjunct);
diff --git 
a/regression-test/data/query/join/sql/test_outer_join_with_delete_column.out 
b/regression-test/data/query/join/sql/test_outer_join_with_delete_column.out
new file mode 100644
index 0000000000..e73b7ed352
--- /dev/null
+++ b/regression-test/data/query/join/sql/test_outer_join_with_delete_column.out
@@ -0,0 +1,33 @@
+-- This file is automatically generated. You should know what you did if you 
want to edit this
+-- !test_outer_join_with_delete_column --
+\N     \N      H220427011909770192580  2022-04-27T16:00:04
+\N     \N      H220427011909800104411  2022-04-27T16:00:14
+\N     \N      H220427011909820192943  2022-04-27T16:00:23
+\N     \N      H220427011909850160918  2022-04-27T16:00:33
+\N     \N      H220427011909870184823  2022-04-27T16:00:36
+\N     \N      T220427400109110184990  2022-04-27T16:00:29
+\N     \N      T220427400109910160949  2022-04-27T16:00:54
+\N     \N      T220427400109930192249  2022-04-27T16:00:56
+\N     \N      T220427400115770144416  2022-04-27T16:00:12
+\N     \N      T220427400123050168464  2022-04-27T16:00:37
+\N     \N      T220427400123770120058  2022-04-27T16:00:56
+\N     \N      T220427400124330112931  2022-04-27T16:00:56
+\N     \N      T220427400124430144718  2022-04-27T16:00:07
+\N     \N      T220427400126390112736  2022-04-27T16:00:19
+\N     \N      T220427400126530112854  2022-04-27T16:00:34
+\N     \N      T220427400127160144672  2022-04-27T16:00:10
+\N     \N      T220427400127900184511  2022-04-27T16:00:34
+\N     \N      T220427400128350120717  2022-04-27T16:00:56
+\N     \N      T220427400129680120838  2022-04-27T16:00:39
+\N     \N      T220427400129940120380  2022-04-27T16:00:23
+\N     \N      T220427400130570160488  2022-04-27T16:00:34
+\N     \N      T220427400130610112671  2022-04-27T16:00:30
+\N     \N      T220427400136970192083  2022-04-27T16:00:51
+\N     \N      T220427400137600160704  2022-04-27T16:00:35
+\N     \N      T220427400139720192986  2022-04-27T16:00:34
+\N     \N      T220427400140260152375  2022-04-27T16:00:02
+\N     \N      T220427400144590176969  2022-04-27T16:00:49
+\N     \N      T220427400146320176530  2022-04-27T16:00:34
+\N     \N      T220427400153170104281  2022-04-27T16:00:31
+\N     \N      T220427601780480120027  2022-04-27T16:00:58
+
diff --git a/regression-test/suites/query/join/ddl/table_1.sql 
b/regression-test/suites/query/join/ddl/table_1.sql
new file mode 100644
index 0000000000..9378994e3c
--- /dev/null
+++ b/regression-test/suites/query/join/ddl/table_1.sql
@@ -0,0 +1,12 @@
+CREATE TABLE `table_1` (
+  `abcd` varchar(150) NULL COMMENT "",
+  `create_time` datetime NULL COMMENT ""
+) ENGINE=OLAP
+UNIQUE KEY(`abcd`)
+COMMENT "OLAP"
+DISTRIBUTED BY HASH(`abcd`) BUCKETS 3
+  PROPERTIES (
+  "replication_allocation" = "tag.location.default: 1",
+  "in_memory" = "false",
+  "storage_format" = "V2"
+)
diff --git a/regression-test/suites/query/join/ddl/table_2.sql 
b/regression-test/suites/query/join/ddl/table_2.sql
new file mode 100644
index 0000000000..31cbf5b906
--- /dev/null
+++ b/regression-test/suites/query/join/ddl/table_2.sql
@@ -0,0 +1,12 @@
+CREATE TABLE `table_2` (
+  `abcd` varchar(150) NULL COMMENT "",
+  `create_time` datetime NULL COMMENT ""
+) ENGINE=OLAP
+UNIQUE KEY(`abcd`)
+COMMENT "OLAP"
+DISTRIBUTED BY HASH(`abcd`) BUCKETS 3
+  PROPERTIES (
+  "replication_allocation" = "tag.location.default: 1",
+  "in_memory" = "false",
+  "storage_format" = "V2"
+)
diff --git a/regression-test/suites/query/join/load.groovy 
b/regression-test/suites/query/join/load.groovy
index 60c429b068..aa3a5402f2 100644
--- a/regression-test/suites/query/join/load.groovy
+++ b/regression-test/suites/query/join/load.groovy
@@ -20,7 +20,7 @@
 // and modified by Doris.
 
 suite("load") {
-    def tables=["test_join", "test_bucket_shuffle_join"]
+    def tables=["test_join", "test_bucket_shuffle_join", "table_1", "table_2"]
 
     for (String table in tables) {
         sql """ DROP TABLE IF EXISTS $table """
@@ -31,8 +31,11 @@ suite("load") {
     }
 
     sql """ insert into test_join values(1),(2),(3),(4),(5) """
+
     sql """ ALTER TABLE test_bucket_shuffle_join ADD PARTITION p202112 
             VALUES LESS THAN ("2022-01-01 00:00:00") DISTRIBUTED BY HASH(id) 
BUCKETS 2;"""
     sql """ insert into test_bucket_shuffle_join values(1, "2021-12-01 
00:00:00"),
         (2, "2021-12-01 00:00:00"), (3, "2021-12-01 00:00:00")"""
+
+    sql """ INSERT INTO table_2 VALUES ('H220427011909850160918','2022-04-27 
16:00:33'),('T220427400109910160949','2022-04-27 
16:00:54'),('T220427400123770120058','2022-04-27 
16:00:56'),('T220427400126530112854','2022-04-27 
16:00:34'),('T220427400127160144672','2022-04-27 
16:00:10'),('T220427400127900184511','2022-04-27 
16:00:34'),('T220427400129940120380','2022-04-27 
16:00:23'),('T220427400139720192986','2022-04-27 
16:00:34'),('T220427400140260152375','2022-04-27 16:00:02'),('T220427400 [...]
 }
diff --git 
a/regression-test/suites/query/join/sql/test_outer_join_with_delete_column.sql 
b/regression-test/suites/query/join/sql/test_outer_join_with_delete_column.sql
new file mode 100644
index 0000000000..8b07a72f3c
--- /dev/null
+++ 
b/regression-test/suites/query/join/sql/test_outer_join_with_delete_column.sql
@@ -0,0 +1,17 @@
+SELECT
+*
+FROM
+(
+SELECT
+table_1.abcd AS exist_key,
+table_1.create_time AS business_time
+FROM
+table_1
+) source
+RIGHT JOIN (
+SELECT
+table_2.abcd AS exist_key,
+table_2.create_time AS business_time
+FROM
+table_2
+) target ON source.exist_key = target.exist_key order by target.exist_key;


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

Reply via email to