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

add TakeOrderedOperator #2863

Merged
merged 11 commits into from
Aug 5, 2024

Conversation

qianheng-aws
Copy link
Contributor

@qianheng-aws qianheng-aws commented Jul 26, 2024

Description

add TakeOrderedOperator

Issues Resolved

#2857

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.

Signed-off-by: Heng Qian <qianheng@amazon.com>
Signed-off-by: Heng Qian <qianheng@amazon.com>
Signed-off-by: Heng Qian <qianheng@amazon.com>
Signed-off-by: Heng Qian <qianheng@amazon.com>
Signed-off-by: Heng Qian <qianheng@amazon.com>
Signed-off-by: Heng Qian <qianheng@amazon.com>
penghuo
penghuo previously approved these changes Aug 2, 2024
Copy link
Collaborator

@penghuo penghuo left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for the change!
@dai-chen please take a look.

this.sortList = sortList;
this.limit = limit;
this.offset = offset;
this.ordering = SortHelper.constructExprOrdering(sortList);
Copy link
Collaborator

@penghuo penghuo Aug 2, 2024

Choose a reason for hiding this comment

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

good job on simpification!

Signed-off-by: Heng Qian <qianheng@amazon.com>
…redOperator

# Conflicts:
#	docs/user/optimization/optimization.rst
Signed-off-by: Heng Qian <qianheng@amazon.com>
assertThat(
execute(
takeOrdered(
inputPlan, 2, 1, Pair.of(SortOption.DEFAULT_ASC, ref("response", INTEGER)))),
Copy link
Member

Choose a reason for hiding this comment

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

Could you add a test which its limit equals its offset?

Copy link
Contributor Author

@qianheng-aws qianheng-aws Aug 2, 2024

Choose a reason for hiding this comment

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

Oh, it comes to me that we may not need to do that test since Limit(offset, limit) in OpenSearch has different semantics with other engine. For OpenSearch, limit stands for the size of HEAD and offset stands for the from of HEAD.
So it will always return limit rows no matter which value offset is.
e.g.

POST _plugins/_ppl
{
  "query": """
    source=opensearch_dashboards_sample_data_flights| fields FlightTimeMin | head 2 from 2
  """
}

# response
{
  "schema": [
    {
      "name": "FlightTimeMin",
      "type": "float"
    }
  ],
  "datarows": [
    [
      0
    ],
    [
      222.74905
    ]
  ],
  "total": 2,
  "size": 2
}

Copy link
Member

@LantaoJin LantaoJin Aug 2, 2024

Choose a reason for hiding this comment

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

So it will always return limit rows no matter which value offset is.

Will skip(offset) in open() method of TakeOrderedOperator change the current behavior?
Nice to have a test to compare the results between take-ordered and limit+head.

Copy link
Contributor Author

@qianheng-aws qianheng-aws Aug 2, 2024

Choose a reason for hiding this comment

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

Sorry, it's not exact right to say it will always return limit rows no matter which value offset is actually. It's right only when the size of input rows is no less than offset + limit.

I think skip(offset) is semantic equal to what LimitOperator do in its open(). You can see the expected results for each UT, I've add different limit, offset cases for each sort options. But I'll add one more test to verify that's also what sort + limit will produce.

…limit

Signed-off-by: Heng Qian <qianheng@amazon.com>
Signed-off-by: Heng Qian <qianheng@amazon.com>
Copy link
Collaborator

@dai-chen dai-chen left a comment

Choose a reason for hiding this comment

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

Thanks for the changes!

In future, I think it'd great to have micro-benchmark in benchmarks module to demonstrate such improvements.

Copy link
Member

@LantaoJin LantaoJin left a comment

Choose a reason for hiding this comment

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

LGTM

@penghuo penghuo merged commit 0e70a50 into opensearch-project:main Aug 5, 2024
14 checks passed
opensearch-trigger-bot bot pushed a commit that referenced this pull request Aug 5, 2024
---------
Signed-off-by: Heng Qian <qianheng@amazon.com>
(cherry picked from commit 0e70a50)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
LantaoJin pushed a commit that referenced this pull request Aug 7, 2024
* add TakeOrderedOperator (#2863)

---------
Signed-off-by: Heng Qian <qianheng@amazon.com>
(cherry picked from commit 0e70a50)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

* Make it compatible with java11

Signed-off-by: Heng Qian <qianheng@amazon.com>

---------

Signed-off-by: Heng Qian <qianheng@amazon.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
manasvinibs pushed a commit to manasvinibs/sql that referenced this pull request Aug 14, 2024
---------
Signed-off-by: Heng Qian <qianheng@amazon.com>
jzonthemtn pushed a commit to jzonthemtn/sql that referenced this pull request Aug 28, 2024
---------
Signed-off-by: Heng Qian <qianheng@amazon.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants