viirya commented on a change in pull request #29485:
URL: https://github.com/apache/spark/pull/29485#discussion_r474215216



##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/TypeCoercion.scala
##########
@@ -385,12 +407,16 @@ object TypeCoercion {
     }
 
     /** Given a plan, add an extra project on top to widen some columns' data 
types. */
-    private def widenTypes(plan: LogicalPlan, targetTypes: Seq[DataType]): 
LogicalPlan = {
-      val casted = plan.output.zip(targetTypes).map {
-        case (e, dt) if e.dataType != dt => Alias(Cast(e, dt), e.name)()
-        case (e, _) => e
-      }
-      Project(casted, plan)
+    private def widenTypes(plan: LogicalPlan, targetTypes: Seq[DataType])
+      : (LogicalPlan, Seq[(ExprId, (ExprId, DataType))]) = {
+      val (casted, newExprIds) = plan.output.zip(targetTypes).map {
+        case (e, dt) if e.dataType != dt =>
+          val alias = Alias(Cast(e, dt), e.name)()
+          (alias, Some(e.exprId -> (alias.exprId, dt)))

Review comment:
       Can we just store the attribute of the `Alias`, i.e., 
`alias.toAttribute`?




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