-
Notifications
You must be signed in to change notification settings - Fork 524
Query: Adds support for the optimized query plan that skips the order by rewrite #5121
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
Merged
microsoft-github-policy-service
merged 6 commits into
master
from
users/ndeshpan/hybridSearchQueryPlanOpt
May 6, 2025
Merged
Query: Adds support for the optimized query plan that skips the order by rewrite #5121
microsoft-github-policy-service
merged 6 commits into
master
from
users/ndeshpan/hybridSearchQueryPlanOpt
May 6, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Merged
3 tasks
335d735 to
362766c
Compare
e148be4 to
9d90576
Compare
sboshra
reviewed
May 5, 2025
...re.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Query/Pipeline/NonStreamingOrderByQueryTests.cs
Show resolved
Hide resolved
sboshra
previously approved these changes
May 5, 2025
Contributor
sboshra
left a comment
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.
![]()
adityasa
reviewed
May 5, 2025
...ry/Core/Pipeline/CrossPartition/HybridSearch/HybridSearchCrossPartitionQueryPipelineStage.cs
Show resolved
Hide resolved
adityasa
reviewed
May 5, 2025
...re.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Query/Pipeline/NonStreamingOrderByQueryTests.cs
Show resolved
Hide resolved
1 task
Maya-Painter
approved these changes
May 6, 2025
adityasa
approved these changes
May 6, 2025
Contributor
adityasa
left a comment
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.
![]()
microsoft-github-policy-service bot
pushed a commit
that referenced
this pull request
May 6, 2025
…h to be disabled (#5171) ## Description #5120 enabled the switch to ask for the optimized query plan by default. However, the pipeline support for the optimized query plan is in #5121. This will lead to exceptions in the hybrid search query pipeline in version 3.49.0 if the SDK talks to a newer gateway that can return the optimized query plan. To prevent this, we change this optimization to be disabled by default. ## Type of change - [x] Bug fix (non-breaking change which fixes an issue) Co-authored-by: Debdatta Kunda <[email protected]>
neildsh
added a commit
that referenced
this pull request
May 6, 2025
…h to be disabled (#5171) ## Description #5120 enabled the switch to ask for the optimized query plan by default. However, the pipeline support for the optimized query plan is in #5121. This will lead to exceptions in the hybrid search query pipeline in version 3.49.0 if the SDK talks to a newer gateway that can return the optimized query plan. To prevent this, we change this optimization to be disabled by default. ## Type of change - [x] Bug fix (non-breaking change which fixes an issue) Co-authored-by: Debdatta Kunda <[email protected]>
1 task
microsoft-github-policy-service bot
pushed a commit
that referenced
this pull request
May 6, 2025
…h to be disabled (#5174) This is a cherry-pick of #5171 ## Description #5120 enabled the switch to ask for the optimized query plan by default. However, the pipeline support for the optimized query plan is in #5121. This will lead to exceptions in the hybrid search query pipeline in version 3.49.0 if the SDK talks to a newer gateway that can return the optimized query plan. To prevent this, we change this optimization to be disabled by default. ## Type of change - [x] Bug fix (non-breaking change which fixes an issue) Co-authored-by: Debdatta Kunda <[email protected]>
amanrao23
added a commit
to Azure/azure-sdk-for-js
that referenced
this pull request
May 9, 2025
…34222) ### Packages impacted by this PR @azure/cosmos ### Issues associated with this PR #34221 ### Describe the problem that is addressed by this PR 1. ***Add support for weighted RRF in hybrid search.*** We allow weights to be negative but the negative sign is used to signal that we should sort scores in ascending order for the corresponding component. The final WRRF score is then computed using the absolute value of the weight. In this approach, the sign of the weight indicates the interpretation of the ranking itself rather than directly affecting the calculated score: WRRF(d) = ∑ |w_i| × 1/(k + r_i'(d)) 2. ***Adds support for the optimized query plan*** Adds a QueryFeature that returns optimized query plan, effectively removing the need for rewriting orderByExpressions in the SDK. A flag `disableHybridSearchQueryPlanOptimization` is added to disable returning optimized query plan. This is done to ensure the query works as expected for older gateways. ### Are there test cases added in this PR? _(If not, why?)_ Yes ### Provide a list of related PRs _(if any)_ * Azure/azure-cosmos-dotnet-v3#5064 * Azure/azure-cosmos-dotnet-v3#5120 * Azure/azure-cosmos-dotnet-v3#5121 ### Command used to generate this PR:**_(Applicable only to SDK release request PRs)_ ### Checklists - [ ] Added impacted package name to the issue description - [ ] Does this PR needs any fixes in the SDK Generator?** _(If so, create an Issue in the [Autorest/typescript](https://github.com/Azure/autorest.typescript) repository and link it here)_ - [ ] Added a changelog (if necessary)
This was referenced Jul 28, 2025
Closed
This was referenced Aug 4, 2025
Closed
This was referenced Aug 19, 2025
This was referenced Sep 1, 2025
This was referenced Oct 6, 2025
This was referenced Nov 9, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Adds support for the optimized query plan that skips the order by rewrite. The new hybrid search component query plan "lies" to the SDK about there being no ORDER BY on the component queries. However, the hybrid search query pipeline stage knows that the component scores need to be sorted. Since there is no information about this sorting on the query plan anymore, the hybrid search query pipeline stage will always sort descending in this scenario. The component score projections are rewritten to safeguard this assumption.
This change is backward compatible so that the SDK can accept both the old style query plan with rewritten ORDER BY as well as the new one that skips the order by rewrite.
The end user can disable the optimized query plan by setting the environment variable
AZURE_COSMOS_HYBRID_SEARCH_QUERYPLAN_OPTIMIZATION_DISABLEDflag totrue.Type of change