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

Optionally display schema in explain plan #11177

Merged
merged 1 commit into from
Jun 30, 2024
Merged

Conversation

alamb
Copy link
Contributor

@alamb alamb commented Jun 29, 2024

Which issue does this PR close?

Closes #11176

Rationale for this change

In the context of:

I have been contemplating adding optimizations that changes DataTypes between certain operators (e.g. to DictionaryArray or StringArray)

Thus I would like to be able to see the schema in the query plans as part of that project

What changes are included in this PR?

  1. Add set datafusion.explain.show_schema = true; option
  2. Add tests

Are these changes tested?

Yes

Are there any user-facing changes?

A new config option and more information in verbose explain plans

@github-actions github-actions bot added core Core DataFusion crate sqllogictest SQL Logic Tests (.slt) labels Jun 29, 2024
InitialPhysicalPlanWithStats,
),
);
// Show statistics + schema in verbose output even if not
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The amount of code required for this change is unfortunate, and I am sure we could make it better, but it was pretty mechanical

EXPLAIN SELECT a, b, c FROM simple_explain_test;
----
logical_plan TableScan: simple_explain_test projection=[a, b, c]
physical_plan CsvExec: file_groups={1 group: [[WORKSPACE_ROOT/datafusion/core/tests/data/example.csv]]}, projection=[a, b, c], has_header=true, schema=[a:Int32;N, b:Int32;N, c:Int32;N]
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 shows how the schema is displayed (schema=[[a:Int32;N, b:Int32;N, c:Int32;N]])

@alamb alamb marked this pull request as ready for review June 29, 2024 19:59
Copy link
Contributor

@jayzhan211 jayzhan211 left a comment

Choose a reason for hiding this comment

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

👍

@alamb
Copy link
Contributor Author

alamb commented Jun 30, 2024

Thank you for the review @jayzhan211

@alamb alamb merged commit 90145df into apache:main Jun 30, 2024
25 checks passed
findepi pushed a commit to findepi/datafusion that referenced this pull request Jul 16, 2024
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Core DataFusion crate sqllogictest SQL Logic Tests (.slt)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Optionally display schema in explain plan
2 participants