docs: missing documentation for aggregate _STATE combinator
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- Half a day
- Newbie friendliness
- 76/100
- Issue type
- Documentation
- Clarity
- Clearly specified
- Activity status
- Quiet
- Tech stack
- rust
- Domain
- documentation
Research direction
Start with the existing combinator documentation at docs/en/sql-reference/20-sql-functions/07-aggregate-functions/aggregate-combinators.md, then read the registration in src/query/functions/src/aggregates/aggregator.rs and implementation in src/query/functions/src/aggregates/adaptors/aggregate_combinator_state.rs. Document the _state suffix, serialized binary return type, partial-aggregation use cases, example queries, and its relationship to _merge or finalization; done means the behavior is clear to SQL users.
Written by the indexing model from the issue text.
Description
Summary
Databend registers a _state aggregate combinator suffix that allows any aggregate function to return its intermediate serialized state instead of the final result. This combinator is completely undocumented.
Source
File: src/query/functions/src/aggregates/aggregator.rs
Registration (line ~199):
factory.register_combinator("_state", AggregateStateCombinator::combinator_desc());
Implementation: src/query/functions/src/aggregates/adaptors/aggregate_combinator_state.rs
The combinator wraps any aggregate function and changes its return type to the serialized binary state of that aggregate (via serialize_data_type()), enabling incremental/partial aggregation workflows.
What it does
Appending _state to any aggregate function name returns the intermediate binary state of that aggregate rather than the final computed value. This is useful for:
- Storing partial aggregation results for later merging
- Implementing two-phase aggregation pipelines
- Passing aggregate state between queries
Example:
-- Returns the intermediate binary state of SUM, not the final sum
SELECT sum_state(number) FROM numbers(10);
-- The state can later be merged/finalized
SELECT sum_merge(state_col) FROM partial_results;
Suggested doc location
docs/en/sql-reference/20-sql-functions/07-aggregate-functions/aggregate-combinators.md
Or a dedicated page covering all three combinators (_if, _distinct, _state) as a general concept. The page should cover:
- How the
_statesuffix works - Return type (serialized binary aggregate state)
- Use cases (partial aggregation, incremental computation)
- Example queries
- Relationship to
_merge/ finalization patterns
- Dominant language
- TypeScript
- Stars
- 17
- Forks
- 44
- Avg merge
- 2d 7m
- Merged PRs (30d)
- 4
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from databendlabs/databend-docs
-
Link Checker Report Openautomated issue report
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
databendlabs/databend-docs#3504 ·
-
Link Checker Report Openautomated issue report
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
databendlabs/databend-docs#3503 ·
-
auto-fix-done documentation
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
databendlabs/databend-docs#3359 ·
-
auto-fix-done documentation
Difficulty 2/5 1-2 days Newbie friendliness 72/100
databendlabs/databend-docs#3356 ·
-
auto-fix documentation
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
databendlabs/databend-docs#3302 ·
All issues in databendlabs/databend-docs
Similar issues
-
calcite-components needs triage refactor
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Esri/calcite-design-system#15203 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 91/100
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Difficulty 1/5 Under an hour Newbie friendliness 95/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Automattic/studio#4908 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 90/100