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

add session option 'datafusion.explain.logical_plan'. when set to true, the explain statement will only print logical plans. #2895

Merged
merged 3 commits into from
Jul 14, 2022

Conversation

HuSen8891
Copy link
Contributor

Which issue does this PR close?

Closes #2894

Rationale for this change

Add session option 'datafusion.explain.logical_plan'.
when set to true, the explain statement will only print logical plans. We can set environment variable DATAFUSION_EXPLAIN_LOGICAL_PLAN to make this value take effect.

For example:
explain select count(*) from (values ('a', 1, 100), ('a', 2, 150)) as t (c1,c2,c3);

+--------------+----------------------------------------------------------------------------------+
| plan_type | plan |
+--------------+----------------------------------------------------------------------------------+
| logical_plan | Projection: #COUNT(UInt8(1)) |
| | Aggregate: groupBy=[[]], aggr=[[COUNT(UInt8(1))]] |
| | Values: (Utf8("a"), Int64(1), Int64(100)), (Utf8("a"), Int64(2), Int64(150)) |
+--------------+----------------------------------------------------------------------------------+

What changes are included in this PR?

add session option 'datafusion.explain.logical_plan'. in datafusion/core/src/config.rs
use this option to control the output of explain statement in datafusion/core/src/physical_plan/planner.rs

…e, the explain statement will only print logical plans.
@github-actions github-actions bot added the core Core DataFusion crate label Jul 13, 2022
@codecov-commenter
Copy link

Codecov Report

Merging #2895 (a47b237) into master (6a5de4f) will increase coverage by 0.00%.
The diff coverage is 92.30%.

❗ Current head a47b237 differs from pull request most recent head e8551bc. Consider uploading reports for the commit e8551bc to get more accurate results

@@           Coverage Diff           @@
##           master    #2895   +/-   ##
=======================================
  Coverage   85.34%   85.34%           
=======================================
  Files         276      276           
  Lines       49294    49296    +2     
=======================================
+ Hits        42071    42073    +2     
  Misses       7223     7223           
Impacted Files Coverage Δ
datafusion/core/src/config.rs 92.50% <ø> (ø)
datafusion/core/src/physical_plan/planner.rs 81.02% <92.30%> (+0.03%) ⬆️
datafusion/physical-expr/src/expressions/binary.rs 95.03% <0.00%> (-0.09%) ⬇️
datafusion/core/src/physical_plan/metrics/value.rs 87.43% <0.00%> (+0.50%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6a5de4f...e8551bc. Read the comment docs.

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.

Thank you @AssHero -- This looks good to me

I think this feature needs a test, so this feature isn't accidentally broken in the future, but extending one of the existing tests should be straight forward

@@ -27,6 +27,9 @@ use std::env;
/// Configuration option "datafusion.optimizer.filter_null_join_keys"
pub const OPT_FILTER_NULL_JOIN_KEYS: &str = "datafusion.optimizer.filter_null_join_keys";

/// Configuration option "datafusion.explain.logical_plan"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
/// Configuration option "datafusion.explain.logical_plan"
/// Configuration option "datafusion.explain.logical_plan_only"

Maybe we could call it datafusion.explain.logical_plan_only to be consistent with the internal implementation and be more self describing

Another way to encode this might be "datafusion.explain.include_physical_plan", defaulted to true. That way we could also encode a "datafusion.explain.include_logical_plan" if people ever wanted only the physical plan

This way works too. problem with this way, however

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks!
I add two options 'datafusion.explain.logical_plan_only' and 'datafusion.explain.physical_plan_only'.
If set datafusion.explain.logical_plan_only to true, only print logical plans.
If set datafusion.explain.physical_plan_only to true, only print physical plans.
Both default to false.

But if both are set to true, print nothing currently.

@HuSen8891
Copy link
Contributor Author

Thank you @AssHero -- This looks good to me

I think this feature needs a test, so this feature isn't accidentally broken in the future, but extending one of the existing tests should be straight forward

I'll add a test later. Thanks!

…plan_only' and 'datafusion.explain.physical_plan_only' to

seperately print logical plans and physical plans.
@HuSen8891
Copy link
Contributor Author

  1. add test cases.
  2. add session options 'datafusion.explain.logical_plan_only' and 'datafusion.explain.physical_plan_only' to seperately print logical plans and physical plans.

@@ -119,6 +125,16 @@ impl BuiltInConfigs {
predicate push down.",
false,
),
ConfigDefinition::new_bool(
Copy link
Member

Choose a reason for hiding this comment

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

can you run ./dev/update_config_docs.sh to re-generate the documentation to include these new options

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 docs/source/user-guide/configs.md is updated. Thanks!

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.

looks good to me 👍

@HuSen8891
Copy link
Contributor Author

Re-generate the documentation to include these new options.

@alamb
Copy link
Contributor

alamb commented Jul 14, 2022

👍 Thanks again @AssHero !

@alamb alamb merged commit 1b8117e into apache:master Jul 14, 2022
@ursabot
Copy link

ursabot commented Jul 14, 2022

Benchmark runs are scheduled for baseline = 6dc9dea and contender = 1b8117e. 1b8117e is a master commit associated with this PR. Results will be available as each benchmark for each run completes.
Conbench compare runs links:
[Skipped ⚠️ Benchmarking of arrow-datafusion-commits is not supported on ec2-t3-xlarge-us-east-2] ec2-t3-xlarge-us-east-2
[Skipped ⚠️ Benchmarking of arrow-datafusion-commits is not supported on test-mac-arm] test-mac-arm
[Skipped ⚠️ Benchmarking of arrow-datafusion-commits is not supported on ursa-i9-9960x] ursa-i9-9960x
[Skipped ⚠️ Benchmarking of arrow-datafusion-commits is not supported on ursa-thinkcentre-m75q] ursa-thinkcentre-m75q
Buildkite builds:
Supported benchmarks:
ec2-t3-xlarge-us-east-2: Supported benchmark langs: Python, R. Runs only benchmarks with cloud = True
test-mac-arm: Supported benchmark langs: C++, Python, R
ursa-i9-9960x: Supported benchmark langs: Python, R, JavaScript
ursa-thinkcentre-m75q: Supported benchmark langs: C++, Java

@HuSen8891 HuSen8891 deleted the logical_plan branch July 16, 2022 15:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Core DataFusion crate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The explain statements only print logical plans for debug/other purpose.
5 participants