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 5e0c34b35a [fix](join) should call getOutputTblRefIds to get child's
tuple info (#13227)
5e0c34b35a is described below
commit 5e0c34b35aef97110bc98e73da87a1e3f093d46b
Author: starocean999 <[email protected]>
AuthorDate: Fri Oct 14 09:46:14 2022 +0800
[fix](join) should call getOutputTblRefIds to get child's tuple info
(#13227)
* [fix](join) should call getOutputTblRefIds to get child's tuple info
---
.../org/apache/doris/planner/HashJoinNode.java | 23 +++++++++++++++++++---
.../org/apache/doris/planner/QueryPlanTest.java | 6 +++---
regression-test/data/query/join/test_join3.out | 2 +-
3 files changed, 24 insertions(+), 7 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 ce4a2f4648..470104fe4d 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,15 @@ public class HashJoinNode extends PlanNode {
int leftNullableNumber = 0;
int rightNullableNumber = 0;
if (copyLeft) {
- for (TupleDescriptor leftTupleDesc :
analyzer.getDescTbl().getTupleDesc(getChild(0).getOutputTupleIds())) {
+ //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.
+ boolean needSetToNullable =
+ getChild(0) instanceof CrossJoinNode &&
analyzer.isOuterJoined(leftTupleDesc.getId());
for (SlotDescriptor leftSlotDesc : leftTupleDesc.getSlots()) {
if (!isMaterailizedByChild(leftSlotDesc,
getChild(0).getOutputSmap())) {
continue;
@@ -463,13 +471,19 @@ public class HashJoinNode extends PlanNode {
outputSlotDesc.setIsNullable(true);
leftNullableNumber++;
}
+ if (needSetToNullable) {
+ outputSlotDesc.setIsNullable(true);
+ }
srcTblRefToOutputTupleSmap.put(new SlotRef(leftSlotDesc),
new SlotRef(outputSlotDesc));
}
}
}
if (copyRight) {
- for (TupleDescriptor rightTupleDesc :
-
analyzer.getDescTbl().getTupleDesc(getChild(1).getOutputTupleIds())) {
+ 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())
{
if (!isMaterailizedByChild(rightSlotDesc,
getChild(1).getOutputSmap())) {
continue;
@@ -480,6 +494,9 @@ public class HashJoinNode extends PlanNode {
outputSlotDesc.setIsNullable(true);
rightNullableNumber++;
}
+ if (needSetToNullable) {
+ outputSlotDesc.setIsNullable(true);
+ }
srcTblRefToOutputTupleSmap.put(new SlotRef(rightSlotDesc),
new SlotRef(outputSlotDesc));
}
}
diff --git
a/fe/fe-core/src/test/java/org/apache/doris/planner/QueryPlanTest.java
b/fe/fe-core/src/test/java/org/apache/doris/planner/QueryPlanTest.java
index 31fd25b10f..cd91238dfd 100644
--- a/fe/fe-core/src/test/java/org/apache/doris/planner/QueryPlanTest.java
+++ b/fe/fe-core/src/test/java/org/apache/doris/planner/QueryPlanTest.java
@@ -1651,15 +1651,15 @@ public class QueryPlanTest extends TestWithFeService {
sql = "SELECT a.k1, b.k2 FROM (SELECT k1 from baseall) a LEFT OUTER
JOIN (select k1, 999 as k2 from baseall) b ON (a.k1=b.k1)";
explainString = getSQLPlanOrErrorMsg("EXPLAIN " + sql);
- Assert.assertTrue(explainString.contains("<slot 5>\n" + " 999"));
+ Assert.assertTrue(explainString.contains("<slot 5>\n" + " <slot
7>"));
sql = "SELECT a.k1, b.k2 FROM (SELECT 1 as k1 from baseall) a RIGHT
OUTER JOIN (select k1, 999 as k2 from baseall) b ON (a.k1=b.k1)";
explainString = getSQLPlanOrErrorMsg("EXPLAIN " + sql);
- Assert.assertTrue(explainString.contains("1\n" + " 999"));
+ Assert.assertTrue(explainString.contains("<slot 5>\n" + " <slot
7>"));
sql = "SELECT a.k1, b.k2 FROM (SELECT 1 as k1 from baseall) a FULL
JOIN (select k1, 999 as k2 from baseall) b ON (a.k1=b.k1)";
explainString = getSQLPlanOrErrorMsg("EXPLAIN " + sql);
- Assert.assertTrue(explainString.contains("1\n" + " 999"));
+ Assert.assertTrue(explainString.contains("<slot 5>\n" + " <slot
7>"));
}
@Test
diff --git a/regression-test/data/query/join/test_join3.out
b/regression-test/data/query/join/test_join3.out
index e7a6efa415..3a1541bde9 100644
--- a/regression-test/data/query/join/test_join3.out
+++ b/regression-test/data/query/join/test_join3.out
@@ -24,5 +24,5 @@ ee 42 \N \N
\N \N bb 2
\N \N cc 2
\N \N ee 2
-bb 11 \N 2
+bb 11 \N \N
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]