Github user cloud-fan commented on a diff in the pull request:
https://github.com/apache/spark/pull/10781#discussion_r49962281
--- 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 --
yea, it works, I'll add a test for it.
---
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]