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

Pagination Phase 2: Support ORDER BY clauses and queries without FROM. #1599

Merged
merged 3 commits into from
Jun 15, 2023

Conversation

Yury-Fridlyand
Copy link
Collaborator

@Yury-Fridlyand Yury-Fridlyand commented May 2, 2023

Pagination in V2: Phase 2. See Phase 1 in #1497.

Doc: https://github.com/Bit-Quill/opensearch-project-sql/blob/61767f2b200b2a7f8c8b2df32de209b3c30caa61/docs/dev/Pagination-v2.md

This PR depends on #1500.

curl -XPOST http://localhost:9200/_plugins/_sql -H 'Content-Type: application/json' -d '{"query": "select * from calcs order by int0, num1;", "fetch_size": 3 }'

You can use attached script for testing as well. Command line: ./cursor_test.sh <table> <page size>. Requires jq. Rename the script before use.
cursor_test.sh.txt

Description

Add support for more complex queries in paged requests.
Supported things:

  • GROUP BY clause
  • queries without FROM clause

Unsupported things:

Issues Resolved

Support of ORDER BY clause and support queries without FROM clause.

Check List

  • New functionality includes testing.
    • All tests pass, including unit test, integration test and doctest
  • New functionality has been documented.
    • New functionality has javadoc added
    • New functionality has user manual doc added
  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@codecov-commenter
Copy link

codecov-commenter commented May 2, 2023

Codecov Report

Merging #1599 (5b75395) into main (29f99aa) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@            Coverage Diff            @@
##               main    #1599   +/-   ##
=========================================
  Coverage     97.31%   97.31%           
- Complexity     4372     4375    +3     
=========================================
  Files           385      385           
  Lines         10847    10850    +3     
  Branches        763      765    +2     
=========================================
+ Hits          10556    10559    +3     
  Misses          284      284           
  Partials          7        7           
Flag Coverage Δ
sql-engine 97.31% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...ch/sql/executor/pagination/CanPaginateVisitor.java 100.00% <100.00%> (ø)
...org/opensearch/sql/planner/DefaultImplementor.java 100.00% <100.00%> (ø)

Base automatically changed from feature/pagination/integ to main May 30, 2023 21:44
@penghuo penghuo added the pagination Pagination feature, ref #656 label Jun 8, 2023
@Yury-Fridlyand Yury-Fridlyand force-pushed the feature/pagination/limit-and-orderby branch from 547a199 to 1872e00 Compare June 10, 2023 04:23
@Yury-Fridlyand Yury-Fridlyand changed the title Support LIMIT, ORDER BY clauses in pagination and queries without FROM. Support ORDER BY clauses in pagination and queries without FROM. Jun 10, 2023
@Yury-Fridlyand Yury-Fridlyand marked this pull request as ready for review June 10, 2023 04:24
@anirudha
Copy link
Collaborator

Thanks!

Signed-off-by: Yury-Fridlyand <[email protected]>
@Yury-Fridlyand Yury-Fridlyand changed the title Support ORDER BY clauses in pagination and queries without FROM. Pagination Phase 2: Support ORDER BY clauses and queries without FROM. Jun 14, 2023
forestmvey
forestmvey previously approved these changes Jun 14, 2023
GumpacG
GumpacG previously approved these changes Jun 14, 2023
@Yury-Fridlyand Yury-Fridlyand dismissed stale reviews from GumpacG and forestmvey via 5b75395 June 15, 2023 04:39
@@ -68,14 +67,24 @@ public Boolean visitRelation(Relation node, Object context) {
return Boolean.TRUE;
}

private Boolean canPaginate(Node node, Object context) {
protected Boolean canPaginate(Node node, Object context) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

why?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I had a test which uses (overrides) it, but it become irrelevant after merging with #1500.

@Yury-Fridlyand Yury-Fridlyand merged commit 94d5479 into main Jun 15, 2023
@Yury-Fridlyand Yury-Fridlyand deleted the feature/pagination/limit-and-orderby branch June 15, 2023 17:11
@opensearch-trigger-bot
Copy link
Contributor

The backport to 2.x failed:

The process '/usr/bin/git' failed with exit code 1

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-2.x 2.x
# Navigate to the new working tree
cd .worktrees/backport-2.x
# Create a new branch
git switch --create backport/backport-1599-to-2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 94d5479522ba5ae83645c4169d6cc44a38b720de
# Push it to GitHub
git push --set-upstream origin backport/backport-1599-to-2.x
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-2.x

Then, create a pull request where the base branch is 2.x and the compare/head branch is backport/backport-1599-to-2.x.

@Yury-Fridlyand
Copy link
Collaborator Author

Will restart backport after merging #1741

opensearch-trigger-bot bot pushed a commit that referenced this pull request Jun 15, 2023
…ROM`. (#1599)

* Support `ORDER BY` clauses in pagination and queries without `FROM`.

Signed-off-by: Yury-Fridlyand <[email protected]>

* Fix IT.

Signed-off-by: Yury-Fridlyand <[email protected]>

---------

Signed-off-by: Yury-Fridlyand <[email protected]>
(cherry picked from commit 94d5479)
Yury-Fridlyand added a commit that referenced this pull request Jun 16, 2023
…ROM`. (#1599) (#1745)

* Support `ORDER BY` clauses in pagination and queries without `FROM`.

Signed-off-by: Yury-Fridlyand <[email protected]>

* Fix IT.

Signed-off-by: Yury-Fridlyand <[email protected]>

---------

Signed-off-by: Yury-Fridlyand <[email protected]>
(cherry picked from commit 94d5479)

Co-authored-by: Yury-Fridlyand <[email protected]>
@acarbonetto acarbonetto added the v2.9.0 v2.9.0 label Jul 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport 2.x pagination Pagination feature, ref #656 v2.9.0 v2.9.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants