-
Notifications
You must be signed in to change notification settings - Fork 315
cosmos: Allow the Query Pipeline to return an alternative query to execute in each request #3166
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
cosmos: Allow the Query Pipeline to return an alternative query to execute in each request #3166
Conversation
I'm actually going to do a few other optimizations to the Query Engine API and open a new PR soon |
Ok, I've added two more optimizations that I've been meaning to add to this API:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR enhances the Cosmos DB query pipeline to support alternative queries for each request, enabling features like Hybrid Search and ReadMany operations. Instead of replaying the original query for each partition, the pipeline can now direct the SDK to execute different queries with optional parameter inheritance.
- Modified query pipeline and executor to support optional query overrides per request
- Added configuration for including/excluding original parameters with alternative queries
- Enhanced mock query engine infrastructure for comprehensive testing
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
sdk/cosmos/azure_data_cosmos/src/query/engine.rs | Extended QueryRequest and QueryResult structures with new fields for query overrides, parameter inclusion, and request ordering |
sdk/cosmos/azure_data_cosmos/src/query/executor.rs | Updated executor to handle alternative queries and parameter inheritance logic |
sdk/cosmos/azure_data_cosmos/src/query/mod.rs | Added method to copy parameters between Query instances |
sdk/cosmos/azure_data_cosmos/tests/framework/query_engine.rs | Enhanced mock infrastructure with query override configuration and request ordering validation |
sdk/cosmos/azure_data_cosmos/tests/query_engine.rs | Added comprehensive test cases for query override scenarios |
sdk/cosmos/azure_data_cosmos/tests/cosmos_query.rs | Updated error handling test to use newer API pattern |
sdk/cosmos/azure_data_cosmos/src/clients/cosmos_client.rs | Fixed documentation example to use Secret wrapper |
API Change CheckAPIView identified API level changes in this PR and created the following API reviews |
@analogrelay Could you please push a small change to this PR? That should unblock the CI pipeline which was accidentally included. |
Can do! Sorry about the delay, got pulled on to high-pri stuff ;). |
7d128e5
to
6d42511
Compare
For Hybrid Search, as well as ReadMany support, the query engine will need to direct the SDK to issue multiple different queries. However, the Rust SDK's query executor expects to be able to replay the original query on each request. This PR changes that expectation to allow (but not require) each Query Request coming from the pipeline to provide an alternate query. When an alternate query is provided, the pipeline can also indicate if the parameters from the original query should be sent. Often, the alternate query does NOT use the parameters, but in some circumstances (hybrid search) it will.
There are also some small fixes for doc tests and error checking in the engine-less cross-partition query tests. Not sure why these are coming up here and not in
main
.