Skip to content

Commit

Permalink
Evaluate cheaper condition first in join selection
Browse files Browse the repository at this point in the history
  • Loading branch information
findepi committed Nov 14, 2024
1 parent 57235c2 commit 43b460f
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions datafusion/core/src/physical_optimizer/join_selection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -382,8 +382,8 @@ fn try_collect_left(

match (left_can_collect, right_can_collect) {
(true, true) => {
if should_swap_join_order(&**left, &**right)?
&& supports_swap(*hash_join.join_type())
if supports_swap(*hash_join.join_type())
&& should_swap_join_order(&**left, &**right)?
{
Ok(Some(swap_hash_join(hash_join, PartitionMode::CollectLeft)?))
} else {
Expand Down Expand Up @@ -423,7 +423,7 @@ fn try_collect_left(
fn partitioned_hash_join(hash_join: &HashJoinExec) -> Result<Arc<dyn ExecutionPlan>> {
let left = hash_join.left();
let right = hash_join.right();
if should_swap_join_order(&**left, &**right)? && supports_swap(*hash_join.join_type())
if supports_swap(*hash_join.join_type()) && should_swap_join_order(&**left, &**right)?
{
swap_hash_join(hash_join, PartitionMode::Partitioned)
} else {
Expand Down Expand Up @@ -468,8 +468,8 @@ fn statistical_join_selection_subrule(
PartitionMode::Partitioned => {
let left = hash_join.left();
let right = hash_join.right();
if should_swap_join_order(&**left, &**right)?
&& supports_swap(*hash_join.join_type())
if supports_swap(*hash_join.join_type())
&& should_swap_join_order(&**left, &**right)?
{
swap_hash_join(hash_join, PartitionMode::Partitioned).map(Some)?
} else {
Expand Down

0 comments on commit 43b460f

Please sign in to comment.