Use a streaming group fold for exact typed duql aggregates
DecisionVerified 30 Sep 2026Holds project: dftracer-utils
Decision. The context, the choice, why, and the options that were turned down. Context#
count_distinct, collect, arg_max, arg_min, sketch and merge need exact counts, typed values and input-order tie handling.
Decision#
Run these aggregates in duql/group_fold.{h,cpp} on the dataframe-library side. Feed engine aggregates from the same scan.
Why#
The existing engine aggregate kinds do not provide those semantics. This decision is recorded in observer inbox 5f2574cd39.
Rejected options#
Engine Distinct is approximate. ArgMax and ArgMin return a string representation. ListSorted returns list rather than the required typed values. Also found by searching
- count_distinct in duql returns approximate count, arg_max returns string
- typed aggregates like collect and arg_min give wrong types or inexact results
- how should exact typed aggregates count_distinct collect sketch merge be implemented
- engine Distinct approximate, ListSorted list<string>, use group_fold streaming
- duql count_distinct returns approximate count, need exact typed results
- arg_max arg_min return string representation instead of typed value in aggregates
- why not use engine Distinct, ArgMax and ListSorted aggregates for duql collect and sketch?
- group_fold exact aggregates tie handling input order