This repository was archived by the owner on Aug 2, 2022. It is now read-only.
-
Couldn't load subscription status.
- Fork 188
Support subquery in FROM clause in new engine #822
Merged
chloe-zh
merged 14 commits into
opendistro-for-elasticsearch:develop
from
chloe-zh:from-subquery
Nov 17, 2020
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
134efdf
support subquery in from
chloe-zh b06b8a7
update
chloe-zh cf540cc
added java doc
chloe-zh 8c84ae1
added unit test
chloe-zh 9755afd
added comparison test cases
chloe-zh ec1b49f
skipped a broken test in SubqueryIT.java due to different schema in n…
chloe-zh 3b31737
added case for issue #375
chloe-zh 38707ba
update
chloe-zh 080cf31
Merge remote-tracking branch 'upstream/develop' into from-subquery
chloe-zh 348b054
update
chloe-zh e2d4f24
address comments
chloe-zh 5599673
address comments
chloe-zh 7083bed
put the context push after subquery analysis recursion
chloe-zh c64a058
Merge remote-tracking branch 'upstream/develop' into from-subquery
chloe-zh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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
60 changes: 60 additions & 0 deletions
60
core/src/main/java/com/amazon/opendistroforelasticsearch/sql/ast/tree/RelationSubquery.java
This file contains hidden or 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,60 @@ | ||
| /* | ||
| * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"). | ||
| * You may not use this file except in compliance with the License. | ||
| * A copy of the License is located at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * or in the "license" file accompanying this file. This file is distributed | ||
| * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
| * express or implied. See the License for the specific language governing | ||
| * permissions and limitations under the License. | ||
| */ | ||
|
|
||
| package com.amazon.opendistroforelasticsearch.sql.ast.tree; | ||
|
|
||
| import com.amazon.opendistroforelasticsearch.sql.ast.AbstractNodeVisitor; | ||
| import com.amazon.opendistroforelasticsearch.sql.exception.SemanticCheckException; | ||
| import com.google.common.collect.ImmutableList; | ||
| import java.util.List; | ||
| import java.util.Locale; | ||
| import lombok.AllArgsConstructor; | ||
| import lombok.EqualsAndHashCode; | ||
| import lombok.RequiredArgsConstructor; | ||
| import lombok.ToString; | ||
|
|
||
| /** | ||
| * Logical plan node of RelationSubquery. | ||
| */ | ||
| @AllArgsConstructor | ||
| @EqualsAndHashCode(callSuper = false) | ||
| @RequiredArgsConstructor | ||
| @ToString | ||
| public class RelationSubquery extends UnresolvedPlan { | ||
| private UnresolvedPlan query; | ||
| private String alias; | ||
|
|
||
| /** | ||
| * Take subquery alias as table name. | ||
| */ | ||
| public String getAliasAsTableName() { | ||
| return alias; | ||
| } | ||
|
|
||
| @Override | ||
| public List<UnresolvedPlan> getChild() { | ||
| return ImmutableList.of(query); | ||
| } | ||
|
|
||
| @Override | ||
| public <T, C> T accept(AbstractNodeVisitor<T, C> nodeVisitor, C context) { | ||
| return nodeVisitor.visitRelationSubquery(this, context); | ||
| } | ||
|
|
||
| @Override | ||
| public UnresolvedPlan attach(UnresolvedPlan child) { | ||
| return this; | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,2 @@ | ||
| SELECT flights.TEMP1 AS a, flights.TEMP2 AS b FROM (SELECT COUNT(*) AS TEMP1, SUM(AvgTicketPrice) AS TEMP2 FROM kibana_sample_data_flights) flights | ||
| SELECT flights.origin AS a FROM (SELECT Origin AS origin, AvgTicketPrice AS price FROM kibana_sample_data_flights GROUP BY origin, price) flights |
This file contains hidden or 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,19 @@ | ||
| SELECT Origin FROM (SELECT * FROM kibana_sample_data_flights) AS f | ||
| SELECT f.Origin FROM (SELECT * FROM kibana_sample_data_flights) AS f | ||
| SELECT f.o FROM (SELECT Origin AS o FROM kibana_sample_data_flights) AS f | ||
| SELECT origin FROM (SELECT Origin AS origin, AvgTicketPrice AS price FROM kibana_sample_data_flights WHERE AvgTicketPrice > 100) AS f | ||
| SELECT origin FROM (SELECT Origin AS origin, AvgTicketPrice AS price FROM kibana_sample_data_flights) AS f WHERE f.price > 100 | ||
| SELECT origin FROM (SELECT Origin AS origin, AvgTicketPrice AS price FROM kibana_sample_data_flights) AS f WHERE price > 100 | ||
| SELECT origin FROM (SELECT Origin AS origin, AvgTicketPrice AS price FROM kibana_sample_data_flights WHERE AvgTicketPrice > 100) AS f WHERE price < 1000 | ||
| SELECT origin FROM (SELECT Origin AS origin, AvgTicketPrice AS price FROM kibana_sample_data_flights) AS f ORDER BY f.price | ||
| SELECT origin FROM (SELECT Origin AS origin, AvgTicketPrice AS price FROM kibana_sample_data_flights) AS f ORDER BY price DESC | ||
| SELECT origin, price FROM (SELECT Origin AS origin, AvgTicketPrice AS price FROM kibana_sample_data_flights GROUP BY origin, price) AS f | ||
| SELECT origin, price FROM (SELECT Origin AS origin, AvgTicketPrice AS price FROM kibana_sample_data_flights) AS f GROUP BY origin, price | ||
| SELECT origin, price FROM (SELECT Origin AS origin, Dest AS dest, AvgTicketPrice AS price FROM kibana_sample_data_flights GROUP BY origin, dest, price) AS f GROUP BY origin, price | ||
| SELECT origin, price FROM (SELECT Origin AS origin, Dest AS dest, AvgTicketPrice AS price FROM kibana_sample_data_flights GROUP BY 1, 2, 3) AS f GROUP BY 1, 2 | ||
| SELECT ABS(AvgTicketPrice) FROM (SELECT AvgTicketPrice FROM kibana_sample_data_flights) AS flights GROUP BY ABS(AvgTicketPrice) | ||
| SELECT Origin, Dest FROM (SELECT * FROM kibana_sample_data_flights WHERE AvgTicketPrice > 100 GROUP BY Origin, Dest, AvgTicketPrice) AS flights WHERE AvgTicketPrice < 1000 ORDER BY AvgTicketPrice | ||
| SELECT Origin, MIN(AvgTicketPrice) FROM (SELECT * FROM kibana_sample_data_flights) AS flights GROUP BY Origin ORDER BY MAX(AvgTicketPrice) | ||
| SELECT Origin FROM (SELECT Origin, AvgTicketPrice FROM kibana_sample_data_flights) AS flights GROUP BY Origin HAVING MIN(AvgTicketPrice) > 500 | ||
| SELECT avg_price FROM (SELECT AVG(AvgTicketPrice) AS avg_price FROM kibana_sample_data_flights) AS flights | ||
| SELECT Dest FROM (SELECT Dest, OriginWeather FROM (SELECT Dest, OriginWeather, AvgTicketPrice FROM (SELECT Dest, Origin, OriginWeather, AvgTicketPrice FROM kibana_sample_data_flights WHERE Origin = 'Zurich Airport') AS flights_data WHERE AvgTicketPrice < 10000) AS flights WHERE OriginWeather = 'Clear') AS f |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.