alamb commented on code in PR #6904:
URL: https://github.com/apache/arrow-datafusion/pull/6904#discussion_r1259593868
##########
datafusion/physical-expr/src/aggregate/count.rs:
##########
@@ -76,6 +85,109 @@ impl Count {
}
}
+/// An accumulator to compute the counts of [`PrimitiveArray<T>`].
+/// Stores values as native types, and does overflow checking
+///
+/// Unlike most other accumulators, COUNT never produces NULLs. If no
+/// non-null values are seen in any group the output is 0. Thus, this
+/// accumulator has no additional null or seen filter tracking.
+#[derive(Debug)]
+struct CountGroupsAccumulator {
+ /// Count per group (use i64 to make Int64Array)
+ counts: Vec<i64>,
Review Comment:
I looked into this some more. The reason this count is `i64` is because the
output of `COUNT` is defined to be `DataType::Int64` and thus by using an i64
the output can be created directly. I will add a comment to clarify
```sql
❯ create table foo as values (1);
0 rows in set. Query took 0.004 seconds.
❯ select arrow_typeof(count(*)) from foo;
+-------------------------------+
| arrow_typeof(COUNT(UInt8(1))) |
+-------------------------------+
| Int64 |
+-------------------------------+
1 row in set. Query took 0.004 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]