Github user mn-mikke commented on a diff in the pull request: https://github.com/apache/spark/pull/21687#discussion_r200850235 --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/TypeCoercion.scala --- @@ -688,10 +688,10 @@ object TypeCoercion { plan: LogicalPlan): LogicalPlan = plan transformAllExpressions { case e if !e.childrenResolved => e // Find tightest common type for If, if the true value and false value have different types. - case i @ If(pred, left, right) if left.dataType != right.dataType => - findWiderTypeForTwo(left.dataType, right.dataType).map { widestType => - val newLeft = if (left.dataType == widestType) left else Cast(left, widestType) - val newRight = if (right.dataType == widestType) right else Cast(right, widestType) + case i @ If(pred, left, right) if !i.areInputTypesForMergingEqual => + findWiderTypeForTwo(left.dataType, right.dataType).map { commonType => + val newLeft = if (left.dataType.sameType(commonType)) left else Cast(left, commonType) + val newRight = if (right.dataType.sameType(commonType)) right else Cast(right, commonType) --- End diff -- ```widestType``` sounded to me a bit misleading, but I can revert it back if you find it OK.
--- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org