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



##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/TypeCoercion.scala
##########
@@ -273,29 +274,37 @@ abstract class TypeCoercionBase {
     @tailrec private def getWidestTypes(
         children: Seq[LogicalPlan],
         attrIndex: Int,
-        castedTypes: mutable.Queue[DataType]): Seq[DataType] = {
+        castedTypes: mutable.Queue[Option[DataType]]): Seq[Option[DataType]] = 
{
       // Return the result after the widen data types have been found for all 
the children
       if (attrIndex >= children.head.output.length) return castedTypes.toSeq
 
       // For the attrIndex-th attribute, find the widest type
       findWiderCommonType(children.map(_.output(attrIndex).dataType)) match {
         // If unable to find an appropriate widen type for this column, return 
an empty Seq
-        case None => Seq.empty[DataType]
+        case None =>
+          castedTypes.enqueue(None)
+          getWidestTypes(children, attrIndex + 1, castedTypes)
         // Otherwise, record the result in the queue and find the type for the 
next column
         case Some(widenType) =>
-          castedTypes.enqueue(widenType)
+          castedTypes.enqueue(Some(widenType))
           getWidestTypes(children, attrIndex + 1, castedTypes)

Review comment:
       Just simplified to
   
   ```scala
   val widenTypeOpt = 
findWiderCommonType(children.map(_.output(attrIndex).dataType))
   castedTypes.enqueue(widenTypeOpt)
   getWidestTypes(children, attrIndex + 1, castedTypes)
   ```




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

To unsubscribe, e-mail: [email protected]

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