Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Evaluate cheaper condition first in join selection and physical planner #13435

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
4 changes: 2 additions & 2 deletions datafusion/core/src/physical_planner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -656,8 +656,8 @@ impl DefaultPhysicalPlanner {
let logical_input_schema = input.as_ref().schema();
let physical_input_schema_from_logical = logical_input_schema.inner();

if &physical_input_schema != physical_input_schema_from_logical
&& !options.execution.skip_physical_aggregate_schema_check
if !options.execution.skip_physical_aggregate_schema_check
&& &physical_input_schema != physical_input_schema_from_logical
{
return internal_err!("Physical input schema should be the same as the one converted from logical input schema.");
}
Expand Down