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/14 18:35:34 UTC

[PR] test: show stats in explain of two representative queries [arrow-datafusion]

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

   ## 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.
   -->
   
   Tests for https://github.com/apache/arrow-datafusion/issues/8155
   
   ## Rationale for this change
   
   I have found that statistics were lost being propagated upward in the plan. These are tests that include representative operators for us to verify whether the statistics are computed and propagated up correctly 
   
   <!--
    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?
   
   Add 2 explains
   
   <!--
   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?
   
   They are tests only
   
   <!--
   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?
   
   No
   
   <!--
   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] test: show stats in explain of two representative queries [arrow-datafusion]

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

   I think the tests in this PR add value as they function as an end to end test of statistics calculation and propagation  -- perhaps we can move them to a different `.slt` file (`statistics.slt` perhaps)?


-- 
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] test: show stats in explain of two representative queries [arrow-datafusion]

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

   marking as draft to show this PR isn't waiting for review


-- 
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] test: show stats in explain of two representative queries [arrow-datafusion]

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


##########
datafusion/sqllogictest/test_files/explain.slt:
##########
@@ -279,13 +279,97 @@ physical_plan
 GlobalLimitExec: skip=0, fetch=10, statistics=[Rows=Inexact(10), Bytes=Absent, [(Col[0]:),(Col[1]:),(Col[2]:)]]
 --CsvExec: file_groups={1 group: [[WORKSPACE_ROOT/datafusion/core/tests/data/example.csv]]}, projection=[a, b, c], limit=10, has_header=true, statistics=[Rows=Absent, Bytes=Absent, [(Col[0]:),(Col[1]:),(Col[2]:)]]
 
-# Parquet scan with statistics collected
+# Collect statistics
 statement ok
 set datafusion.execution.collect_statistics = true;
 
+# CSV scan
+# query having almost presentative opererators
+query TT
+explain
+SELECT t1.c1, sum(t2.c4)
+FROM aggregate_test_100_with_order as t1, aggregate_test_100_with_order as t2
+WHERE t1.c3 > 10 and t1.c11 != 30.5
+    AND t2.c13 = 'whatever'
+    AND t1.c2 = t2.c2 and t2.c10 < 987654321
+GROUP BY t1.c1
+HAVING sum(t2.c4) > 1
+ORDER BY  t1.c1 ASC
+LIMIT 10;

Review Comment:
   I think this makes sense and is a great first step. 



-- 
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] test: show stats in explain of two representative queries [arrow-datafusion]

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


##########
datafusion/sqllogictest/test_files/explain.slt:
##########
@@ -279,13 +279,97 @@ physical_plan
 GlobalLimitExec: skip=0, fetch=10, statistics=[Rows=Inexact(10), Bytes=Absent, [(Col[0]:),(Col[1]:),(Col[2]:)]]
 --CsvExec: file_groups={1 group: [[WORKSPACE_ROOT/datafusion/core/tests/data/example.csv]]}, projection=[a, b, c], limit=10, has_header=true, statistics=[Rows=Absent, Bytes=Absent, [(Col[0]:),(Col[1]:),(Col[2]:)]]
 
-# Parquet scan with statistics collected
+# Collect statistics
 statement ok
 set datafusion.execution.collect_statistics = true;
 
+# CSV scan
+# query having almost presentative opererators
+query TT
+explain
+SELECT t1.c1, sum(t2.c4)
+FROM aggregate_test_100_with_order as t1, aggregate_test_100_with_order as t2
+WHERE t1.c3 > 10 and t1.c11 != 30.5
+    AND t2.c13 = 'whatever'
+    AND t1.c2 = t2.c2 and t2.c10 < 987654321
+GROUP BY t1.c1
+HAVING sum(t2.c4) > 1
+ORDER BY  t1.c1 ASC
+LIMIT 10;

Review Comment:
   @alamb : At first I thought I would add many small queries and on single data type but it turns out, if I do so, I have to add quite many and also many combinations for different data types. Still, they do not cover the propagation I want to see. Thus, I have to add complicated queries plus those small queries.
   
   To avoid that, I decided to go with 2 quite representative queries, one on CVS file and one on parquet file. Each I have different combinations of filters on different data types and includes common standard SQL clauses (select, from, where, group by, having, order by, limit). They not only show the statistics for each operator but also how they are propagated upward.
   
   Let me know what you think. I am happy to add small queries, too



-- 
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] test: show stats in explain of two representative queries [arrow-datafusion]

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

   @alamb : It seems there are improvements in statistics recently. Do you think we still need this kind of tests?


-- 
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