GitHub user scwf opened a pull request:
https://github.com/apache/spark/pull/5821
[SPARK-7289] [SQL] CombineLimits improvement: push down sort when it's
child is Limit
Optimize following sql
`select key from (select * from testData limit 5) t order by key limit 5`
before this PR:
```
== Parsed Logical Plan ==
'Limit 5
'Sort ['key ASC], true
'Project ['key]
'Subquery t
'Limit 5
'Project [*]
'UnresolvedRelation [testData], None
== Analyzed Logical Plan ==
Limit 5
Sort [key#0 ASC], true
Project [key#0]
Subquery t
Limit 5
Project [key#0,value#1]
Subquery testData
LogicalRDD [key#0,value#1], MapPartitionsRDD[1]
== Optimized Logical Plan ==
Limit 5
Sort [key#0 ASC], true
Project [key#0]
Limit 5
LogicalRDD [key#0,value#1], MapPartitionsRDD[1]
== Physical Plan ==
TakeOrdered 5, [key#0 ASC]
Project [key#0]
Limit 5
PhysicalRDD [key#0,value#1], MapPartitionsRDD[1]
```
after this PR
```
== Parsed Logical Plan ==
'Limit 5
'Sort ['key ASC], true
'Project ['key]
'Subquery t
'Limit 5
'Project [*]
'UnresolvedRelation [testData], None
== Analyzed Logical Plan ==
Limit 5
Sort [key#0 ASC], true
Project [key#0]
Subquery t
Limit 5
Project [key#0,value#1]
Subquery testData
LogicalRDD [key#0,value#1], MapPartitionsRDD[1]
== Optimized Logical Plan ==
Limit 5
Sort [key#0 ASC], true
Project [key#0]
LogicalRDD [key#0,value#1], MapPartitionsRDD[1]
== Physical Plan ==
TakeOrdered 5, [key#0 ASC]
Project [key#0]
PhysicalRDD [key#0,value#1], MapPartitionsRDD[1]
```
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/scwf/spark limit
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/spark/pull/5821.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #5821
----
commit 494cc25eb9b51b1333e5ba95082be6568e17ee20
Author: scwf <[email protected]>
Date: 2015-04-30T23:23:39Z
push down sort when it's child is Limit
----
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]