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

Merge OpenSearchPagedIndexScan and OpenSearchIndexScan #1600

Conversation

MaxKsyunz
Copy link
Collaborator

@MaxKsyunz MaxKsyunz commented May 2, 2023

High-level Summary

Core Module

  • Added PushDownPageSize optimization rule to LogicalPlanOptimizer.
  • Added TableScanBuilder.pushDownPageSize method.
  • Removed Table.createPagedScanBuilder.
  • Removed CreatePagingTableScanBuilder.

opensearch Module

  • Simplified OpenSearchIndexScanQueryBuilder and OpenSearchIndexScanAggregationBuilder by removing index scan dependency.
  • OpenSearchScrollRequest.toCursor does not generate a cursor if the request needs to be cleaned up -- means OpenSearch will not send any more data.
  • Added ExecutableRequestBuilder interface that represents operations of an executable request. Used by OpenSearchIndexScan.
  • Simplified ContinuePageRequest to only implement ExecutableRequestBuilder.
  • Removed
    • InitialPageRequestBuilder,
    • OpenSearchPagedIndexScan,
    • OpenSearchPagedIndexScanBuilder,
    • PagedRequestBuilder,
    • PushDownRequestBuilder

Issues Resolved

  • Review comments on pagination PR.

Check List

  • New functionality includes testing.
    • All tests pass, including unit test, integration test and doctest
  • 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.

MaxKsyunz added 6 commits May 2, 2023 12:31
Unit tests pass, some integration tests fail.

Signed-off-by: MaxKsyunz <[email protected]>
Signed-off-by: MaxKsyunz <[email protected]>
10000 is default query size set in `integ-test/build.gradle`

Previous request builder wasn't setting size correctly for explain requests so output didn't match what was executed.

Signed-off-by: MaxKsyunz <[email protected]>
Paginated response no longer sends an empty last page. Last page of the response now lacks cursor property. This matches legacy behaviour.

Signed-off-by: MaxKsyunz <[email protected]>
When OpenSearchScrollRequest.needClean is true, the object represents the last request.

Signed-off-by: MaxKsyunz <[email protected]>
@MaxKsyunz MaxKsyunz force-pushed the feature/pagination/integ_refactor branch from 3a9c6e0 to 91cea61 Compare May 2, 2023 19:32
Signed-off-by: MaxKsyunz <[email protected]>
@codecov-commenter
Copy link

codecov-commenter commented May 2, 2023

Codecov Report

Merging #1600 (701bce7) into feature/pagination/integ (3614f88) will decrease coverage by 0.94%.
The diff coverage is 100.00%.

@@                      Coverage Diff                       @@
##             feature/pagination/integ    #1600      +/-   ##
==============================================================
- Coverage                       98.16%   97.22%   -0.94%     
- Complexity                       3306     4217     +911     
==============================================================
  Files                             287      381      +94     
  Lines                            8174    10596    +2422     
  Branches                          552      727     +175     
==============================================================
+ Hits                             8024    10302    +2278     
- Misses                            147      287     +140     
- Partials                            3        7       +4     
Flag Coverage Δ
sql-engine 97.22% <100.00%> (-0.94%) ⬇️

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

Impacted Files Coverage Δ
...java/org/opensearch/sql/executor/QueryService.java 100.00% <ø> (ø)
...search/sql/executor/pagination/PlanSerializer.java 100.00% <ø> (ø)
...a/org/opensearch/sql/planner/SerializablePlan.java 100.00% <ø> (ø)
...ch/sql/planner/optimizer/LogicalPlanOptimizer.java 100.00% <ø> (ø)
...rc/main/java/org/opensearch/sql/storage/Table.java 100.00% <ø> (ø)
...ain/java/org/opensearch/sql/analysis/Analyzer.java 100.00% <100.00%> (ø)
...earch/sql/executor/execution/QueryPlanFactory.java 100.00% <100.00%> (ø)
...org/opensearch/sql/planner/DefaultImplementor.java 100.00% <100.00%> (ø)
...search/sql/planner/logical/LogicalFetchCursor.java 100.00% <100.00%> (ø)
...opensearch/sql/planner/logical/LogicalPlanDSL.java 100.00% <100.00%> (ø)
... and 16 more

... and 83 files with indirect coverage changes

MaxKsyunz added 2 commits May 3, 2023 22:26
- Rename `getQuerySize` to `getMaxResponseSize` to reflect what
the value means.
- Create ExecutableRequestBuilder interface -- what OpenSearchIndexScan
requires from a request builder.
- Remove `PushDownRequestBuilder` interface as unnecessary

Signed-off-by: MaxKsyunz <[email protected]>
MaxKsyunz added 5 commits May 4, 2023 13:13
Signed-off-by: MaxKsyunz <[email protected]>
Refactoring fixed a small bug in explain.

Previously, explain output did not show the correct `SearchSourceBuilder.size` value
. It now does and this affected some tests.

Signed-off-by: MaxKsyunz <[email protected]>
- Inlined `OpenSearchIndexScan.create` that was only used in tests.
- Changed Function parameter of `OpenSearchIndexScanBuilder` to an
abstract method -- better describes intent.
- Renamed PushDownTranslator to PushDownQueryBuilder for better consistency.

Signed-off-by: MaxKsyunz <[email protected]>
Signed-off-by: MaxKsyunz <[email protected]>
Old name doesn't quite make sense.

Signed-off-by: MaxKsyunz <[email protected]>

@EqualsAndHashCode(callSuper = false)
@ToString
public class LogicalFetchCursor extends LogicalPlan {
Copy link
Collaborator

Choose a reason for hiding this comment

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

javadoc?

Max Ksyunz and others added 3 commits May 26, 2023 11:58
…lanDSL.java

Co-authored-by: Yury-Fridlyand <[email protected]>
Signed-off-by: Max Ksyunz <[email protected]>
…lanNodeVisitor.java

Co-authored-by: Yury-Fridlyand <[email protected]>
Signed-off-by: Max Ksyunz <[email protected]>
Signed-off-by: MaxKsyunz <[email protected]>
Copy link
Collaborator

@acarbonetto acarbonetto left a comment

Choose a reason for hiding this comment

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

Please respond to Chen/Peng on this:
OpenSearchIndex.java

return Stream.of(
relation, tableScanBuilder, write, tableWriteBuilder, filter, aggregation, rename, project,
remove, eval, sort, dedup, window, rareTopN, highlight, mlCommons, ad, ml, paginate, nested
remove, eval, sort, dedup, window, rareTopN, highlight, mlCommons, ad, ml, paginate, nested,
cursor
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: we should split this test up for each LogicalPlan node

Copy link
Collaborator

Choose a reason for hiding this comment

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

I merged this recently to avoid duplicating code in tests...

assertEquals(
project(pagedTableScanBuilder),
LogicalPlanOptimizer.create().optimize(paginate(project(relation), 4)));
assertEquals(project(tableScanBuilder), optimized);
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: we should check pagesize of 4 explicitly
or is this done already?

var builder = new OpenSearchRequestBuilder(
settings.getSettingValue(Settings.Key.QUERY_SIZE_LIMIT),
new OpenSearchExprValueFactory(allFields));
return new OpenSearchIndexScanBuilder(builder) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

MaxKsyunz added 2 commits May 29, 2023 12:39
Add comment and remove unused default constructor.

Signed-off-by: MaxKsyunz <[email protected]>
@Yury-Fridlyand
Copy link
Collaborator

Please, update PR description - for example, you don't have ExecutableRequestBuilder anymore.

Copy link
Collaborator

@Yury-Fridlyand Yury-Fridlyand left a comment

Choose a reason for hiding this comment

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

LGFM
Last few minor things left.

@MaxKsyunz MaxKsyunz merged commit 1c7233c into opensearch-project:feature/pagination/integ May 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
maintenance Improves code quality, but not the product pagination Pagination feature, ref #656
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants