You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "NGA-TRAN (via GitHub)" <gi...@apache.org> on 2023/11/09 22:58:54 UTC

[PR] feat: show statistics in explain verbose [arrow-datafusion]

NGA-TRAN opened a new pull request, #8113:
URL: https://github.com/apache/arrow-datafusion/pull/8113

   ## Which issue does this PR close?
   
   <!--
   We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123.
   -->
   
   Closes #https://github.com/apache/arrow-datafusion/issues/8111
   
   ## Rationale for this change
   
   Always show statistics in explain verbose to get used by other DB such as IOx that do not want to use setting `set datafusion.explain.show_statistics = true;`
   
   <!--
    Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed.
    Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes.  
   -->
   
   ## What changes are included in this PR?
   
   Always show statistics in explain verbose
   
   <!--
   There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
   -->
   
   ## Are these changes tested?
   
   Yes
   
   <!--
   We typically require tests for all PRs in order to:
   1. Prevent the code from being accidentally broken by subsequent changes
   2. Serve as another way to document the expected behavior of the code
   
   If tests are not included in your PR, please explain why (for example, are they covered by existing tests)?
   -->
   
   ## Are there any user-facing changes?
   
   Explain verbose now includes statistics 
   
   <!--
   If there are user-facing changes then we may require documentation to be updated before approving the PR.
   -->
   
   <!--
   If there are any breaking changes to public APIs, please add the `api change` label.
   -->
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat: show statistics in explain verbose [arrow-datafusion]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on code in PR #8113:
URL: https://github.com/apache/arrow-datafusion/pull/8113#discussion_r1391364572


##########
datafusion/core/src/physical_planner.rs:
##########
@@ -1900,6 +1900,18 @@ impl DefaultPhysicalPlanner {
                                 .to_stringified(e.verbose, InitialPhysicalPlan),
                         );
 
+                        // Add plan with stats for verbose case even if show_statistics is false

Review Comment:
   This comment seems confusing as the next line checks for `!config.show_statistics`. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat: show statistics in explain verbose [arrow-datafusion]

Posted by "NGA-TRAN (via GitHub)" <gi...@apache.org>.
NGA-TRAN commented on PR #8113:
URL: https://github.com/apache/arrow-datafusion/pull/8113#issuecomment-1806498233

   @alamb I have addressed your comments but I have a new question in the code


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat: show statistics in explain verbose [arrow-datafusion]

Posted by "NGA-TRAN (via GitHub)" <gi...@apache.org>.
NGA-TRAN commented on code in PR #8113:
URL: https://github.com/apache/arrow-datafusion/pull/8113#discussion_r1391534504


##########
datafusion/core/src/physical_planner.rs:
##########
@@ -1900,6 +1900,18 @@ impl DefaultPhysicalPlanner {
                                 .to_stringified(e.verbose, InitialPhysicalPlan),
                         );
 
+                        // Add plan with stats for verbose case even if show_statistics is false

Review Comment:
   I have made the comments clearer



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat: show statistics in explain verbose [arrow-datafusion]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #8113:
URL: https://github.com/apache/arrow-datafusion/pull/8113#issuecomment-1809167216

   Looks like the CI failures are due to a logical merge conflict with #8112 -- I'll push an update


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat: show statistics in explain verbose [arrow-datafusion]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #8113:
URL: https://github.com/apache/arrow-datafusion/pull/8113#issuecomment-1806444585

   Something like this perhaps: https://github.com/apache/arrow-datafusion/issues/8111#issuecomment-1806444463


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat: show statistics in explain verbose [arrow-datafusion]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb merged PR #8113:
URL: https://github.com/apache/arrow-datafusion/pull/8113


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat: show statistics in explain verbose [arrow-datafusion]

Posted by "NGA-TRAN (via GitHub)" <gi...@apache.org>.
NGA-TRAN commented on PR #8113:
URL: https://github.com/apache/arrow-datafusion/pull/8113#issuecomment-1804815812

   @alamb : Instead of adding lines with stats, I just add stats to all physical plans which I think more reasonable. Let me know what you think
   
   CC @berkaysynnada 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat: show statistics in explain verbose [arrow-datafusion]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on code in PR #8113:
URL: https://github.com/apache/arrow-datafusion/pull/8113#discussion_r1390015438


##########
datafusion/proto/src/logical_plan/to_proto.rs:
##########
@@ -352,6 +352,11 @@ impl From<&StringifiedPlan> for protobuf::StringifiedPlan {
                 PlanType::FinalPhysicalPlan => Some(protobuf::PlanType {
                     plan_type_enum: Some(FinalPhysicalPlan(EmptyMessage {})),
                 }),
+                // Make it `todo` to avoid breaking clippy
+                // We do not want to add proto plan type for these two becasue they are just the same as
+                // InitialPhysicalPlan and FinalPhysicalPlan
+                datafusion_expr::PlanType::InitialPhysicalPlanWithStats
+                | datafusion_expr::PlanType::FinalPhysicalPlanWithStats => todo!(),

Review Comment:
   I think adding two new types in the proto would be the most consistent with the existing code
   
   However, as long as this doesn't panic I think it would be ok to merge -- for example, if it returned an internal error. 
   
   I don't really understand why there is special serialization for this to be honest 🤔  maybe we could simplify that too as a follow on PR



##########
datafusion/sqllogictest/test_files/explain.slt:
##########
@@ -245,6 +245,7 @@ logical_plan after eliminate_projection SAME TEXT AS ABOVE
 logical_plan after push_down_limit SAME TEXT AS ABOVE
 logical_plan TableScan: simple_explain_test projection=[a, b, c]
 initial_physical_plan CsvExec: file_groups={1 group: [[WORKSPACE_ROOT/datafusion/core/tests/data/example.csv]]}, projection=[a, b, c], has_header=true
+initial_physical_plan_with_stats CsvExec: file_groups={1 group: [[WORKSPACE_ROOT/datafusion/core/tests/data/example.csv]]}, projection=[a, b, c], has_header=true, statistics=[Rows=Absent, Bytes=Absent]

Review Comment:
   Nice



##########
datafusion/proto/src/logical_plan/to_proto.rs:
##########
@@ -352,6 +352,11 @@ impl From<&StringifiedPlan> for protobuf::StringifiedPlan {
                 PlanType::FinalPhysicalPlan => Some(protobuf::PlanType {
                     plan_type_enum: Some(FinalPhysicalPlan(EmptyMessage {})),
                 }),
+                // Make it `todo` to avoid breaking clippy
+                // We do not want to add proto plan type for these two becasue they are just the same as
+                // InitialPhysicalPlan and FinalPhysicalPlan
+                datafusion_expr::PlanType::InitialPhysicalPlanWithStats
+                | datafusion_expr::PlanType::FinalPhysicalPlanWithStats => todo!(),

Review Comment:
   I think adding two new types in the proto would be the most consistent with the existing code
   
   However, as long as this doesn't panic I think it would be ok to merge -- for example, if it returned an internal error. 
   
   I don't really understand why there is special serialization for this to be honest 🤔  maybe we could simplify that too as a follow on PR



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat: show statistics in explain verbose [arrow-datafusion]

Posted by "NGA-TRAN (via GitHub)" <gi...@apache.org>.
NGA-TRAN commented on code in PR #8113:
URL: https://github.com/apache/arrow-datafusion/pull/8113#discussion_r1391533955


##########
datafusion/proto/src/logical_plan/to_proto.rs:
##########
@@ -352,6 +352,11 @@ impl From<&StringifiedPlan> for protobuf::StringifiedPlan {
                 PlanType::FinalPhysicalPlan => Some(protobuf::PlanType {
                     plan_type_enum: Some(FinalPhysicalPlan(EmptyMessage {})),
                 }),
+                // Make it `todo` to avoid breaking clippy
+                // We do not want to add proto plan type for these two becasue they are just the same as
+                // InitialPhysicalPlan and FinalPhysicalPlan
+                datafusion_expr::PlanType::InitialPhysicalPlanWithStats
+                | datafusion_expr::PlanType::FinalPhysicalPlanWithStats => todo!(),

Review Comment:
   I have add 2 new types to proto instead



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat: show statistics in explain verbose [arrow-datafusion]

Posted by "berkaysynnada (via GitHub)" <gi...@apache.org>.
berkaysynnada commented on PR #8113:
URL: https://github.com/apache/arrow-datafusion/pull/8113#issuecomment-1805208284

   I think it makes sense, thank you.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat: show statistics in explain verbose [arrow-datafusion]

Posted by "NGA-TRAN (via GitHub)" <gi...@apache.org>.
NGA-TRAN commented on code in PR #8113:
URL: https://github.com/apache/arrow-datafusion/pull/8113#discussion_r1389965551


##########
datafusion/proto/src/logical_plan/to_proto.rs:
##########
@@ -352,6 +352,11 @@ impl From<&StringifiedPlan> for protobuf::StringifiedPlan {
                 PlanType::FinalPhysicalPlan => Some(protobuf::PlanType {
                     plan_type_enum: Some(FinalPhysicalPlan(EmptyMessage {})),
                 }),
+                // Make it `todo` to avoid breaking clippy
+                // We do not want to add proto plan type for these two becasue they are just the same as
+                // InitialPhysicalPlan and FinalPhysicalPlan
+                datafusion_expr::PlanType::InitialPhysicalPlanWithStats
+                | datafusion_expr::PlanType::FinalPhysicalPlanWithStats => todo!(),

Review Comment:
   @alamb Cargo suggested me to do this. Do you want to go with this or create 2 new types in photo enum?



##########
datafusion/sqllogictest/test_files/explain.slt:
##########
@@ -291,8 +293,72 @@ physical_plan
 GlobalLimitExec: skip=0, fetch=10, statistics=[Rows=Exact(8), Bytes=Absent]
 --ParquetExec: file_groups={1 group: [[WORKSPACE_ROOT/parquet-testing/data/alltypes_plain.parquet]]}, projection=[id, bool_col, tinyint_col, smallint_col, int_col, bigint_col, float_col, double_col, date_string_col, string_col, timestamp_col], limit=10, statistics=[Rows=Exact(8), Bytes=Absent]
 
-statement ok
-set datafusion.execution.collect_statistics = false;
+# explain verbose with both collect & show statistics on
+query TT
+EXPLAIN VERBOSE SELECT * FROM alltypes_plain limit 10;

Review Comment:
   All plans have stats because show_stats is on. This works the same as before this PR



##########
datafusion/sqllogictest/test_files/explain.slt:
##########
@@ -291,8 +293,72 @@ physical_plan
 GlobalLimitExec: skip=0, fetch=10, statistics=[Rows=Exact(8), Bytes=Absent]
 --ParquetExec: file_groups={1 group: [[WORKSPACE_ROOT/parquet-testing/data/alltypes_plain.parquet]]}, projection=[id, bool_col, tinyint_col, smallint_col, int_col, bigint_col, float_col, double_col, date_string_col, string_col, timestamp_col], limit=10, statistics=[Rows=Exact(8), Bytes=Absent]
 
-statement ok
-set datafusion.execution.collect_statistics = false;
+# explain verbose with both collect & show statistics on
+query TT
+EXPLAIN VERBOSE SELECT * FROM alltypes_plain limit 10;
+----
+initial_physical_plan
+GlobalLimitExec: skip=0, fetch=10, statistics=[Rows=Exact(8), Bytes=Absent]
+--ParquetExec: file_groups={1 group: [[WORKSPACE_ROOT/parquet-testing/data/alltypes_plain.parquet]]}, projection=[id, bool_col, tinyint_col, smallint_col, int_col, bigint_col, float_col, double_col, date_string_col, string_col, timestamp_col], limit=10, statistics=[Rows=Exact(8), Bytes=Absent]
+physical_plan after OutputRequirements
+OutputRequirementExec, statistics=[Rows=Exact(8), Bytes=Absent]
+--GlobalLimitExec: skip=0, fetch=10, statistics=[Rows=Exact(8), Bytes=Absent]
+----ParquetExec: file_groups={1 group: [[WORKSPACE_ROOT/parquet-testing/data/alltypes_plain.parquet]]}, projection=[id, bool_col, tinyint_col, smallint_col, int_col, bigint_col, float_col, double_col, date_string_col, string_col, timestamp_col], limit=10, statistics=[Rows=Exact(8), Bytes=Absent]
+physical_plan after aggregate_statistics SAME TEXT AS ABOVE
+physical_plan after join_selection SAME TEXT AS ABOVE
+physical_plan after LimitedDistinctAggregation SAME TEXT AS ABOVE
+physical_plan after EnforceDistribution SAME TEXT AS ABOVE
+physical_plan after CombinePartialFinalAggregate SAME TEXT AS ABOVE
+physical_plan after EnforceSorting SAME TEXT AS ABOVE
+physical_plan after coalesce_batches SAME TEXT AS ABOVE
+physical_plan after OutputRequirements
+GlobalLimitExec: skip=0, fetch=10, statistics=[Rows=Exact(8), Bytes=Absent]
+--ParquetExec: file_groups={1 group: [[WORKSPACE_ROOT/parquet-testing/data/alltypes_plain.parquet]]}, projection=[id, bool_col, tinyint_col, smallint_col, int_col, bigint_col, float_col, double_col, date_string_col, string_col, timestamp_col], limit=10, statistics=[Rows=Exact(8), Bytes=Absent]
+physical_plan after PipelineChecker SAME TEXT AS ABOVE
+physical_plan after LimitAggregation SAME TEXT AS ABOVE
+physical_plan after ProjectionPushdown SAME TEXT AS ABOVE
+physical_plan
+GlobalLimitExec: skip=0, fetch=10, statistics=[Rows=Exact(8), Bytes=Absent]
+--ParquetExec: file_groups={1 group: [[WORKSPACE_ROOT/parquet-testing/data/alltypes_plain.parquet]]}, projection=[id, bool_col, tinyint_col, smallint_col, int_col, bigint_col, float_col, double_col, date_string_col, string_col, timestamp_col], limit=10, statistics=[Rows=Exact(8), Bytes=Absent]
+
 
 statement ok
 set datafusion.explain.show_statistics = false;
+
+# explain verbose with collect on and & show statistics off: still has stats
+query TT
+EXPLAIN VERBOSE SELECT * FROM alltypes_plain limit 10;

Review Comment:
   2 new lines added for this one because show_stats is off



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat: show statistics in explain verbose [arrow-datafusion]

Posted by "NGA-TRAN (via GitHub)" <gi...@apache.org>.
NGA-TRAN commented on PR #8113:
URL: https://github.com/apache/arrow-datafusion/pull/8113#issuecomment-1806450315

   > Something like this perhaps: https://github.com/apache/arrow-datafusion/issues/8111#issuecomment-1806444463
   
   Sounds good. I will add stats for initial and final physical plans only


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat: show statistics in explain verbose [arrow-datafusion]

Posted by "NGA-TRAN (via GitHub)" <gi...@apache.org>.
NGA-TRAN commented on code in PR #8113:
URL: https://github.com/apache/arrow-datafusion/pull/8113#discussion_r1391402864


##########
datafusion/proto/src/logical_plan/to_proto.rs:
##########
@@ -352,6 +352,11 @@ impl From<&StringifiedPlan> for protobuf::StringifiedPlan {
                 PlanType::FinalPhysicalPlan => Some(protobuf::PlanType {
                     plan_type_enum: Some(FinalPhysicalPlan(EmptyMessage {})),
                 }),
+                // Make it `todo` to avoid breaking clippy
+                // We do not want to add proto plan type for these two becasue they are just the same as
+                // InitialPhysicalPlan and FinalPhysicalPlan
+                datafusion_expr::PlanType::InitialPhysicalPlanWithStats
+                | datafusion_expr::PlanType::FinalPhysicalPlanWithStats => todo!(),

Review Comment:
   @alamb  The `todo!`  returns a panic of `not yet implemented`.  Let me try to add new types to proto



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org