Skip to content

Commit eea1ff4

Browse files
committed
[HSTACK] - heuristic for "right deep tree" collect left join
1 parent 96c22f9 commit eea1ff4

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

datafusion/physical-optimizer/src/join_selection.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,18 @@ pub(crate) fn try_collect_left(
232232

233233
match (left_can_collect, right_can_collect) {
234234
(true, true) => {
235+
// Simple heuristic that will trigger a swap if the join is on the left,
236+
// to obtain the "right deep tree"
237+
// FIXME: this should rather be fixed by pushing stats through joins as we do for filter
238+
let join_on_left = left.exists(|p| {
239+
Ok(p.as_any()
240+
.downcast_ref::<HashJoinExec>()
241+
.filter(|p| p.mode == PartitionMode::CollectLeft)
242+
.is_some())
243+
});
244+
235245
if hash_join.join_type().supports_swap()
236-
&& should_swap_join_order(&**left, &**right)?
246+
&& (should_swap_join_order(&**left, &**right)? || join_on_left?)
237247
{
238248
Ok(Some(hash_join.swap_inputs(PartitionMode::CollectLeft)?))
239249
} else {

0 commit comments

Comments
 (0)