Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
01e4cdf
Merge remote-tracking branch 'upstream/master'
gatorsmile Nov 13, 2015
6835704
Merge remote-tracking branch 'upstream/master'
gatorsmile Nov 14, 2015
9180687
Merge remote-tracking branch 'upstream/master'
gatorsmile Nov 14, 2015
b38a21e
SPARK-11633
gatorsmile Nov 17, 2015
d2b84af
Merge remote-tracking branch 'upstream/master' into joinMakeCopy
gatorsmile Nov 17, 2015
fda8025
Merge remote-tracking branch 'upstream/master'
gatorspark Nov 17, 2015
ac0dccd
Merge branch 'master' of https://github.com/gatorsmile/spark
gatorspark Nov 17, 2015
6e0018b
Merge remote-tracking branch 'upstream/master'
Nov 20, 2015
0546772
converge
gatorsmile Nov 20, 2015
b37a64f
converge
gatorsmile Nov 20, 2015
661260b
Merge remote-tracking branch 'upstream/master'
gatorsmile Nov 23, 2015
2dfa0fd
Merge remote-tracking branch 'upstream/master'
gatorsmile Nov 25, 2015
d929d9b
Merge remote-tracking branch 'upstream/master'
gatorsmile Nov 25, 2015
4070d2f
Merge remote-tracking branch 'upstream/master'
gatorsmile Dec 7, 2015
38dcfb2
Merge remote-tracking branch 'upstream/master'
gatorsmile Dec 9, 2015
cb3fc83
Merge remote-tracking branch 'upstream/master'
gatorsmile Dec 12, 2015
8dbacc7
Merge remote-tracking branch 'upstream/master'
gatorsmile Dec 18, 2015
41b9172
Merge remote-tracking branch 'upstream/master'
gatorsmile Dec 22, 2015
56fd782
union limit pushdown.
gatorsmile Dec 23, 2015
b5ac8d7
Merge remote-tracking branch 'upstream/master' into unionLimit
gatorsmile Dec 23, 2015
77105e3
combine the limits.
gatorsmile Dec 23, 2015
7f25d91
update the comments.
gatorsmile Dec 24, 2015
ae59f42
add a stop flag.
gatorsmile Dec 25, 2015
3ccf3bd
fixed the build failure.
gatorsmile Dec 25, 2015
004ed66
revert the changes back.
gatorsmile Dec 26, 2015
6998ec9
added limitedNumRows into the logicalPlan
gatorsmile Dec 28, 2015
09a5672
changed limitedNumRows to maxRows
gatorsmile Dec 28, 2015
358d62e
address the comments.
gatorsmile Dec 29, 2015
2823a57
addressed comments.
gatorsmile Dec 29, 2015
10d570c
Merge remote-tracking branch 'upstream/master'
gatorsmile Dec 29, 2015
cfbeea7
Merge branch 'unionLimit' into unionLimit2
gatorsmile Dec 29, 2015
ca5c104
addressed comments.
gatorsmile Dec 29, 2015
56f0c16
address the comments.
gatorsmile Dec 30, 2015
62d5cbe
update the comment.
gatorsmile Dec 30, 2015
7cf955f
update the comment.
gatorsmile Dec 30, 2015
7899312
Merge remote-tracking branch 'upstream/master' into unionLimit2
gatorsmile Dec 30, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,15 @@ object SetOperationPushDown extends Rule[LogicalPlan] with PredicateHelper {
)
)

// Push down limit into union
case Limit(exp, Union(left, right)) =>
Limit(exp,
Union(
Limit(exp, left),
Limit(exp, right)
)
)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A bug exists here. Will fix it soon. Thanks!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need a stop condition, or it will keep pushing Limit forever

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your review! Since we call CombineLimits here, we will not add extra Limit in the subsequent iteration. Thus, I think it will cause the plan change. Thus, it will stop automatically, right?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After think it more, there may be a problem: If left or right is an operator that can push Limit down(currently there is no such operator, but we can't guarantee there won't be). Then every time you push down a Limit here, it will be pushed down further. Thus the CombineLimits can NOT detect that you have already pushed the Limit down, and keeps generating new Limit and pushing it down.

I think we should have a better way to detect whether we have pushed Limit down or not, or add some comments to say that this rule assumes the newly added Limit on top of left and right won't be removed by other optimization rules.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right. Limit might not converge to the same position after multiple pushdown.

Let me think about it. Thank you!


// Push down deterministic projection through UNION ALL
case p @ Project(projectList, u @ Union(left, right)) =>
if (projectList.forall(_.deterministic)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,14 @@ class SetOperationPushDownSuite extends PlanTest {
comparePlans(exceptOptimized, exceptCorrectAnswer)
}

test("union: limit to each side") {
val unionQuery = testUnion.limit(1)
val unionOptimized = Optimize.execute(unionQuery.analyze)
val unionCorrectAnswer =
Limit(1, Union(testRelation.limit(1), testRelation2.limit(1))).analyze
comparePlans(unionOptimized, unionCorrectAnswer)
}

test("union: project to each side") {
val unionQuery = testUnion.select('a)
val unionOptimized = Optimize.execute(unionQuery.analyze)
Expand Down