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

    https://github.com/apache/spark/pull/14444#discussion_r73112000
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala
 ---
    @@ -2065,18 +2065,28 @@ object EliminateUnions extends Rule[LogicalPlan] {
      */
     object CleanupAliases extends Rule[LogicalPlan] {
       private def trimAliases(e: Expression): Expression = {
    -    var stop = false
         e.transformDown {
    -      // CreateStruct is a special case, we need to retain its top level 
Aliases as they decide the
    -      // name of StructField. We also need to stop transform down this 
expression, or the Aliases
    -      // under CreateStruct will be mistakenly trimmed.
    -      case c: CreateStruct if !stop =>
    -        stop = true
    -        c.copy(children = c.children.map(trimNonTopLevelAliases))
    -      case c: CreateStructUnsafe if !stop =>
    -        stop = true
    -        c.copy(children = c.children.map(trimNonTopLevelAliases))
    -      case Alias(child, _) if !stop => child
    +      /**
    +        *  [[CreateStruct]] is a special case as it uses its top level 
Aliases to decide the
    +        *  name of StructField.
    +        *  we tackle this by replacing [[CreateStruct]] with 
[[CreateNamedStruct]]
    +        *  which encodes the field names as child literals.
    +        */
    +      case c @ CreateStruct(children) =>
    --- End diff --
    
    So,is it OK to leave this logic in CleanupAlias? I saw it's being called
    from other places,i'm just not sure if there are any optimizer rules that
    introduce struts and/or aliases and if these rules are actually calling the
    aliased cleanup rule.
    
    On Aug 2, 2016 10:20, "Wenchen Fan" <notificati...@github.com> wrote:
    
    > In
    > 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala
    > <https://github.com/apache/spark/pull/14444#discussion_r73105110>:
    >
    > > -      // name of StructField. We also need to stop transform down this 
expression, or the Aliases
    > > -      // under CreateStruct will be mistakenly trimmed.
    > > -      case c: CreateStruct if !stop =>
    > > -        stop = true
    > > -        c.copy(children = c.children.map(trimNonTopLevelAliases))
    > > -      case c: CreateStructUnsafe if !stop =>
    > > -        stop = true
    > > -        c.copy(children = c.children.map(trimNonTopLevelAliases))
    > > -      case Alias(child, _) if !stop => child
    > > +      /**
    > > +        *  [[CreateStruct]] is a special case as it uses its top level 
Aliases to decide the
    > > +        *  name of StructField.
    > > +        *  we tackle this by replacing [[CreateStruct]] with 
[[CreateNamedStruct]]
    > > +        *  which encodes the field names as child literals.
    > > +        */
    > > +      case c @ CreateStruct(children) =>
    >
    > Optimizer will only add resolved expressions, but may clean up(remove
    > aliases) them if necessary.
    >
    > —
    > You are receiving this because you authored the thread.
    > Reply to this email directly, view it on GitHub
    > 
<https://github.com/apache/spark/pull/14444/files/8920c12a2a363c90b441dd7f29400c951ce9cd2f#r73105110>,
    > or mute the thread
    > 
<https://github.com/notifications/unsubscribe-auth/ABFFOcmSPQ3V7MvZEaTIIwBkyPuQ3W3qks5qbu-jgaJpZM4JaDJr>
    > .
    >



---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to