Github user liutang123 commented on a diff in the pull request:
https://github.com/apache/spark/pull/21100#discussion_r182979953
--- Diff: sql/core/src/test/scala/org/apache/spark/sql/SQLQuerySuite.scala
---
@@ -896,6 +896,19 @@ class SQLQuerySuite extends QueryTest with
SharedSQLContext {
}
}
+ test("SPARK-24012 Union of map and other compatible columns") {
+ checkAnswer(
+ sql(
+ """
+ |SELECT map(1, 2), 'str'
+ |UNION ALL
+ |SELECT map(1, 2, 3, NULL), 1""".stripMargin),
--- End diff --
map<int, nullable int> and map<int, not nullable int> are accepted by
Union, but, string and int are not.
If types of one column can not be accepted by Union,
TCWSOT(TypeCoercion.WidenSetOperationTypes) will try to coerce them to a
completely identical type. TCWSOT works when all of the columns can be coerced
and not work when columns can not be coerced exist.
map<int, nullable int> and map<int, not nullable int> can not be coerced,
so, TCWSOT didn't work and string and int will not be coerced.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]