-
Notifications
You must be signed in to change notification settings - Fork 264
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
feat: Explain command support #444
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
21775ab
WIP: explain command support
jiashenC 6402090
update logical->physical rules and executors
jiashenC 137ca82
minor fix for explain internal execution
jiashenC 175ee9d
update after rebase
jiashenC d194c1b
fix errors
jiashenC d9e0493
fix lint errors
jiashenC 181a858
trigger prehook
jiashenC 35c28f4
trigger prehook after reformatting
jiashenC cdd09be
fix test cases by dropping tables
jiashenC 1b05445
Merge branch 'master' of github.com:georgia-tech-db/eva into explain-cmd
gaurav274 d5559d1
test: add test cases
gaurav274 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# coding=utf-8 | ||
# Copyright 2018-2022 EVA | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License 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. | ||
import pandas as pd | ||
|
||
from eva.executor.abstract_executor import AbstractExecutor | ||
from eva.models.storage.batch import Batch | ||
from eva.planner.abstract_plan import AbstractPlan | ||
from eva.planner.explain_plan import ExplainPlan | ||
|
||
|
||
class ExplainExecutor(AbstractExecutor): | ||
def __init__(self, node: ExplainPlan): | ||
super().__init__(node) | ||
|
||
def validate(self): | ||
pass | ||
|
||
def exec(self): | ||
# Traverse optimized physical plan, which is commonly supported. | ||
# Logical plan can be also printted by passing explainable_opr | ||
# attribute of the node, but is not done for now. | ||
plan_str = self._exec(self._node.children[0], 0) | ||
yield Batch(pd.DataFrame([plan_str])) | ||
|
||
def _exec(self, node: AbstractPlan, depth: int): | ||
cur_str = " " * depth * 4 + "|__ " + str(node.__class__.__name__) + "\n" | ||
for child in node.children: | ||
cur_str += self._exec(child, depth + 1) | ||
return cur_str |
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
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,38 @@ | ||
# coding=utf-8 | ||
# Copyright 2018-2022 EVA | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License 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. | ||
from eva.parser.statement import AbstractStatement | ||
from eva.parser.types import StatementType | ||
|
||
|
||
class ExplainStatement(AbstractStatement): | ||
def __init__(self, explainable_stmt: AbstractStatement): | ||
super().__init__(StatementType.EXPLAIN) | ||
self._explainable_stmt = explainable_stmt | ||
|
||
def __str__(self) -> str: | ||
print_str = "EXPLAIN {}".format(str(self._explainable_stmt)) | ||
return print_str | ||
|
||
@property | ||
def explainable_stmt(self) -> AbstractStatement: | ||
return self._explainable_stmt | ||
|
||
def __eq__(self, other): | ||
if not isinstance(other, ExplainStatement): | ||
return False | ||
return self._explainable_stmt == other.explainable_stmt | ||
|
||
def __hash__(self) -> int: | ||
return hash((super().__hash__(), self.explainable_stmt)) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# coding=utf-8 | ||
# Copyright 2018-2022 EVA | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License 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. | ||
from eva.parser.evaql.evaql_parser import evaql_parser | ||
from eva.parser.evaql.evaql_parserVisitor import evaql_parserVisitor | ||
from eva.parser.explain_statement import ExplainStatement | ||
|
||
|
||
class Explain(evaql_parserVisitor): | ||
def visitExplainStatement(self, ctx: evaql_parser.ExplainStatementContext): | ||
explainable_stmt = self.visit(ctx.explainableStatement()) | ||
return ExplainStatement(explainable_stmt) |
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right now, bind will create catalog entries. @gaurav274 This can be a consideration to move catalog operations to executors.