Github user viirya commented on a diff in the pull request:
https://github.com/apache/spark/pull/21687#discussion_r200802633
--- 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 --
Above changes looks like just renaming `widestType` -> `commonType`. Is it
necessary?
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]