forked from opensearch-project/sql
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from opensearch-project/2.x
update latest changes from 2.x
- Loading branch information
Showing
86 changed files
with
3,093 additions
and
2,092 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
.../src/main/java/org/opensearch/sql/planner/optimizer/rule/read/CreateTableScanBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.opensearch.sql.planner.optimizer.rule.read; | ||
|
||
import static org.opensearch.sql.planner.optimizer.pattern.Patterns.table; | ||
|
||
import com.facebook.presto.matching.Capture; | ||
import com.facebook.presto.matching.Captures; | ||
import com.facebook.presto.matching.Pattern; | ||
import lombok.Getter; | ||
import lombok.experimental.Accessors; | ||
import org.opensearch.sql.planner.logical.LogicalPlan; | ||
import org.opensearch.sql.planner.logical.LogicalRelation; | ||
import org.opensearch.sql.planner.optimizer.Rule; | ||
import org.opensearch.sql.storage.Table; | ||
import org.opensearch.sql.storage.read.TableScanBuilder; | ||
|
||
/** | ||
* Rule that replace logical relation operator to {@link TableScanBuilder} for later | ||
* push down optimization. All push down optimization rules that depends on table scan | ||
* builder needs to run after this. | ||
*/ | ||
public class CreateTableScanBuilder implements Rule<LogicalRelation> { | ||
|
||
/** Capture the table inside matched logical relation operator. */ | ||
private final Capture<Table> capture; | ||
|
||
/** Pattern that matches logical relation operator. */ | ||
@Accessors(fluent = true) | ||
@Getter | ||
private final Pattern<LogicalRelation> pattern; | ||
|
||
/** | ||
* Construct create table scan builder rule. | ||
*/ | ||
public CreateTableScanBuilder() { | ||
this.capture = Capture.newCapture(); | ||
this.pattern = Pattern.typeOf(LogicalRelation.class) | ||
.with(table().capturedAs(capture)); | ||
} | ||
|
||
@Override | ||
public LogicalPlan apply(LogicalRelation plan, Captures captures) { | ||
TableScanBuilder scanBuilder = captures.get(capture).createScanBuilder(); | ||
// TODO: Remove this after Prometheus refactored to new table scan builder too | ||
return (scanBuilder == null) ? plan : scanBuilder; | ||
} | ||
} |
Oops, something went wrong.