Skip to content
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

[Internal] Query: Adds support for continuation using SqlQuerySpec #3774

Merged

Conversation

balaperu
Copy link
Contributor

@balaperu balaperu commented Mar 22, 2023

Pull Request Template

Description

Currently, supporting continuation for cross partition order by requires us to re-write the queries filter to resume from the last returned order by value. This approach of re-writing filters is very cumbersome for multi-item order by and this approach doesn't work when the continuation value is an array or object.

The new approach is to send the resume value as part of SqlQuerySpec to backend which uses it to resume the query. The backend changes have already been checked in and is currently being deployed.

Current OrderByContinuationToken:

{ 
   "compositeToken":{
           "token":"+RID:OpY0AN-mFAACAAAAAAAABA==#RT:1#TRC:1#RTD:qdTAEA==",
            "range":{"min":"05C1D9CD673398","max":"05C1E399CD6732"}
   },
   "orderByItems"[{"item":2}],
   "rid":"OpY0AN-mFAACAAAAAAAABA==",
   "skipCount":1,
   "filter":"r.key > 1"
}

New Token:
Contains resumeValues instead of orderByItems.

{
   "compositeToken":{
           "token":"+RID:OpY0AN-mFAACAAAAAAAABA==#RT:1#TRC:1#RTD:qdTAEA==",
            "range":{"min":"05C1D9CD673398","max":"05C1E399CD6732"}
   },
   "resumeValues":[2],
   "rid":"OpY0AN-mFAACAAAAAAAABA==",
   "skipCount":1,
}

Undefined values are represented by an empty array "[]"

Array and Object are represented in resume value by their hash value

{
    "type":  <"array" / "object">
    "low": <UINT128.Low>
    "high": <UINT128.High>
}

Old continuation tokens with orderByItems will be converted to SqlQuerySpec ResumeValue during pipeline create stage.

ResumeValue doesn't support C* types so the old continuation token format will be used for these types.

Type of change

  • [] New feature (non-breaking change which adds functionality)

Closing issues

#3639

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All good!

sboshra
sboshra previously approved these changes Aug 22, 2023
Copy link
Contributor

@sboshra sboshra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

…ived objects.

update cosmosundefinedquerytests. other code review comments.
Bala Perumalswamy added 4 commits August 25, 2023 16:31
…esume value. unit tests for SqlQueryResumeValue.
…r by and group by tests. reducing the document count to reduce execution time.
…etter symmetry for comparing arrays and objects.
neildsh
neildsh previously approved these changes Sep 5, 2023
Copy link
Contributor

@neildsh neildsh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@balaperu balaperu changed the title [Internal] Query: Support continuation using SqlQuerySpec [Internal] Query: Adds support for continuation using SqlQuerySpec Feb 6, 2024
Copy link
Contributor

@sboshra sboshra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@adityasa adityasa added the auto-merge Enables automation to merge PRs label Feb 13, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot merged commit cba93d3 into master Feb 13, 2024
20 checks passed
@microsoft-github-policy-service microsoft-github-policy-service bot deleted the users/balaperu/query_spec_continuation branch February 13, 2024 20:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-merge Enables automation to merge PRs QUERY
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants