File tree Expand file tree Collapse file tree
datafusion/physical-optimizer/src Expand file tree Collapse file tree Original file line number Diff line number Diff 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 {
You can’t perform that action at this time.
0 commit comments