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 f949262ddf [fix](planner) a slot id is bounded on a wrong tuple id, if
cross join has a hash join as child (#12156)
f949262ddf is described below
commit f949262ddf985ccc5e6ac0d0b2fa22bd8608f325
Author: minghong <[email protected]>
AuthorDate: Wed Aug 31 09:07:55 2022 +0800
[fix](planner) a slot id is bounded on a wrong tuple id, if cross join has
a hash join as child (#12156)
---
.../org/apache/doris/planner/HashJoinNode.java | 10 ++--
.../correctness/test_crossjoin_inlineview_slot.out | 4 ++
.../test_crossjoin_inlineview_slot.groovy | 55 ++++++++++++++++++++++
3 files changed, 66 insertions(+), 3 deletions(-)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/planner/HashJoinNode.java
b/fe/fe-core/src/main/java/org/apache/doris/planner/HashJoinNode.java
index 46e35775da..a319ef9534 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/planner/HashJoinNode.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/planner/HashJoinNode.java
@@ -452,7 +452,10 @@ public class HashJoinNode extends PlanNode {
int leftNullableNumber = 0;
int rightNullableNumber = 0;
if (copyLeft) {
- for (TupleDescriptor leftTupleDesc :
analyzer.getDescTbl().getTupleDesc(getChild(0).getOutputTblRefIds())) {
+ //cross join do not have OutputTblRefIds
+ List<TupleId> srcTupleIds = getChild(0) instanceof CrossJoinNode ?
getChild(0).getOutputTupleIds()
+ : getChild(0).getOutputTblRefIds();
+ for (TupleDescriptor leftTupleDesc :
analyzer.getDescTbl().getTupleDesc(srcTupleIds)) {
// if the child is cross join node, the only way to get the
correct nullable info of its output slots
// is to check if the output tuple ids are outer joined or not.
// then pass this nullable info to hash join node will be
correct.
@@ -476,8 +479,9 @@ public class HashJoinNode extends PlanNode {
}
}
if (copyRight) {
- for (TupleDescriptor rightTupleDesc : analyzer.getDescTbl()
- .getTupleDesc(getChild(1).getOutputTblRefIds())) {
+ List<TupleId> srcTupleIds = getChild(1) instanceof CrossJoinNode ?
getChild(1).getOutputTupleIds()
+ : getChild(1).getOutputTblRefIds();
+ for (TupleDescriptor rightTupleDesc :
analyzer.getDescTbl().getTupleDesc(srcTupleIds)) {
boolean needSetToNullable =
getChild(1) instanceof CrossJoinNode &&
analyzer.isOuterJoined(rightTupleDesc.getId());
for (SlotDescriptor rightSlotDesc : rightTupleDesc.getSlots())
{
diff --git
a/regression-test/data/correctness/test_crossjoin_inlineview_slot.out
b/regression-test/data/correctness/test_crossjoin_inlineview_slot.out
new file mode 100644
index 0000000000..095c7b2035
--- /dev/null
+++ b/regression-test/data/correctness/test_crossjoin_inlineview_slot.out
@@ -0,0 +1,4 @@
+-- This file is automatically generated. You should know what you did if you
want to edit this
+-- !sql --
+1
+
diff --git
a/regression-test/suites/correctness/test_crossjoin_inlineview_slot.groovy
b/regression-test/suites/correctness/test_crossjoin_inlineview_slot.groovy
new file mode 100644
index 0000000000..dff80009e2
--- /dev/null
+++ b/regression-test/suites/correctness/test_crossjoin_inlineview_slot.groovy
@@ -0,0 +1,55 @@
+// 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_crossjoin_inlineview_slot") {
+ sql "DROP TABLE IF EXISTS t0;"
+ sql "DROP TABLE IF EXISTS t1;"
+ sql "DROP TABLE IF EXISTS t2;"
+ sql "DROP TABLE IF EXISTS t3;"
+ sql "DROP TABLE IF EXISTS t4;"
+
+ sql """create table t0 (id0 int) engine=olap distributed by hash(id0)
buckets 1 properties("replication_num"="1");"""
+ sql """create table t1 (id1 int) engine=olap distributed by hash(id1)
buckets 1 properties("replication_num"="1");"""
+ sql """create table t2 (id2 tinyint(4), status tinyint(4)) engine=olap
distributed by hash(id2) buckets 1 properties("replication_num"="1");"""
+ sql """create table t3 (id3 int) engine=olap distributed by hash(id3)
buckets 1 properties("replication_num"="1");"""
+ sql """create table t4 (id4 int) engine=olap distributed by hash(id4)
buckets 1 properties("replication_num"="1");"""
+
+ sql "insert into t0 values (1);"
+ sql "insert into t1 values (1);"
+ sql "insert into t2 values (1, 1);"
+ sql "insert into t3 values (1);"
+ sql "insert into t4 values (1);"
+
+ qt_sql """
+ select id0
+ from t0
+ where
+ EXISTS (
+ select
+ id4
+ from t4 right join t1
+ on id4 = id1
+ where
+ EXISTS (
+ select
+ status
+ from t2 join t3
+ on (id2 = id3 )
+ )
+ )
+ """
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]