-
Notifications
You must be signed in to change notification settings - Fork 28.2k
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
[SPARK-13732] [SPARK-13797] [SQL] Remove projectList from Window and Eliminate useless Window #11565
Closed
Closed
[SPARK-13732] [SPARK-13797] [SQL] Remove projectList from Window and Eliminate useless Window #11565
Changes from all commits
Commits
Show all changes
46 commits
Select commit
Hold shift + click to select a range
01e4cdf
Merge remote-tracking branch 'upstream/master'
gatorsmile 6835704
Merge remote-tracking branch 'upstream/master'
gatorsmile 9180687
Merge remote-tracking branch 'upstream/master'
gatorsmile b38a21e
SPARK-11633
gatorsmile d2b84af
Merge remote-tracking branch 'upstream/master' into joinMakeCopy
gatorsmile fda8025
Merge remote-tracking branch 'upstream/master'
gatorspark ac0dccd
Merge branch 'master' of https://github.com/gatorsmile/spark
gatorspark 6e0018b
Merge remote-tracking branch 'upstream/master'
0546772
converge
gatorsmile b37a64f
converge
gatorsmile c2a872c
Merge remote-tracking branch 'upstream/master'
gatorsmile ab6dbd7
Merge remote-tracking branch 'upstream/master'
gatorsmile 4276356
Merge remote-tracking branch 'upstream/master'
gatorsmile 2dab708
Merge remote-tracking branch 'upstream/master'
gatorsmile 0458770
Merge remote-tracking branch 'upstream/master'
gatorsmile 1debdfa
Merge remote-tracking branch 'upstream/master'
gatorsmile 763706d
Merge remote-tracking branch 'upstream/master'
gatorsmile 4de6ec1
Merge remote-tracking branch 'upstream/master'
gatorsmile 9422a4f
Merge remote-tracking branch 'upstream/master'
gatorsmile 52bdf48
Merge remote-tracking branch 'upstream/master'
gatorsmile 1e95df3
Merge remote-tracking branch 'upstream/master'
gatorsmile fab24cf
Merge remote-tracking branch 'upstream/master'
gatorsmile 8b2e33b
Merge remote-tracking branch 'upstream/master'
gatorsmile 2ee1876
Merge remote-tracking branch 'upstream/master'
gatorsmile b9f0090
Merge remote-tracking branch 'upstream/master'
gatorsmile ade6f7e
Merge remote-tracking branch 'upstream/master'
gatorsmile 9fd63d2
Merge remote-tracking branch 'upstream/master'
gatorsmile 5199d49
Merge remote-tracking branch 'upstream/master'
gatorsmile 404214c
Merge remote-tracking branch 'upstream/master'
gatorsmile c001dd9
Merge remote-tracking branch 'upstream/master'
gatorsmile 59daa48
Merge remote-tracking branch 'upstream/master'
gatorsmile 41d5f64
Merge remote-tracking branch 'upstream/master'
gatorsmile 25f6ff6
remove projectList from Window
gatorsmile 467b095
clean the comment.
gatorsmile b169236
changed the column pruning rule for Window.
gatorsmile b229ea2
style fix.
gatorsmile 472a6e3
Merge remote-tracking branch 'upstream/master'
gatorsmile 60fcafa
Merge branch 'removeProjListWindow' into removeProjListWindowNew
gatorsmile f0fbe78
address comments.
gatorsmile f8fd37f
address comments.
gatorsmile 4dd3e66
added a comment
gatorsmile 6cf6f44
eliminate useless Aggregate and Window
gatorsmile 44326f1
remove aggregate replacement.
gatorsmile fc96d84
address comments.
gatorsmile 6a59b42
address comments.
gatorsmile bd35ee7
address comments.
gatorsmile 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
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 |
---|---|---|
|
@@ -23,7 +23,8 @@ import org.apache.spark.sql.catalyst.analysis | |
import org.apache.spark.sql.catalyst.dsl.expressions._ | ||
import org.apache.spark.sql.catalyst.dsl.plans._ | ||
import org.apache.spark.sql.catalyst.encoders.ExpressionEncoder | ||
import org.apache.spark.sql.catalyst.expressions.{Ascending, Explode, Literal, SortOrder} | ||
import org.apache.spark.sql.catalyst.expressions._ | ||
import org.apache.spark.sql.catalyst.expressions.aggregate.{AggregateExpression, Complete, Count} | ||
import org.apache.spark.sql.catalyst.plans.{Inner, PlanTest} | ||
import org.apache.spark.sql.catalyst.plans.logical._ | ||
import org.apache.spark.sql.catalyst.rules.RuleExecutor | ||
|
@@ -33,7 +34,8 @@ class ColumnPruningSuite extends PlanTest { | |
|
||
object Optimize extends RuleExecutor[LogicalPlan] { | ||
val batches = Batch("Column pruning", FixedPoint(100), | ||
ColumnPruning) :: Nil | ||
ColumnPruning, | ||
CollapseProject) :: Nil | ||
} | ||
|
||
test("Column pruning for Generate when Generate.join = false") { | ||
|
@@ -258,6 +260,68 @@ class ColumnPruningSuite extends PlanTest { | |
comparePlans(optimized1, analysis.EliminateSubqueryAliases(correctAnswer1)) | ||
} | ||
|
||
test("Column pruning on Window with useless aggregate functions") { | ||
val input = LocalRelation('a.int, 'b.string, 'c.double, 'd.int) | ||
|
||
val originalQuery = | ||
input.groupBy('a, 'c, 'd)('a, 'c, 'd, | ||
WindowExpression( | ||
AggregateExpression(Count('b), Complete, isDistinct = false), | ||
WindowSpecDefinition( 'a :: Nil, | ||
SortOrder('b, Ascending) :: Nil, | ||
UnspecifiedFrame)).as('window)).select('a, 'c) | ||
|
||
val correctAnswer = input.select('a, 'c, 'd).groupBy('a, 'c, 'd)('a, 'c).analyze | ||
|
||
val optimized = Optimize.execute(originalQuery.analyze) | ||
|
||
comparePlans(optimized, correctAnswer) | ||
} | ||
|
||
test("Column pruning on Window with selected agg expressions") { | ||
val input = LocalRelation('a.int, 'b.string, 'c.double, 'd.int) | ||
|
||
val originalQuery = | ||
input.select('a, 'b, 'c, 'd, | ||
WindowExpression( | ||
AggregateExpression(Count('b), Complete, isDistinct = false), | ||
WindowSpecDefinition( 'a :: Nil, | ||
SortOrder('b, Ascending) :: Nil, | ||
UnspecifiedFrame)).as('window)).where('window > 1).select('a, 'c) | ||
|
||
val correctAnswer = | ||
input.select('a, 'b, 'c) | ||
.window(WindowExpression( | ||
AggregateExpression(Count('b), Complete, isDistinct = false), | ||
WindowSpecDefinition( 'a :: Nil, | ||
SortOrder('b, Ascending) :: Nil, | ||
UnspecifiedFrame)).as('window) :: Nil, | ||
'a :: Nil, 'b.asc :: Nil) | ||
.select('a, 'c, 'window).where('window > 1).select('a, 'c).analyze | ||
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. It's weird to see 3 selects here, we can add 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. Will do. Thanks! |
||
|
||
val optimized = Optimize.execute(originalQuery.analyze) | ||
|
||
comparePlans(optimized, correctAnswer) | ||
} | ||
|
||
test("Column pruning on Window in select") { | ||
val input = LocalRelation('a.int, 'b.string, 'c.double, 'd.int) | ||
|
||
val originalQuery = | ||
input.select('a, 'b, 'c, 'd, | ||
WindowExpression( | ||
AggregateExpression(Count('b), Complete, isDistinct = false), | ||
WindowSpecDefinition( 'a :: Nil, | ||
SortOrder('b, Ascending) :: Nil, | ||
UnspecifiedFrame)).as('window)).select('a, 'c) | ||
|
||
val correctAnswer = input.select('a, 'c).analyze | ||
|
||
val optimized = Optimize.execute(originalQuery.analyze) | ||
|
||
comparePlans(optimized, correctAnswer) | ||
} | ||
|
||
test("Column pruning on Union") { | ||
val input1 = LocalRelation('a.int, 'b.string, 'c.double) | ||
val input2 = LocalRelation('c.int, 'd.string, 'e.double) | ||
|
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
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.
move this rule near the rule that filter out useless window expressions, which makes people eaiser to understand.
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.
sure.