Github user hvanhovell commented on a diff in the pull request:

    https://github.com/apache/spark/pull/12720#discussion_r61382939
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/namedExpressions.scala
 ---
    @@ -337,6 +337,16 @@ case class PrettyAttribute(
       override def nullable: Boolean = true
     }
     
    +/**
    + * A place holder used to hold a reference that has been resolved to a 
field outside of the current
    + * plan. This is used for correlated subqueries.
    + */
    +case class OuterReference(e: NamedExpression) extends LeafExpression with 
Unevaluable {
    +  override def dataType: DataType = e.dataType
    +  override def nullable: Boolean = e.nullable
    +  override def prettyName: String = "outer"
    --- End diff --
    
    It will look like `outer(some ref)`, for example:
    ```
    16/04/28 09:15:11 INFO SessionState$$anon$1: 
    === Applying Rule 
org.apache.spark.sql.catalyst.analysis.Analyzer$ResolveSubquery ===
     'Project [*]                                      'Project [*]
     +- 'Filter exists#20                              +- 'Filter exists#20
    !   :  +- 'SubqueryAlias exists#20                    :  +- SubqueryAlias 
exists#20
    !   :     +- 'Project ['id]                           :     +- Project 
[id#12L]
    !   :        +- 'Filter ('id = 'a.id)                 :        +- Filter 
(id#12L = outer(id#0L))
    !   :           +- 'UnresolvedRelation `d`, None      :           +- 
SubqueryAlias d
    !   +- Join LeftOuter, Some((id#8L = id#4L))          :              +- 
Range 3, 12, 1, 8, [id#12L]
    !      :- Join Inner, Some((id#0L = id#4L))           +- Join LeftOuter, 
Some((id#8L = id#4L))
    !      :  :- SubqueryAlias a                             :- Join Inner, 
Some((id#0L = id#4L))
    !      :  :  +- Range 0, 10, 1, 8, [id#0L]               :  :- 
SubqueryAlias a
    !      :  +- SubqueryAlias b                             :  :  +- Range 0, 
10, 1, 8, [id#0L]
    !      :     +- Range 5, 15, 1, 8, [id#4L]               :  +- 
SubqueryAlias b
    !      +- SubqueryAlias c                                :     +- Range 5, 
15, 1, 8, [id#4L]
    !         +- Range 7, 25, 1, 8, [id#8L]                  +- SubqueryAlias c
    !                                                           +- Range 7, 25, 
1, 8, [id#8L]
    
    ```


---
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]

Reply via email to