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

kxiao pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git

commit f03ccd0b0536904cfb8da4309b6fad7e9b9bdeb1
Author: morrySnow <[email protected]>
AuthorDate: Tue Jul 18 18:22:40 2023 +0800

    [fix](Nereids) join other conjuncts should get slot from join output 
(#21840)
---
 .../nereids/rules/rewrite/AdjustNullable.java      |  3 +
 .../join/test_other_conjuncts_nullable.groovy      | 64 ++++++++++++++++++++++
 2 files changed, 67 insertions(+)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/AdjustNullable.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/AdjustNullable.java
index 67dc893dfd..d708d6226c 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/AdjustNullable.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/AdjustNullable.java
@@ -102,6 +102,9 @@ public class AdjustNullable extends 
DefaultPlanRewriter<Void> implements CustomR
         join = (LogicalJoin<? extends Plan, ? extends Plan>) super.visit(join, 
context);
         Map<ExprId, Slot> exprIdSlotMap = collectChildrenOutputMap(join);
         List<Expression> hashConjuncts = 
updateExpressions(join.getHashJoinConjuncts(), exprIdSlotMap);
+        // because other join compute on join's output on be, so we need to 
change slot to join's output
+        exprIdSlotMap = join.getOutputSet().stream()
+                .collect(Collectors.toMap(NamedExpression::getExprId, s -> s));
         List<Expression> otherConjuncts = 
updateExpressions(join.getOtherJoinConjuncts(), exprIdSlotMap);
         return join.withJoinConjuncts(hashConjuncts, 
otherConjuncts).recomputeLogicalProperties();
     }
diff --git 
a/regression-test/suites/nereids_p0/join/test_other_conjuncts_nullable.groovy 
b/regression-test/suites/nereids_p0/join/test_other_conjuncts_nullable.groovy
new file mode 100644
index 0000000000..66587972eb
--- /dev/null
+++ 
b/regression-test/suites/nereids_p0/join/test_other_conjuncts_nullable.groovy
@@ -0,0 +1,64 @@
+// 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_other_conjuncts_nullable") {
+    sql "SET enable_nereids_planner=true"
+    sql "SET enable_fallback_to_original_planner=false"
+
+    sql """DROP TABLE IF EXISTS other_conjuncts_t0"""
+    sql """DROP TABLE IF EXISTS other_conjuncts_t1"""
+
+    sql """ CREATE TABLE other_conjuncts_t0(c0 CHAR(94)) DISTRIBUTED BY HASH 
(c0) PROPERTIES ("replication_num" = "1");"""
+    sql """ CREATE TABLE other_conjuncts_t1(c1 CHAR(94) NOT NULL) DUPLICATE 
KEY(c1) DISTRIBUTED BY RANDOM BUCKETS 16 PROPERTIES ("replication_num" = 
"1");"""
+    sql """ INSERT INTO other_conjuncts_t0 (c0) VALUES ('ACBy');"""
+    sql """ INSERT INTO other_conjuncts_t1 (c1) VALUES ('QMOpD贷_Td');"""
+    sql """ INSERT INTO other_conjuncts_t0 (c0) VALUES ('贷\');"""
+    sql """ INSERT INTO other_conjuncts_t1 (c1) VALUES ('aWZ*'), 
('1d!贷*u{ye'), ('c');"""
+    sql """ INSERT INTO other_conjuncts_t1 (c1) VALUES ('\\'K\\r');"""
+    sql """ INSERT INTO other_conjuncts_t0 (c0) VALUES ('C7t2u!4');"""
+    sql """ INSERT INTO other_conjuncts_t0 (c0) VALUES ('k_䳜doj>.W');"""
+    sql """ INSERT INTO other_conjuncts_t0 (c0) VALUES ('KX');"""
+    sql """ INSERT INTO other_conjuncts_t0 (c0) VALUES ('YA');"""
+    sql """ INSERT INTO other_conjuncts_t0 (c0) VALUES ('k_䳜doj>.W');"""
+    sql """ INSERT INTO other_conjuncts_t0 (c0) VALUES ('');"""
+    sql """ INSERT INTO other_conjuncts_t1 (c1) VALUES ('');"""
+    sql """ INSERT INTO other_conjuncts_t1 (c1) VALUES ('');"""
+    sql """ INSERT INTO other_conjuncts_t1 (c1) VALUES ('-1096708809');"""
+    sql """ INSERT INTO other_conjuncts_t1 (c1) VALUES ('');"""
+    sql """ INSERT INTO other_conjuncts_t0 (c0) VALUES ('4,szzM䳜wz'), (''), 
('uU\nXtdP+V');"""
+    sql """ INSERT INTO other_conjuncts_t0 (c0) VALUES ('隺E');"""
+    sql """ INSERT INTO other_conjuncts_t0 (c0) VALUES ('');"""
+    sql """ INSERT INTO other_conjuncts_t1 (c1) VALUES ('');"""
+
+    sql """sync"""
+
+    sql """
+        SELECT
+            1
+        FROM
+            other_conjuncts_t0
+            LEFT OUTER JOIN other_conjuncts_t1 ON (
+                true NOT IN (
+                    true,
+                    CASE
+                        ((other_conjuncts_t0.c0) LIKE ('12235502'))
+                        WHEN (NOT false) THEN ((other_conjuncts_t1.c1) like 
(''))
+                    END
+                )
+            );
+    """
+}


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

Reply via email to