xinlifoobar commented on issue #10613:
URL: https://github.com/apache/datafusion/issues/10613#issuecomment-2124136360
This is like an optimization for empty tables. The result above is when both
t3 and t4 are empty. After insert some values, the plan displayed correctly.
```sql
> insert into t3 values (1,2), (2,3)
;
+-------+
| count |
+-------+
| 2 |
+-------+
1 row(s) fetched.
Elapsed 0.004 seconds.
> explain select count(*) from ((select distinct c1, c2 from t3 order by c1
) union all (select distinct c2, c1 from t4 order by c1));
+---------------+-------------------------------------------------------------------------------------------+
| plan_type | plan
|
+---------------+-------------------------------------------------------------------------------------------+
| logical_plan | Aggregate: groupBy=[[]], aggr=[[COUNT(Int64(1)) AS
COUNT(*)]] |
| | Union
|
| | Projection:
|
| | Sort: t3.c1 ASC NULLS LAST
|
| | Projection: t3.c1
|
| | Aggregate: groupBy=[[t3.c1, t3.c2]], aggr=[[]]
|
| | TableScan: t3 projection=[c1, c2]
|
| | Projection:
|
| | Sort: t4.c1 ASC NULLS LAST
|
| | Projection: t4.c1
|
| | Aggregate: groupBy=[[t4.c2, t4.c1]], aggr=[[]]
|
| | Projection: t4.c2, t4.c1
|
| | TableScan: t4 projection=[c1, c2]
|
| physical_plan | AggregateExec: mode=Final, gby=[], aggr=[COUNT(*)]
|
| | CoalescePartitionsExec
|
| | AggregateExec: mode=Partial, gby=[], aggr=[COUNT(*)]
|
| | RepartitionExec: partitioning=RoundRobinBatch(14),
input_partitions=28 |
| | UnionExec
|
| | ProjectionExec: expr=[]
|
| | 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=14 |
| | RepartitionExec:
partitioning=RoundRobinBatch(14), input_partitions=1 |
| | AggregateExec: mode=Partial, gby=[c1@0
as c1, c2@1 as c2], aggr=[] |
| | MemoryExec: partitions=1,
partition_sizes=[1] |
| | ProjectionExec: expr=[]
|
| | AggregateExec: mode=FinalPartitioned,
gby=[c2@0 as c2, c1@1 as c1], aggr=[] |
| | CoalesceBatchesExec: target_batch_size=8192
|
| | RepartitionExec: partitioning=Hash([c2@0,
c1@1], 14), input_partitions=1 |
| | AggregateExec: mode=Partial, gby=[c2@0
as c2, c1@1 as c1], aggr=[] |
| | MemoryExec: partitions=1,
partition_sizes=[0] |
| |
|
+---------------+-------------------------------------------------------------------------------------------+
2 row(s) fetched.
Elapsed 0.018 seconds.
> select count(*) from ((select distinct c1, c2 from t3 order by c1 ) union
all (select distinct c2, c1 from t4 order by c1));
+----------+
| COUNT(*) |
+----------+
| 2 |
+----------+
1 row(s) fetched.
Elapsed 0.019 seconds.
```
--
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]