Skip to content

Commit

Permalink
[fix](planner)need call materializeSrcExpr for materialized slots in …
Browse files Browse the repository at this point in the history
…join node (#25204) (#31016)

bp #25204
Co-authored-by: starocean999 <[email protected]>
  • Loading branch information
morningman authored Feb 9, 2024
1 parent cf45f08 commit 07d30d4
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ public SlotDescriptor(SlotId id, TupleDescriptor parent, SlotDescriptor src) {
this.isAgg = false;
this.stats = src.stats;
this.type = src.type;
this.sourceExprs.add(new SlotRef(src));
}

public boolean isMultiRef() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,6 @@ protected void computeOutputTuple(Analyzer analyzer) throws UserException {
boolean needSetToNullable =
getChild(0) instanceof JoinNodeBase && analyzer.isOuterJoined(leftTupleDesc.getId());
for (SlotDescriptor leftSlotDesc : leftTupleDesc.getSlots()) {
if (!isMaterializedByChild(leftSlotDesc, getChild(0).getOutputSmap())) {
continue;
}
SlotDescriptor outputSlotDesc =
analyzer.getDescTbl().copySlotDescriptor(vOutputTupleDesc, leftSlotDesc);
if (leftNullable) {
Expand All @@ -191,9 +188,6 @@ protected void computeOutputTuple(Analyzer analyzer) throws UserException {
boolean needSetToNullable =
getChild(1) instanceof JoinNodeBase && analyzer.isOuterJoined(rightTupleDesc.getId());
for (SlotDescriptor rightSlotDesc : rightTupleDesc.getSlots()) {
if (!isMaterializedByChild(rightSlotDesc, getChild(1).getOutputSmap())) {
continue;
}
SlotDescriptor outputSlotDesc =
analyzer.getDescTbl().copySlotDescriptor(vOutputTupleDesc, rightSlotDesc);
if (rightNullable) {
Expand Down Expand Up @@ -226,6 +220,7 @@ protected void computeOutputTuple(Analyzer analyzer) throws UserException {
rSlotRef.getDesc().setIsMaterialized(lSlotRef.getDesc().isMaterialized());
} else {
rSlotRef.getDesc().setIsMaterialized(true);
rSlotRef.materializeSrcExpr();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,7 @@ public void testJoinPredicateTransitivity() throws Exception {
+ "left join join2 on join1.id = join2.id\n"
+ "and join1.id > 1;";
String explainString = getSQLPlanOrErrorMsg("explain " + sql);
Assert.assertTrue(explainString.contains("other join predicates: <slot 12> > 1"));
Assert.assertTrue(explainString.contains("other join predicates: <slot 12> <slot 0> > 1"));
Assert.assertFalse(explainString.contains("PREDICATES: `join1`.`id` > 1"));

/*
Expand Down Expand Up @@ -833,7 +833,7 @@ public void testJoinPredicateTransitivity() throws Exception {
+ "left anti join join2 on join1.id = join2.id\n"
+ "and join1.id > 1;";
explainString = getSQLPlanOrErrorMsg("explain " + sql);
Assert.assertTrue(explainString.contains("other join predicates: <slot 7> > 1"));
Assert.assertTrue(explainString.contains("other join predicates: <slot 7> <slot 0> > 1"));
Assert.assertFalse(explainString.contains("PREDICATES: `join1`.`id` > 1"));

// test semi join, left table join predicate, only push to left table
Expand Down Expand Up @@ -1523,7 +1523,6 @@ public void testRuntimeFilterType() throws Exception {
public void testEmptyNode() throws Exception {
connectContext.setDatabase("default_cluster:test");
String emptyNode = "EMPTYSET";
String denseRank = "dense_rank";

List<String> sqls = Lists.newArrayList();
sqls.add("explain select * from baseall limit 0");
Expand All @@ -1542,7 +1541,6 @@ public void testEmptyNode() throws Exception {
for (String sql : sqls) {
String explainString = getSQLPlanOrErrorMsg(sql);
Assert.assertTrue(explainString.contains(emptyNode));
Assert.assertFalse(explainString.contains(denseRank));
}
}

Expand Down Expand Up @@ -2056,7 +2054,7 @@ public void testResultExprs() throws Exception {
Assert.assertFalse(explainString.contains("OUTPUT EXPRS:\n 3\n 4"));
System.out.println(explainString);
Assert.assertTrue(explainString.contains(
"OUTPUT EXPRS:\n" + " CAST(<slot 4> AS INT)\n" + " CAST(<slot 5> AS INT)"));
"OUTPUT EXPRS:\n" + " CAST(<slot 4> <slot 2> 3 AS INT)\n" + " CAST(<slot 5> <slot 3> 4 AS INT)"));
}

@Test
Expand Down

0 comments on commit 07d30d4

Please sign in to comment.