Github user ueshin commented on a diff in the pull request:
https://github.com/apache/spark/pull/21704#discussion_r201924130
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/TypeCoercion.scala
---
@@ -610,27 +636,27 @@ object TypeCoercion {
// Coalesce should return the first non-null value, which could be
any column
// from the list. So we need to make sure the return type is
deterministic and
// compatible with every child column.
- case c @ Coalesce(es) if !haveSameType(es) =>
+ case c @ Coalesce(es) if !c.areInputTypesForMergingEqual =>
val types = es.map(_.dataType)
findWiderCommonType(types) match {
- case Some(finalDataType) => Coalesce(es.map(Cast(_,
finalDataType)))
+ case Some(finalDataType) => Coalesce(es.map(castIfNotSameType(_,
finalDataType)))
case None => c
}
// When finding wider type for `Greatest` and `Least`, we should
handle decimal types even if
// we need to truncate, but we should not promote one side to string
if the other side is
// string.g
- case g @ Greatest(children) if !haveSameType(children) =>
+ case g @ Greatest(children) if !g.areInputTypesForMergingEqual =>
--- End diff --
Updated PR title and description.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]