Skip to content

Conversation

@smiklos
Copy link
Contributor

@smiklos smiklos commented Aug 10, 2023

Which issue does this PR close?

Closes #7241.

Rationale for this change

It is possible to select no columns at all when using exclude. In such cases the push_down_projection rule will alter the schema which will then blow up in the optimizer as rules are not suppose to change the plan's schema.

I can't tell if empty selection is even legit..

What changes are included in this PR?

Both empty projection and empty projection with filter has been tweaked to do not alter the original schema.

Are these changes tested?

Yeah

Are there any user-facing changes?

No

No

No

@github-actions github-actions bot added the optimizer Optimizer rules label Aug 10, 2023
.insert(scan.projected_schema.fields()[0].qualified_column());
push_down_scan(&used_columns, scan, true)?
let new_scan = push_down_scan(&used_columns, scan, true)?;
plan.with_new_inputs(&[new_scan])?
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This call feels like it was just left out accidentally

let new_filter = child_plan.with_new_inputs(&[new_projection])?;

generate_plan!(projection_is_empty, plan, new_filter)
plan.with_new_inputs(&[new_filter])?
Copy link
Contributor Author

@smiklos smiklos Aug 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in this branch projection_is_empty is false so new_filter was returned as is. However that means it becomes a filter plan with a different schema. so this way we keep the original plan and change its inputs

assert_schema_is_the_same(rule.name(), &new_plan, &plan)?;
new_plan = plan;
Ok(Some(optimized_plan)) => {
assert_schema_is_the_same(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this assertion should be chained with result first such that the error handling below can kick in and rules that change the schema can also be skipped if needed.

@smiklos smiklos marked this pull request as draft August 10, 2023 12:35
@smiklos smiklos force-pushed the no-selection-pushdown-fixes branch from a4c616a to 43cb264 Compare August 10, 2023 15:08
@smiklos smiklos closed this Aug 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

optimizer Optimizer rules

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Optimizer push_down_projection failed due to different schemas

1 participant