Github user dongjoon-hyun commented on a diff in the pull request:
https://github.com/apache/spark/pull/18460#discussion_r125959164
--- 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 --
Sorry for making this confused.
I added the comment in [the
test](https://github.com/apache/spark/pull/18460/files/d3a9f73c1a19818bf9970d1102fc1b8d1cf0effa#diff-01ecdd038c5c2f53f38118912210fef8R443).
```
StructType does not widen the types, but supports case-sensitive options.
```
This line are guarded by `if st1.sameType(st2)`. So, we always have the
same `dataType`.
The reason to use `findWiderTypeForTwo` is to get the final nested complex
type with the new nullability.
Also, this function is `findWiderTypeForTwo`.
---
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]