-
Notifications
You must be signed in to change notification settings - Fork 29k
[WIP][Spark-SQL] Optimize the Constant Folding for Expression #482
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
Closed
chenghao-intel
wants to merge
13
commits into
apache:master
from
chenghao-intel:optimize_constant_folding
Closed
Changes from 1 commit
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
2645d4f
Constant Folding(null propagation)
chenghao-intel 3c045c7
Optimize the Constant Folding by adding more rules
chenghao-intel 536c005
Add Exceptional case for constant folding
chenghao-intel 9cf0396
update code according to the code review comment
chenghao-intel 543ef9d
fix code style issues
chenghao-intel 9ccefdb
Add tests for optimized expression evaluation.
marmbrus b28e03a
Merge pull request #1 from marmbrus/pr/482
chenghao-intel 27ea3d7
Fix Constant Folding Bugs & Add More Unittests
chenghao-intel 80f9f18
Update the UnitTest for aggregation constant folding
chenghao-intel 50444cc
Remove the unnecessary null checking
chenghao-intel 29c8166
Update the code for feedback of code review
chenghao-intel 68b9fad
Remove the Literal pattern matching for NullPropagation
chenghao-intel 2f14b50
Fix code style issues
chenghao-intel 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
Remove the Literal pattern matching for NullPropagation
- Loading branch information
commit 68b9fad66b499e667c827a1a0bb1ef8dccaa813e
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -94,8 +94,6 @@ object ColumnPruning extends Rule[LogicalPlan] { | |
| object NullPropagation extends Rule[LogicalPlan] { | ||
| def apply(plan: LogicalPlan): LogicalPlan = plan transform { | ||
| case q: LogicalPlan => q transformExpressionsUp { | ||
| // Skip redundant folding of literals. | ||
| case l: Literal => l | ||
| case e @ Count(Literal(null, _)) => Literal(0, e.dataType) | ||
| case e @ Sum(Literal(c, _)) if(c == 0) => Literal(0, e.dataType) | ||
|
Contributor
Author
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. Not like the previous implementation, I didn't add the null value as Child expression for both Sum and Average in the rule, cause Hive will throw semantic exception. |
||
| case e @ Average(Literal(c, _)) if(c == 0) => Literal(0.0, e.dataType) | ||
|
|
||
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.
Do we want
Up? I believe this means we are going to call evaluate on each foldable node working up instead of just calling it once at the top.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.
expression.foldableis ok by traveling from top to bottom, while null propagation is opposite. I've put them into different rule objects (ConstantFolding & NullPropagation).