cloud-fan commented on a change in pull request #27150: [SPARK-30471][SQL] Fix 
issue when comparing String and IntegerType
URL: https://github.com/apache/spark/pull/27150#discussion_r365640741
 
 

 ##########
 File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/TypeCoercion.scala
 ##########
 @@ -136,11 +136,20 @@ object TypeCoercion {
     case (TimestampType, DateType) => Some(TimestampType)
     case (DateType, TimestampType) => Some(TimestampType)
 
-    // There is no proper decimal type we can pick,
-    // using double type is the best we can do.
-    // See SPARK-22469 for details.
-    case (n: DecimalType, s: StringType) => Some(DoubleType)
-    case (s: StringType, n: DecimalType) => Some(DoubleType)
+    case (l, r) if (l.isInstanceOf[StringType] && r.isInstanceOf[NumericType]) 
||
+      (l.isInstanceOf[NumericType] && r.isInstanceOf[StringType]) =>
+      if (conf.ansiEnabled) {
+        throw new ArithmeticException(
+          s"""
+            | Operator does not exist: $l compare $r
 
 Review comment:
   We don't have to follow the error message of pgsql. We can return None here, 
and the framework would produce proper error message for us.

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to