Skip to content

Preserve projection for inline scan #15811

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

Closed
wants to merge 1 commit into from
Closed

Conversation

vadimpiven
Copy link
Contributor

Which issue does this PR close?

Rationale for this change

PR #15201 introduced a bug here

if table_scan.filters.is_empty() {
- there is a check for filters, but there is no check for projection. As a result - projection is dropped.

What changes are included in this PR?

This PR fixes incorrect if condition.

Are these changes tested?

Introduced unit test covering the change.

Are there any user-facing changes?

No user-facing changes. This PR reverts fixes API brake introduced in 47.0.0 release.

@github-actions github-actions bot added logical-expr Logical plan and expressions core Core DataFusion crate labels Apr 22, 2025
@xudong963 xudong963 self-requested a review April 22, 2025 14:06
@@ -498,7 +498,7 @@ impl LogicalPlanBuilder {
TableScan::try_new(table_name, table_source, projection, filters, fetch)?;

// Inline TableScan
if table_scan.filters.is_empty() {
if table_scan.projection.is_none() && table_scan.filters.is_empty() {
Copy link
Member

Choose a reason for hiding this comment

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

Thank you, nice find!

I'm wondering if we can still inline TableScan and wrap Projection on top of the view's logical plan. In this way, maybe the plan will be easier to optimize in the optimizer. -- This can be a further experiment, I think the PR is good to go.

Copy link
Contributor

Choose a reason for hiding this comment

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

The previous implementation did what you said.

@vadimpiven
Copy link
Contributor Author

vadimpiven commented Apr 23, 2025

@xudong963 I do not have a merge button even after your approval. Should I wait for another review, or you can merge the change? In the letter case I want to highlight that this change is blocking me from updating to 47.0.0 version, and I would highly appreciate a patch release with this fix.

@xudong963
Copy link
Member

Should I wait for another review, or you can merge the change?

I'll wait for another to review, if not, I'll merge tomorrow.

In the letter case I want to highlight that this change is blocking me from updating to 47.0.0 version,

cc @alamb

@xudong963
Copy link
Member

In the letter case I want to highlight that this change is blocking me from updating to 47.0.0 version, and I would highly appreciate a patch release with this fix.

If it's urgent, another way is to cherry-pick to your fork after merging

@vadimpiven
Copy link
Contributor Author

Thank you! Ok, will discuss making a fork and depending on it instead of upstream with my team today.

@jayzhan211
Copy link
Contributor

#15825

I couldn't open a PR to your repo. Here is the fix I did

@vadimpiven
Copy link
Contributor Author

You can merge your change and just close my PR, there is no difference to the result for me.

@vadimpiven
Copy link
Contributor Author

Updated the test code so we check that the projection is applied, not how it is applied.

assert_eq!(
plan.schema().field_names(),
vec![format!("{name}.{column}")]
);
Copy link
Contributor

@jayzhan211 jayzhan211 Apr 24, 2025

Choose a reason for hiding this comment

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

I think we also need to check the plan, so we know inline table rewrite works as expected

@vadimpiven vadimpiven closed this Apr 24, 2025
@vadimpiven
Copy link
Contributor Author

Close in favour of #15825

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Core DataFusion crate logical-expr Logical plan and expressions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Inline table scan drops projection
3 participants