Github user dongjoon-hyun commented on a diff in the pull request:
https://github.com/apache/spark/pull/18460#discussion_r125968150
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/TypeCoercion.scala
---
@@ -144,6 +145,12 @@ object TypeCoercion {
.orElse((t1, t2) match {
case (ArrayType(et1, containsNull1), ArrayType(et2,
containsNull2)) =>
findWiderTypeForTwo(et1, et2).map(ArrayType(_, containsNull1 ||
containsNull2))
+ case (st1 @ StructType(fields1), st2 @ StructType(fields2)) if
st1.sameType(st2) =>
+ Some(StructType(fields1.zip(fields2).map { case (sf1, sf2) =>
+ val name = if (sf1.name == sf2.name) sf1.name else
sf1.name.toLowerCase(Locale.ROOT)
+ val dataType = findWiderTypeForTwo(sf1.dataType,
sf2.dataType).get
--- End diff --
For Hive, it's the same.
```
hive> select * from t1 union all select * from t2;
FAILED: SemanticException 1:41 Schema of both sides of union should match:
Column _c0 is of type struct<a:int> on first table and type struct<a:bigint> on
second table. Error encountered near token 't2'
```
---
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]