Github user liancheng commented on the pull request:
https://github.com/apache/spark/pull/10099#issuecomment-161235263
For example, the following snippet
```scala
val path = "file:///tmp/parquet/unsafe"
(sqlContext range 10 coalesce 1).write mode "overwrite" parquet path
sqlContext.read parquet path registerTempTable "u"
sqlContext.sql("select count(*) from (select * from u where id > 3) a join
u b where a.id = b.id") explain true
```
gives the following query plan explanation, which can be (arguably) more
intuitive:
```
== Parsed Logical Plan ==
'Project [unresolvedalias((count(1),mode=Complete,isDistinct=false))]
+- 'Filter ('a.id = 'b.id)
+- 'Join Inner, None
:- 'Subquery a
: +- 'Project [unresolvedalias(*)]
: +- 'Filter ('id > 3)
: +- 'UnresolvedRelation `u`, None
+- 'UnresolvedRelation `u`, Some(b)
== Analyzed Logical Plan ==
_c0: bigint
Aggregate [(count(1),mode=Complete,isDistinct=false) AS _c0#13L]
+- Filter (id#0L = id#12L)
+- Join Inner, None
:- Subquery a
: +- Project [id#0L]
: +- Filter (id#0L > cast(3 as bigint))
: +- Subquery u
: +- Relation[id#0L]
ParquetRelation[file:/tmp/parquet/unsafe]
+- Subquery b
+- Subquery u
+- Relation[id#12L] ParquetRelation[file:/tmp/parquet/unsafe]
== Optimized Logical Plan ==
Aggregate [(count(1),mode=Complete,isDistinct=false) AS _c0#13L]
+- Project
+- Join Inner, Some((id#0L = id#12L))
:- Project [id#0L]
: +- Filter (id#0L > 3)
: +- Relation[id#0L] ParquetRelation[file:/tmp/parquet/unsafe]
+- Relation[id#12L] ParquetRelation[file:/tmp/parquet/unsafe]
== Physical Plan ==
TungstenAggregate(key=[],
functions=[(count(1),mode=Final,isDistinct=false)], output=[_c0#13L])
+- TungstenExchange SinglePartition, None
+- TungstenAggregate(key=[],
functions=[(count(1),mode=Partial,isDistinct=false)], output=[count#16L])
+- Project
+- BroadcastHashJoin [id#0L], [id#12L], BuildRight
:- Filter (id#0L > 3)
: +- Scan ParquetRelation[file:/tmp/parquet/unsafe]
PushedFilter: [GreaterThan(id,3)] [id#0L]
+- Scan ParquetRelation[file:/tmp/parquet/unsafe] PushedFilter:
[] [id#12L]
```
---
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]