-
Notifications
You must be signed in to change notification settings - Fork 179
Merge OpenSearchPagedIndexScan and OpenSearchIndexScan #1600
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
Changes from 20 commits
68db706
ef93375
306a7fe
7d5b126
dc2c471
91cea61
2ee810c
39ce902
fabd4ee
6eb0498
bdfe563
1f6b6f1
a8295e4
86429f8
4f5b69d
b1050dd
a16f2fa
eff76b2
8548d90
f4770a8
e350662
413087a
7e812e5
1daacbb
f1e1342
73f18df
60226be
fabb179
23bc3ab
264e483
97ef3a5
2cecaca
840c4a9
4c9e958
102706b
2f4b48b
33ad6dd
0abe298
1dc3320
701bce7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -41,6 +41,7 @@ | |||||
| import org.opensearch.sql.ast.statement.Statement; | ||||||
| import org.opensearch.sql.ast.tree.AD; | ||||||
| import org.opensearch.sql.ast.tree.Aggregation; | ||||||
| import org.opensearch.sql.ast.tree.Cursor; | ||||||
| import org.opensearch.sql.ast.tree.Dedupe; | ||||||
| import org.opensearch.sql.ast.tree.Eval; | ||||||
| import org.opensearch.sql.ast.tree.Filter; | ||||||
|
|
@@ -299,4 +300,8 @@ public T visitExplain(Explain node, C context) { | |||||
| public T visitPaginate(Paginate paginate, C context) { | ||||||
| return visitChildren(paginate, context); | ||||||
| } | ||||||
|
|
||||||
| public T visitCursor(Cursor cursor, C context) { | ||||||
| return visit(cursor, context); | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit
Suggested change
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. lave for later |
||||||
| } | ||||||
| } | ||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| package org.opensearch.sql.ast.tree; | ||
Yury-Fridlyand marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| import lombok.Getter; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.opensearch.sql.ast.AbstractNodeVisitor; | ||
|
|
||
| @RequiredArgsConstructor | ||
| public class Cursor extends UnresolvedPlan { | ||
Yury-Fridlyand marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| @Getter | ||
| final String cursor; | ||
|
|
||
| @Override | ||
| public <T, C> T accept(AbstractNodeVisitor<T, C> nodeVisitor, C context) { | ||
| return nodeVisitor.visitCursor(this, context); | ||
| } | ||
|
|
||
| @Override | ||
| public UnresolvedPlan attach(UnresolvedPlan child) { | ||
| throw new UnsupportedOperationException("Cursor unresolved plan does not support children"); | ||
| } | ||
| } | ||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| package org.opensearch.sql.planner; | ||
Yury-Fridlyand marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
Yury-Fridlyand marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| import java.util.List; | ||
| import lombok.Getter; | ||
| import org.opensearch.sql.planner.logical.LogicalPlan; | ||
| import org.opensearch.sql.planner.logical.LogicalPlanNodeVisitor; | ||
|
|
||
| public class LogicalCursor extends LogicalPlan { | ||
Yury-Fridlyand marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| @Getter | ||
| final String cursor; | ||
|
|
||
| public LogicalCursor(String cursor) { | ||
| super(List.of()); | ||
| this.cursor = cursor; | ||
| } | ||
|
|
||
| @Override | ||
| public <R, C> R accept(LogicalPlanNodeVisitor<R, C> visitor, C context) { | ||
| return visitor.visitCursor(this, context); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,7 +13,6 @@ | |
| import java.util.List; | ||
| import java.util.stream.Collectors; | ||
| import org.opensearch.sql.planner.logical.LogicalPlan; | ||
| import org.opensearch.sql.planner.optimizer.rule.CreatePagingTableScanBuilder; | ||
| import org.opensearch.sql.planner.optimizer.rule.MergeFilterAndFilter; | ||
| import org.opensearch.sql.planner.optimizer.rule.PushFilterUnderSort; | ||
| import org.opensearch.sql.planner.optimizer.rule.read.CreateTableScanBuilder; | ||
|
|
@@ -52,7 +51,7 @@ public static LogicalPlanOptimizer create() { | |
| * Phase 2: Transformations that rely on data source push down capability | ||
| */ | ||
| new CreateTableScanBuilder(), | ||
| new CreatePagingTableScanBuilder(), | ||
| new PushDownPageSize(), | ||
|
||
| TableScanPushDown.PUSH_DOWN_FILTER, | ||
| TableScanPushDown.PUSH_DOWN_AGGREGATION, | ||
| TableScanPushDown.PUSH_DOWN_SORT, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| /* | ||
| * Copyright OpenSearch Contributors | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| package org.opensearch.sql.planner.optimizer; | ||
|
|
||
| import com.facebook.presto.matching.Captures; | ||
| import com.facebook.presto.matching.Pattern; | ||
| import java.util.ArrayDeque; | ||
| import java.util.Deque; | ||
| import java.util.Optional; | ||
| import org.opensearch.sql.planner.logical.LogicalPaginate; | ||
| import org.opensearch.sql.planner.logical.LogicalPlan; | ||
| import org.opensearch.sql.storage.read.TableScanBuilder; | ||
|
|
||
| /** | ||
| * A {@link LogicalPlanOptimizer} rule that pushes down page size | ||
| * to table scan builder. | ||
| */ | ||
| public class PushDownPageSize implements Rule<LogicalPaginate> { | ||
MaxKsyunz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| @Override | ||
| public Pattern<LogicalPaginate> pattern() { | ||
| return Pattern.typeOf(LogicalPaginate.class) | ||
| .matching(lp -> findTableScanBuilder(lp).isPresent()); | ||
| } | ||
|
|
||
| @Override | ||
| public LogicalPlan apply(LogicalPaginate plan, Captures captures) { | ||
|
|
||
| var builder = findTableScanBuilder(plan).orElseThrow(); | ||
| if (!builder.pushDownPageSize(plan)) { | ||
| throw new IllegalStateException("Failed to push down LogicalPaginate"); | ||
| } | ||
| return plan.getChild().get(0); | ||
| } | ||
|
|
||
| private Optional<TableScanBuilder> findTableScanBuilder(LogicalPaginate logicalPaginate) { | ||
| Deque<LogicalPlan> plans = new ArrayDeque<>(); | ||
| plans.add(logicalPaginate); | ||
| do { | ||
| final var plan = plans.removeFirst(); | ||
|
||
| final var children = plan.getChild(); | ||
| if (children.stream().anyMatch(TableScanBuilder.class::isInstance)) { | ||
| if (children.size() > 1) { | ||
| throw new UnsupportedOperationException( | ||
| "Unsupported plan: relation operator cannot have siblings"); | ||
| } | ||
| return Optional.of((TableScanBuilder) children.get(0)); | ||
| } | ||
| plans.addAll(children); | ||
| } while (!plans.isEmpty()); | ||
| return Optional.empty(); | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.