Skip to content

Support non-streaming ORDER BY queries #4755

Description

@tvaron3

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    ClientThis issue points to a problem in the data-plane of the library.CosmosThe azure_cosmos crate

    Type

    No type

    Projects

    Status
    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions