Skip to content

Change default EXPLAIN format in datafusion-cli to tree format#15427

Merged
alamb merged 10 commits into
apache:mainfrom
alamb:alamb/default_explain_plan
Mar 31, 2025
Merged

Change default EXPLAIN format in datafusion-cli to tree format#15427
alamb merged 10 commits into
apache:mainfrom
alamb:alamb/default_explain_plan

Conversation

@alamb

@alamb alamb commented Mar 25, 2025

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Rationale for this change

We have nice explain plans, let's default DataFusion cli to use them

What changes are included in this PR?

Note that as discussed on #15343, this ONLY affects datafusion-cli. Any downstream project that wants nicer explain plans by default can adjust the configuration settings

Are these changes tested?

Yes with new tests

Are there any user-facing changes?

EXPLAIN in datafusion-cli will now use the new explain tree format. For example:

DataFusion CLI v46.0.1
> explain select 123;
+---------------+-------------------------------+
| plan_type     | plan                          |
+---------------+-------------------------------+
| physical_plan | ┌───────────────────────────┐ |
|               | │       ProjectionExec      │ |
|               | │    --------------------   │ |
|               | │      Int64(123): 123      │ |
|               | └─────────────┬─────────────┘ |
|               | ┌─────────────┴─────────────┐ |
|               | │     PlaceholderRowExec    │ |
|               | └───────────────────────────┘ |
|               |                               |
+---------------+-------------------------------+
1 row(s) fetched.
Elapsed 0.026 seconds.

You can get the previous indent explain plan by asking for it explicitly:

DataFusion CLI v46.0.1
> explain format indent select 123;
+---------------+------------------------------------------+
| plan_type     | plan                                     |
+---------------+------------------------------------------+
| logical_plan  | Projection: Int64(123)                   |
|               |   EmptyRelation                          |
| physical_plan | ProjectionExec: expr=[123 as Int64(123)] |
|               |   PlaceholderRowExec                     |
|               |                                          |
+---------------+------------------------------------------+
2 row(s) fetched.
Elapsed 0.023 seconds.

Comment thread datafusion-cli/tests/cli_integration.rs Outdated
assert_cmd_snapshot!(cmd);
}

#[rstest]

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I could not get these to work as additional examples in quick_test for reasons I couldn't figure out. So I just made a new test

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this works

blaginin@4738e46

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks, pulled into this branch

@alamb alamb force-pushed the alamb/default_explain_plan branch from c7ced76 to cfa9171 Compare March 25, 2025 22:41
@alamb alamb added the api change Changes the API exposed to users of the crate label Mar 25, 2025
@alamb alamb changed the title Alamb/default explain plan Change default EXPLAIN format in datafusion-cli to tree format Mar 25, 2025
@alamb alamb marked this pull request as ready for review March 26, 2025 10:00

@xudong963 xudong963 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looking forward to df47 😆

@blaginin

Copy link
Copy Markdown
Member

I think one issue with the current approach is that loading from env will break.

before:
RustRover 2025-03-26 18 56 08

after:
RustRover 2025-03-26 18 55 58

@alamb

alamb commented Mar 26, 2025

Copy link
Copy Markdown
Contributor Author

I think one issue with the current approach is that loading from env will break.

this is a good call -- I will fix that

@alamb

alamb commented Mar 27, 2025

Copy link
Copy Markdown
Contributor Author

Run extended tests

@alamb

alamb commented Mar 27, 2025

Copy link
Copy Markdown
Contributor Author

Run extended tests

@alamb

alamb commented Mar 30, 2025

Copy link
Copy Markdown
Contributor Author

I think one issue with the current approach is that loading from env will break.

I pushed a fix and a test for this

@blaginin blaginin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

😍

@alamb

alamb commented Mar 30, 2025

Copy link
Copy Markdown
Contributor Author

I'll plan to merge this one tomorrow unless anyone else would like time to comment

@alamb

alamb commented Mar 31, 2025

Copy link
Copy Markdown
Contributor Author

🚀 📖

THanks again @blaginin and @xudong963

nirnayroy pushed a commit to nirnayroy/datafusion that referenced this pull request May 2, 2025
…pache#15427)

* Change default explain plan to `tree`

* Add tests

* remove unecessary changes

* more unecessary changes

* Move test cases

* Respect environment variable for explain plan

* Fix format

* fmt

---------

Co-authored-by: blaginin <dmitrii@blaginin.me>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api change Changes the API exposed to users of the crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[DISCUSS] Switch to tree explain by default

3 participants