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

Show column names instead of indices in query plans #2690

Merged

Conversation

andygrove
Copy link
Member

Which issue does this PR close?

Closes #2689

Rationale for this change

I am comparing query plans between Spark and DataFusion

Spark shows:

FileScan parquet [ss_sold_time_sk#215,ss_hdemo_sk#219,ss_store_sk#221] ...

DataFusion shows:

TableScan: store_sales projection=Some([1, 5, 7])

I think we should show column names rather than numeric indices so that users don't have to memorize the schemas of the tables in order to comprehend the query plan.

What changes are included in this PR?

Show names instead of indices.

Are there any user-facing changes?

Yes, plans are easier to understand.

@github-actions github-actions bot added core Core DataFusion crate logical-expr Logical plan and expressions labels Jun 3, 2022
@andygrove andygrove changed the title Show column names instead of indices in TableProvider projection plan output Show column names instead of indices in query plans Jun 3, 2022
Copy link
Member

@Ted-Jiang Ted-Jiang left a comment

Choose a reason for hiding this comment

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

👍 More readable!

.iter()
.map(|i| schema.field(*i).name().as_str())
.collect();
format!("Some([{}])", names.join(", "))
Copy link
Contributor

@Dandandan Dandandan Jun 4, 2022

Choose a reason for hiding this comment

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

What about only showing the projection when there is one and ommiting it when there are none.
This could remove the None/Some too:

TableScan a projection=[col1,col2]
vs
TableScan a

Copy link
Member Author

Choose a reason for hiding this comment

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

I started out doing that and it broke many tests that were expecting None so I decided to reduce the size of the change. I agree that it would be a nice improvement though. I'm happy to work on that as a follow-on PR.

Copy link
Member Author

Choose a reason for hiding this comment

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

Filed #2697

Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

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

I think it is a nice improvement -- @Dandandan 's suggestion would make it even more so (though I think it can be done as a follow on PR as well). Thanks @andygrove

@andygrove andygrove merged commit c65feeb into apache:master Jun 4, 2022
@andygrove andygrove deleted the show-names-in-tablescan-projection branch June 4, 2022 20:59
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.

Show column names instead of column indices in query plans
4 participants