You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "alamb (via GitHub)" <gi...@apache.org> on 2023/10/10 14:02:20 UTC

[PR] Minor: Add sql test for `UNION` / `UNION ALL` + plans [arrow-datafusion]

alamb opened a new pull request, #7787:
URL: https://github.com/apache/arrow-datafusion/pull/7787

   ## Which issue does this PR close?
   
   Related to https://github.com/apache/arrow-datafusion/pull/7695  and https://github.com/apache/arrow-datafusion/issues/7786
   
   ## Rationale for this change
   
   Add test for https://github.com/apache/arrow-datafusion/issues/7786 as well as an end to end verification for https://github.com/apache/arrow-datafusion/pull/7695
   
   ## What changes are included in this PR?
   
   2 new tests
   
   ## Are these changes tested?
   
   <!--
   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?
   
   <!--
   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] Minor: Add sql test for `UNION` / `UNION ALL` + plans [arrow-datafusion]

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

   Thanks @comphead  and @jackwener 


-- 
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] Minor: Add sql test for `UNION` / `UNION ALL` + plans [arrow-datafusion]

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


-- 
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] Minor: Add sql test for `UNION` / `UNION ALL` + plans [arrow-datafusion]

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


##########
datafusion/sqllogictest/test_files/union.slt:
##########
@@ -174,6 +174,80 @@ UNION ALL
 Alice
 John
 
+# nested_union
+query T rowsort
+SELECT name FROM t1 UNION (SELECT name from t2 UNION SELECT name || '_new' from t2)
+----
+Alex
+Alex_new
+Alice
+Bob
+Bob_new
+John
+John_new
+
+# should be un-nested
+# https://github.com/apache/arrow-datafusion/issues/7786
+query TT
+EXPLAIN SELECT name FROM t1 UNION (SELECT name from t2 UNION SELECT name || '_new' from t2)
+----
+logical_plan
+Aggregate: groupBy=[[t1.name]], aggr=[[]]
+--Union
+----TableScan: t1 projection=[name]
+----Aggregate: groupBy=[[t2.name]], aggr=[[]]
+------Union
+--------TableScan: t2 projection=[name]
+--------Projection: t2.name || Utf8("_new") AS name
+----------TableScan: t2 projection=[name]
+physical_plan
+AggregateExec: mode=FinalPartitioned, gby=[name@0 as name], aggr=[]
+--CoalesceBatchesExec: target_batch_size=8192
+----RepartitionExec: partitioning=Hash([name@0], 4), input_partitions=8
+------AggregateExec: mode=Partial, gby=[name@0 as name], aggr=[]
+--------UnionExec
+----------MemoryExec: partitions=4, partition_sizes=[1, 0, 0, 0]
+----------AggregateExec: mode=FinalPartitioned, gby=[name@0 as name], aggr=[]
+------------CoalesceBatchesExec: target_batch_size=8192
+--------------RepartitionExec: partitioning=Hash([name@0], 4), input_partitions=8
+----------------AggregateExec: mode=Partial, gby=[name@0 as name], aggr=[]
+------------------UnionExec
+--------------------MemoryExec: partitions=4, partition_sizes=[1, 0, 0, 0]
+--------------------ProjectionExec: expr=[name@0 || _new as name]
+----------------------MemoryExec: partitions=4, partition_sizes=[1, 0, 0, 0]
+
+# nested_union_all
+query T rowsort
+SELECT name FROM t1 UNION ALL (SELECT name from t2 UNION ALL SELECT name || '_new' from t2)
+----
+Alex
+Alex
+Alex_new
+Alice
+Bob
+Bob
+Bob_new
+John
+John_new
+
+# Plan is unnested
+query TT
+EXPLAIN SELECT name FROM t1 UNION ALL (SELECT name from t2 UNION ALL SELECT name || '_new' from t2)

Review Comment:
   This test passes even without https://github.com/apache/arrow-datafusion/pull/7695 as the flattening happens in the SQL pass. https://github.com/apache/arrow-datafusion/pull/7695 move the flattening so it happens as part of the normal optimizer flow



-- 
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] Minor: Add sql test for `UNION` / `UNION ALL` + plans [arrow-datafusion]

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

   > Perhaps I'm wrong but why we have 2 set of AggregateExecs....
   
   Because we haven't implemented https://github.com/apache/arrow-datafusion/issues/7786 yet :) Though it appears that @maruschin is working on it in https://github.com/apache/arrow-datafusion/pull/7788
   


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