Github user marmbrus commented on a diff in the pull request:
https://github.com/apache/spark/pull/3510#discussion_r21128184
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/HiveTypeCoercion.scala
---
@@ -219,6 +219,27 @@ trait HiveTypeCoercion {
if (b.right.dataType == widestType) b.right else
Cast(b.right, widestType)
b.makeCopy(Array(newLeft, newRight))
}.getOrElse(b) // If there is no applicable conversion, leave
expression unchanged.
+
+ case c @ Coalesce(exps) =>
+ val valueTypes = exps.map (_.dataType)
+ if (valueTypes.distinct.size > 1) {
+ val commonType = valueTypes.reduce { (v1, v2) =>
+ // When a string is found on one side, make the other side a
string too.
+ if (v1 == StringType || v2 == StringType) {
+ StringType
--- End diff --
I agree that we should probably add a bunch more tests to make sure that we
are doing the type coercion correctly here.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]