HaoYang670 commented on issue #1623:
URL:
https://github.com/apache/arrow-datafusion/issues/1623#issuecomment-1036041447
```text
EXPLAIN VERBOSE select count(*) count(distinct stop_name) from stops group
by trip_tid
| physical_plan | ProjectionExec:
expr=[COUNT(UInt8(1))@1 as COUNT(UInt8(1)), COUNT(DISTINCT stops.stop_name)@2
as COUNT(DISTINCT stops.stop_name)] |
| |
HashAggregateExec: mode=FinalPartitioned, gby=[trip_tid@0 as trip_tid],
aggr=[COUNT(UInt8(1)), COUNT(DISTINCT stops.stop_name)] |
| |
CoalesceBatchesExec: target_batch_size=4096
|
| |
RepartitionExec: partitioning=Hash([Column { name: "trip_tid", index: 0 }], 16)
|
| |
HashAggregateExec: mode=Partial, gby=[trip_tid@0 as trip_tid],
aggr=[COUNT(UInt8(1)), COUNT(DISTINCT stops.stop_name)] |
| |
RepartitionExec: partitioning=RoundRobinBatch(16)
|
| |
ParquetExec: limit=None,
partitions=[/home/remziy/Downloads/data/2021-11.parquet]
EXPLAIN VERBOSE select count(distinct stop_name) from stops group by trip_tid
| physical_plan | ProjectionExec:
expr=[COUNT(DISTINCT stops.stop_name)@0 as COUNT(DISTINCT stops.stop_name)]
|
| | ProjectionExec:
expr=[COUNT(alias1)@1 as COUNT(DISTINCT stops.stop_name)]
|
| |
HashAggregateExec: mode=FinalPartitioned, gby=[trip_tid@0 as trip_tid],
aggr=[COUNT(alias1)] |
| |
CoalesceBatchesExec: target_batch_size=4096
|
| |
RepartitionExec: partitioning=Hash([Column { name: "trip_tid", index: 0 }], 16)
|
| |
HashAggregateExec: mode=Partial, gby=[trip_tid@0 as trip_tid],
aggr=[COUNT(alias1)] |
| |
HashAggregateExec: mode=FinalPartitioned, gby=[trip_tid@0 as trip_tid, alias1@1
as alias1], aggr=[] |
| |
CoalesceBatchesExec: target_batch_size=4096
|
| |
RepartitionExec: partitioning=Hash([Column { name: "trip_tid", index: 0 },
Column { name: "alias1", index: 1 }], 16) |
| |
HashAggregateExec: mode=Partial, gby=[trip_tid@0 as trip_tid, stop_name@1 as
alias1], aggr=[] |
| |
RepartitionExec: partitioning=RoundRobinBatch(16)
|
| |
ParquetExec: limit=None,
partitions=[/home/remziy/Downloads/data/2021-11.parquet]
```
This is a little amazing for me. Without `count(*)`, datafusion will
replace `count distinct` by firstly doing hash aggregate on `stop_name`
(generate `alias1`) and then `count `directly.
After debugging, I find that with `count(*)`, we will use
`DistinctCountAccumulator` and without `count(*)`, we use `CountAccumulator`
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]