You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Clustered aggregation: release retained capacity before failing or spilling when no group is complete #26911
Is your feature request related to a problem or challenge?
When a clustered aggregate stream (partial, final or single, with full group clustering) fails to grow its reservation, it first emits the completed groups and then calls ClusteredAggregateTable::shrink_to_fit (#26726, #26782). If no group is complete, for example when one key spans the whole batch, the stream returns ResourcesExhausted (partial), or spills or errors (final/single) without shrinking. Shrinking alone could make the reservation fit, because the table still holds capacity it grew for the batch, such as the per-batch accumulator scratch.
For example, a partial APPROX_DISTINCT(v) GROUP BY k over three 8192-row batches of a single key fails a 64 KiB limit asking for 132.1 KB, although the table holds about 4.3 KB after shrink_to_fit.
On a refused reservation with no completed group, call shrink_to_fit and retry the reservation before returning the error or spilling. The existing memory_pressure_without_completed_groups tests in the final and single streams would need to reflect this.
Describe alternatives you've considered
Bound the per-batch scratch itself, for example by hashing in fixed-size chunks in HllGroupsAccumulator, which also avoids regrowing the scratch for every batch under sustained pressure.
Activity