Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add comments.
  • Loading branch information
dongjoon-hyun committed Sep 8, 2017
commit cded71940a7918bdb155e34d06af0cccf9c3362b
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,10 @@ object TypeCoercion {
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) =>
// Since `st1.sameType(st2)` is true, two StructTypes have the same DataType
// except `name` (in case of `spark.sql.caseSensitive=false`) and `nullable`.
// - Different names: use a lower case name because findWiderTypeForTwo is commutative.
// - Different nullabilities: `nullable` is true iff one of them is nullable.
val name = if (sf1.name == sf2.name) sf1.name else sf1.name.toLowerCase(Locale.ROOT)
val dataType = findWiderTypeForTwo(sf1.dataType, sf2.dataType).get
StructField(name, dataType, nullable = sf1.nullable || sf2.nullable)
Expand Down