You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2019/12/04 03:56:07 UTC

[GitHub] [spark] liancheng commented on a change in pull request #26485: [SPARK-29860][SQL] Fix dataType mismatch issue for InSubquery.

liancheng commented on a change in pull request #26485: [SPARK-29860][SQL] Fix dataType mismatch issue for InSubquery.
URL: https://github.com/apache/spark/pull/26485#discussion_r353539018
 
 

 ##########
 File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/TypeCoercion.scala
 ##########
 @@ -472,9 +472,12 @@ object TypeCoercion {
         // RHS is the subquery output.
         val rhs = sub.output
 
-        val commonTypes = lhs.zip(rhs).flatMap { case (l, r) =>
-          findCommonTypeForBinaryComparison(l.dataType, r.dataType, conf)
-            .orElse(findTightestCommonType(l.dataType, r.dataType))
+        val commonTypes = lhs.zip(rhs).flatMap {
+          case (l, r) if !l.dataType.isInstanceOf[DecimalType] &&
+            !r.dataType.isInstanceOf[DecimalType] =>
+            findCommonTypeForBinaryComparison(l.dataType, r.dataType, conf)
+              .orElse(findTightestCommonType(l.dataType, r.dataType))
+          case (l, r) => findWiderTypeForDecimal(l.dataType, r.dataType)
 
 Review comment:
   We can clean this part a little bit with the extractor defined in `object DecimalType` for checking expression data types:
   
   ```scala
   val commonTypes = lhs.zip(rhs).flatMap {
     case (l @ DecimalType(), r @ DecimalType()) =>
       findWiderTypeForDecimal(l.dataType, r.dataType)
   
     case (l, r) =>
       findCommonTypeForBinaryComparison(l.dataType, r.dataType, conf).orElse {
         findTightestCommonType(l.dataType, r.dataType)
       }
   }
   ```
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

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