You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by viirya <gi...@git.apache.org> on 2018/09/25 11:02:02 UTC
[GitHub] spark pull request #22544: [SPARK-25522][SQL] Improve type promotion for inp...
Github user viirya commented on a diff in the pull request:
https://github.com/apache/spark/pull/22544#discussion_r220147139
--- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/TypeCoercion.scala ---
@@ -971,9 +971,36 @@ object TypeCoercion {
case (ArrayType(fromType, true), ArrayType(toType: DataType, false)) => null
case (ArrayType(fromType, false), ArrayType(toType: DataType, false))
- if !Cast.forceNullable(fromType, toType) =>
+ if !Cast.forceNullable(fromType, toType) =>
implicitCast(fromType, toType).map(ArrayType(_, false)).orNull
+ // Implicit cast between Map types.
+ // Follows the same semantics of implicit casting between two array types.
+ // Refer to documentation above.
+ case (MapType(fromKeyType, fromValueType, fn), MapType(toKeyType, toValueType, true)) =>
+ val newFromType = implicitCast(fromKeyType, toKeyType).orNull
+ val newValueType = implicitCast(fromValueType, toValueType).orNull
+ if (newFromType != null && newValueType != null
--- End diff --
Don't we need to verify `!Cast.forceNullable(fromKeyType, toKeyType)`
---
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org