Description
Optimize following sql
select key from (select * from testData order by key) t limit 5
from
== Parsed Logical Plan ==
'Limit 5
'Project ['key]
'Subquery t
'Sort ['key ASC], true
'Project [*]
'UnresolvedRelation [testData], None
== Analyzed Logical Plan ==
Limit 5
Project key#0
Subquery t
Sort key#0 ASC, true
Project key#0,value#1
Subquery testData
LogicalRDD key#0,value#1, MapPartitionsRDD[1]
== Optimized Logical Plan ==
Limit 5
Project key#0
Sort key#0 ASC, true
LogicalRDD key#0,value#1, MapPartitionsRDD[1]
== Physical Plan ==
Limit 5
Project key#0
Sort key#0 ASC, true
Exchange (RangePartitioning key#0 ASC, 5), []
PhysicalRDD key#0,value#1, MapPartitionsRDD[1]
to
== Parsed Logical Plan ==
'Limit 5
'Project ['key]
'Subquery t
'Sort ['key ASC], true
'Project [*]
'UnresolvedRelation [testData], None
== Analyzed Logical Plan ==
Limit 5
Project key#0
Subquery t
Sort key#0 ASC, true
Project key#0,value#1
Subquery testData
LogicalRDD key#0,value#1, MapPartitionsRDD[1]
== Optimized Logical Plan ==
Project key#0
Limit 5
Sort key#0 ASC, true
LogicalRDD key#0,value#1, MapPartitionsRDD[1]
== Physical Plan ==
Project key#0
TakeOrdered 5, key#0 ASC
PhysicalRDD key#0,value#1, MapPartitionsRDD[1]