[fix](planner) bucket shuffle join is not recognized if the first table is a subquery (#16985)

consider sql select *
from
(select * from test_1) a
inner join
(select * from test_2) b
on a.id = b.id
inner join
(select * from test_3) c
on a.id = c.id

Because a.id is from a subquery, to find its source table, need use function getSrcSlotRef().
This commit is contained in:
starocean999
2023-02-22 20:23:00 +08:00
committed by GitHub
parent 7b0fc17c04
commit 7aa063c1f3
2 changed files with 16 additions and 0 deletions

View File

@ -965,6 +965,9 @@ public abstract class PlanNode extends TreeNode<PlanNode> implements PlanStats {
}
public SlotRef findSrcSlotRef(SlotRef slotRef) {
if (slotRef.getSrcSlotRef() != null) {
slotRef = slotRef.getSrcSlotRef();
}
if (slotRef.getTable() instanceof OlapTable) {
return slotRef;
}

View File

@ -78,4 +78,17 @@ suite("test_bucket_shuffle_join") {
contains "4:VHASH JOIN\n | join op: INNER JOIN(BUCKET_SHUFFLE)"
contains "2:VHASH JOIN\n | join op: INNER JOIN(BUCKET_SHUFFLE)"
}
explain {
sql("""select a.id,a.name,b.id,b.name
from (select * from test_colo1) a
inner join
(select * from test_colo2) b
on a.id = b.id and a.name = b.name and a.name = b.name
inner join
(select * from test_colo3) c
on a.id = c.id and a.name = c.name and a.name = c.name""")
contains "4:VHASH JOIN\n | join op: INNER JOIN(BUCKET_SHUFFLE)"
contains "2:VHASH JOIN\n | join op: INNER JOIN(BUCKET_SHUFFLE)"
}
}