xinlifoobar commented on issue #10314: URL: https://github.com/apache/datafusion/issues/10314#issuecomment-2122201906
Hi @alamb, found another interesting case while testing, do you think this
could apply `InterleaveExec` with same order by sets?
```
explain select count(*) from ((select distinct c1, c2 from t3 order by c1 )
union all (select distinct c1, c2 from t4 order by c1)) group by cube(c1,c2);
+---------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| plan_type | plan
|
+---------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| logical_plan | Projection: COUNT(*)
|
| | Aggregate: groupBy=[[CUBE (t3.c1, t3.c2)]],
aggr=[[COUNT(Int64(1)) AS COUNT(*)]]
|
| | Union
|
| | Sort: t3.c1 ASC NULLS LAST
|
| | Aggregate: groupBy=[[t3.c1, t3.c2]], aggr=[[]]
|
| | TableScan: t3 projection=[c1, c2]
|
| | Sort: t4.c1 ASC NULLS LAST
|
| | Aggregate: groupBy=[[t4.c1, t4.c2]], aggr=[[]]
|
| | TableScan: t4 projection=[c1, c2]
|
| physical_plan | ProjectionExec: expr=[COUNT(*)@2 as COUNT(*)]
|
| | AggregateExec: mode=FinalPartitioned, gby=[c1@0 as c1,
c2@1 as c2], aggr=[COUNT(*)], ordering_mode=PartiallySorted([0])
|
| | SortExec: expr=[c1@0 ASC NULLS LAST],
preserve_partitioning=[true]
|
| | CoalesceBatchesExec: target_batch_size=8192
|
| | RepartitionExec: partitioning=Hash([c1@0, c2@1],
14), input_partitions=14
|
| | RepartitionExec:
partitioning=RoundRobinBatch(14), input_partitions=2
|
| | AggregateExec: mode=Partial, gby=[(c1@0 as c1,
c2@1 as c2), (NULL as c1, c2@1 as c2), (c1@0 as c1, NULL as c2), (NULL as c1,
NULL as c2)], aggr=[COUNT(*)] |
| | UnionExec
|
| | CoalescePartitionsExec
|
| | AggregateExec: mode=FinalPartitioned,
gby=[c1@0 as c1, c2@1 as c2], aggr=[]
|
| | CoalesceBatchesExec:
target_batch_size=8192
|
| | RepartitionExec:
partitioning=Hash([c1@0, c2@1], 14), input_partitions=1
|
| | AggregateExec: mode=Partial,
gby=[c1@0 as c1, c2@1 as c2], aggr=[]
|
| | MemoryExec: partitions=1,
partition_sizes=[0]
|
| | CoalescePartitionsExec
|
| | AggregateExec: mode=FinalPartitioned,
gby=[c1@0 as c1, c2@1 as c2], aggr=[]
|
| | CoalesceBatchesExec:
target_batch_size=8192
|
| | RepartitionExec:
partitioning=Hash([c1@0, c2@1], 14), input_partitions=1
|
| | AggregateExec: mode=Partial,
gby=[c1@0 as c1, c2@1 as c2], aggr=[]
|
| | MemoryExec: partitions=1,
partition_sizes=[0]
|
| |
|
+---------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
2 row(s) fetched.
```
With `InterleaveExec`:
```
ProjectionExec:
AggregateExec:
InterleaveExec:
SortExec:
AggregateExec:
SortExec:
AggregateExec:
```
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
