spark-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From viirya <...@git.apache.org>
Subject [GitHub] spark pull request #18460: [SPARK-21247][SQL] Type comparision should respec...
Date Sat, 08 Jul 2017 09:38:37 GMT
Github user viirya commented on a diff in the pull request:

    https://github.com/apache/spark/pull/18460#discussion_r126278747
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/TypeCoercion.scala
---
    @@ -144,6 +145,16 @@ 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) =>
    +            // 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)
    +          }))
    --- End diff --
    
    Shall we also do this in `findWiderTypeWithoutStringPromotionForTwo`?


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Mime
View raw message