Azure / Azure/azure-sdk-for-rust
Support non-streaming ORDER BY queries
- Dominant language
- Rust
- Stars
- 884
- Forks
- 365
- Avg merge
- 2d 19h
- Merged PRs (30d)
- 109
Description
### Feature Summary
Add bounded non-streaming cross-partition ORDER BY execution to the Cosmos DB Rust driver.
### Feature Description
Use the query plan's `has_non_streaming_order_by` signal to select a collect, sort, and page stage for plans that cannot use streaming ordered merge.
Validation and acceptance criteria:
- Trigger this path from `has_non_streaming_order_by`.
- Collect partition results within a configured resource limit, sort globally, and page the sorted output.
- Reuse exactly the same Cosmos multi-column comparator and deterministic tie rules as streaming ORDER BY.
- Initially reject external continuation tokens explicitly.
- Enforce a clear resource-limit failure instead of unbounded buffering.
- Support vector-score and aggregate/GROUP BY ORDER BY combinations required by query plans.
- Cover ascending/descending mixed columns, ties, empty inputs, resource exhaustion, vector scores, aggregate/GROUP BY combinations, and partition splits.
### Use Case
Applications need correct global ordering for query-plan shapes that require full buffering, including computed scores and post-aggregation ordering.
### Alternatives
Forcing these plans through streaming merge is incorrect when the ordering key is unavailable until after computation or aggregation; unbounded client-side collection is unsafe.
### Additional Context
Implement under `sdk/cosmos/azure_data_cosmos_driver/src/driver/dataflow/`. This depends on the parent issue's pipeline factory, buffering limits, envelopes, response transformation, and non-resumable continuation policy, plus the shared comparator behavior defined by streaming ORDER BY. Cross-SDK references: .NET `NonStreamingOrderByQueryTests` and the `PipelineFactory` flag path; Java `NonStreamingOrderByDocumentQueryExecutionContext`, `NonStreamingOrderByDocumentProducer`, and related utilities.
Contributor guide
Research direction
Start in sdk/cosmos/azure_data_cosmos_driver/src/driver/dataflow/ and read the parent issue's pipeline factory, buffering limits, envelopes, response transformation, and non-resumable continuation policy. Trace the has_non_streaming_order_by path and compare it with the shared streaming ORDER BY comparator; cross-check the referenced .NET and Java implementations. Done means bounded global sorting and paging, explicit rejection of external continuation tokens, and coverage of the listed ordering, aggregation, vector-score, split, empty-input, and resource-exhaustion cases.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- azure, rust
- Domain
- databases
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100