[GitHub] [spark] srielau commented on a diff in pull request #37744: [SPARK-40300][SQL] Migrate onto the `DATATYPE_MISMATCH` error class

2022-09-02 Thread GitBox


srielau commented on code in PR #37744:
URL: https://github.com/apache/spark/pull/37744#discussion_r961701777


##
core/src/main/resources/error/error-classes.json:
##
@@ -75,6 +75,23 @@
   "The value  () cannot be converted to  because it 
is malformed. Correct the value as per the syntax, or change its format. Use 
 to tolerate malformed input and return NULL instead."
 ]
   },
+  "DATATYPE_MISMATCH" : {
+"message" : [
+  "Cannot resolve  due to data type mismatch:"
+],
+"subClass" : {
+  "BINARY_OP_DIFF_TYPES" : {
+"message" : [
+  "the left and right arguments of the binary operator have different 
types ( and )."

Review Comment:
   "If the two inputs have different types, the analyzer will find the tightest 
common type and do the proper type casting."
   We always need to look at errors from a user's perspective...



-- 
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.

To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


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



[GitHub] [spark] srielau commented on a diff in pull request #37744: [SPARK-40300][SQL] Migrate onto the `DATATYPE_MISMATCH` error class

2022-09-01 Thread GitBox


srielau commented on code in PR #37744:
URL: https://github.com/apache/spark/pull/37744#discussion_r960719687


##
core/src/main/resources/error/error-classes.json:
##
@@ -75,6 +75,23 @@
   "The value  () cannot be converted to  because it 
is malformed. Correct the value as per the syntax, or change its format. Use 
 to tolerate malformed input and return NULL instead."
 ]
   },
+  "DATATYPE_MISMATCH" : {
+"message" : [
+  "Cannot resolve  due to data type mismatch:"
+],
+"subClass" : {
+  "BINARY_OP_DIFF_TYPES" : {
+"message" : [
+  "the left and right arguments of the binary operator have different 
types ( and )."
+]
+  },
+  "BINARY_OP_WRONG_TYPE" : {
+"message" : [
+  "the binary operator requires the input type , not 
."

Review Comment:
   Are you sure this is about the LEFT type?
   Aren't those non-symetrical operators deriving the right type from the left 
type?




##
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/analysis/ExpressionTypeCheckingSuite.scala:
##
@@ -47,14 +47,23 @@ class ExpressionTypeCheckingSuite extends SparkFunSuite 
with SQLHelper {
 assert(e.getMessage.contains(errorMessage))
   }
 
+  def assertTypeMismatch(expr: Expression, errorMessage: String): Unit = {
+val e = intercept[AnalysisException] {
+  assertSuccess(expr)
+}
+assert(e.getMessage.contains(
+  s"""Cannot resolve "${expr.sql}" due to data type mismatch:"""))
+assert(e.getMessage.contains(errorMessage))

Review Comment:
   Use checkError(), don't test the text



##
sql/core/src/test/scala/org/apache/spark/sql/SQLQuerySuite.scala:
##
@@ -2666,10 +2666,7 @@ class SQLQuerySuite extends QueryTest with 
SharedSparkSession with AdaptiveSpark
 val m = intercept[AnalysisException] {
   sql("SELECT * FROM t, S WHERE c = C")
 }.message
-assert(
-  m.contains(
-"cannot resolve '(spark_catalog.default.t.c = " +
-"spark_catalog.default.S.C)' due to data type mismatch"))
+assert(m.contains("""Cannot resolve "(c = C)" due to data type 
mismatch"""))

Review Comment:
   checkError()



##
core/src/main/resources/error/error-classes.json:
##
@@ -75,6 +75,23 @@
   "The value  () cannot be converted to  because it 
is malformed. Correct the value as per the syntax, or change its format. Use 
 to tolerate malformed input and return NULL instead."
 ]
   },
+  "DATATYPE_MISMATCH" : {
+"message" : [
+  "Cannot resolve  due to data type mismatch:"
+],
+"subClass" : {
+  "BINARY_OP_DIFF_TYPES" : {
+"message" : [
+  "the left and right arguments of the binary operator have different 
types ( and )."

Review Comment:
   ```suggestion
 "the left and right operands of the binary operator have 
incompatible types ( and )."
   ```



##
core/src/main/resources/error/error-classes.json:
##
@@ -75,6 +75,23 @@
   "The value  () cannot be converted to  because it 
is malformed. Correct the value as per the syntax, or change its format. Use 
 to tolerate malformed input and return NULL instead."
 ]
   },
+  "DATATYPE_MISMATCH" : {
+"message" : [
+  "Cannot resolve  due to data type mismatch:"
+],
+"subClass" : {
+  "BINARY_OP_DIFF_TYPES" : {

Review Comment:
   Isn't. the problem that they are incompatible, rather than different? We 
will happily divide an integer by a float. We even divide an interval by a an 
integer
   



-- 
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.

To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


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