Github user yhuai commented on a diff in the pull request:
https://github.com/apache/spark/pull/10781#discussion_r49949314
--- Diff: sql/core/src/main/scala/org/apache/spark/sql/Column.scala ---
@@ -133,6 +133,15 @@ class Column(protected[sql] val expr: Expression)
extends Logging {
case func: UnresolvedFunction => UnresolvedAlias(func,
Some(func.prettyString))
+ // If we have a top level Cast, there is a chance to give it a better
alias, if there is a
+ // NamedExpression under this Cast.
+ case c: Cast => c.transformUp {
+ case Cast(ne: NamedExpression, to) => UnresolvedAlias(Cast(ne, to))
+ } match {
+ case ne: NamedExpression => ne
+ case other => Alias(expr, expr.prettyString)()
+ }
--- End diff --
We use `transformUp` at here to make this logic equivalent with the
original logic that we have in the `cast`, right (since we want to fix it in
1.6)? (in future, will it be possible to just use `cast Cast(ne:
NamedExpression, to) => UnresolvedAlias(Cast(ne, to))`?)
---
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]