Azure / Azure/azure-sdk-for-rust
Support GROUP BY and DCOUNT queries
- Dominant language
- Rust
- Stars
- 884
- Forks
- 365
- Avg merge
- 2d 19h
- Merged PRs (30d)
- 109
Description
### Feature Summary
Add production cross-partition GROUP BY and DCOUNT query execution to the Cosmos DB Rust driver.
### Feature Description
Implement full-drain grouping with per-group aggregate state and add the missing DCOUNT query-plan model and merge path.
Validation and acceptance criteria:
- Read `groupByItems` from rewritten envelopes and use structural JSON hashing/equality for group keys.
- Maintain per-group aggregate accumulators and drain all required partitions before paging grouped output.
- Initially reject external continuation tokens for GROUP BY explicitly.
- Add missing DCOUNT plan model fields and merge per-partition counts.
- Preserve SELECT VALUE and aliased output shapes for DCOUNT and grouped projections.
- Cover group-key JSON types, multiple aggregate expressions, empty groups, partition splits, and output shapes.
- Cover DCOUNT VALUE/alias forms, empty inputs, duplicate distribution across partitions, and split behavior.
### Use Case
Applications need globally correct grouped aggregates and distinct counts across all physical partitions with Cosmos-compatible projection shapes.
### Alternatives
Grouping or counting only public partition pages cannot reconstruct rewritten grouping keys, aggregate state, distinct semantics, or output shapes reliably.
### Additional Context
Implement under `sdk/cosmos/azure_data_cosmos_driver/src/driver/dataflow/`. This depends on the parent issue's `groupByItems` and aggregate envelopes, buffering limits, response transformation, continuation policy, and reusable tests; it also depends on the aggregate stage and the DISTINCT structural hash implementation. Cross-SDK references: .NET `GroupByQueryPipelineStage`, `GroupingTable`, `DCountQueryPipelineStage`, and `GroupByQueryTests`; Java `GroupByDocumentQueryExecutionContext`, `GroupingTable`, `DCountDocumentQueryExecutionContext`, and `DCountInfo`.
Contributor guide
Research direction
Start in sdk/cosmos/azure_data_cosmos_driver/src/driver/dataflow/ by reading the parent issue, aggregate stage, and DISTINCT structural-hash implementation. Compare the named .NET and Java GroupBy and DCount pipeline references, then use the reusable tests mentioned in the issue. Done means grouped and DCOUNT results merge correctly across partitions, preserve projection shapes, handle listed edge cases, and reject external GROUP BY continuation tokens.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- azure, rust
- Domain
- databases, distributed-systems
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100