ulysses-you commented on a change in pull request #30974:
URL: https://github.com/apache/spark/pull/30974#discussion_r551199486



##########
File path: sql/core/src/main/scala/org/apache/spark/sql/Column.scala
##########
@@ -200,6 +203,7 @@ class Column(val expr: Expression) extends Logging {
     // Wait until the struct is resolved. This will generate a nicer looking 
alias.
     case struct: CreateNamedStruct => UnresolvedAlias(struct)
 
+    case expr: Expression if existsUnresolvedExpr(expr) => 
UnresolvedAlias(expr)
     case expr: Expression => Alias(expr, toPrettySQL(expr))()

Review comment:
       you mean add `case c @ Cast(e: Expression, _, _) => Alias(c, 
toPrettySQL(e))()` in `ResolveAliases` ?
   ```
   private def assignAliases(exprs: Seq[NamedExpression]) = {
         exprs.map(_.transformUp { case u @ UnresolvedAlias(child, 
optGenAliasFunc) =>
             child match {
               case ne: NamedExpression => ne
               case go @ GeneratorOuter(g: Generator) if g.resolved => 
MultiAlias(go, Nil)
               case e if !e.resolved => u
               case g: Generator => MultiAlias(g, Nil)
               case c @ Cast(ne: NamedExpression, _, _) => Alias(c, ne.name)()
               case e: ExtractValue => Alias(e, toPrettySQL(e))()
               case e if optGenAliasFunc.isDefined =>
                 Alias(child, optGenAliasFunc.get.apply(e))()
               case e => Alias(e, toPrettySQL(e))()
             }
           }
         ).asInstanceOf[Seq[NamedExpression]]
       }
   ```
   
   I think that's ok logiclly but may affect many code place.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to