MaxGekk commented on code in PR #39872:
URL: https://github.com/apache/spark/pull/39872#discussion_r1096762646


##########
core/src/main/resources/error/error-classes.json:
##########
@@ -511,6 +511,12 @@
     ],
     "sqlState" : "38000"
   },
+  "FAILED_PARSE_EMPTY_STRING" : {

Review Comment:
   This error class is pretty JSON specific. So, add JSON in the name. For 
example:
   ```suggestion
     "EMPTY_JSON_FIELD_VALUE" : {
   ```



##########
core/src/main/resources/error/error-classes.json:
##########
@@ -511,6 +511,12 @@
     ],
     "sqlState" : "38000"
   },
+  "FAILED_PARSE_EMPTY_STRING" : {
+    "message" : [
+      "Failed to parse an empty string for data type <dataType>."

Review Comment:
   Please, tell about the SQL config 
`spark.sql.legacy.json.allowEmptyString.enabled` to users in the error message.



##########
sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/json/JsonSuite.scala:
##########
@@ -2608,11 +2609,12 @@ abstract class JsonSuite
   private def failedOnEmptyString(dataType: DataType): Unit = {
     val df = spark.read.schema(s"a ${dataType.catalogString}")
       .option("mode", "FAILFAST").json(Seq("""{"a":""}""").toDS)
-    val errMessage = intercept[SparkException] {
-      df.collect()
-    }.getMessage
-    assert(errMessage.contains(
-      s"Failed to parse an empty string for data type 
${dataType.catalogString}"))
+    val e = intercept[SparkException] {df.collect()}
+    checkError(
+      exception = 
e.getCause.getCause.getCause.asInstanceOf[SparkRuntimeException],
+      errorClass = "FAILED_PARSE_EMPTY_STRING",
+      parameters = Map("dataType" -> s"${toSQLType(dataType)}")

Review Comment:
   nit:
   ```suggestion
         parameters = Map("dataType" -> toSQLType(dataType))
   ```



##########
sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryExecutionErrors.scala:
##########
@@ -1433,9 +1433,9 @@ private[sql] object QueryExecutionErrors extends 
QueryErrorsBase {
 
   def failToParseEmptyStringForDataTypeError(dataType: DataType): 
SparkRuntimeException = {
     new SparkRuntimeException(
-      errorClass = "_LEGACY_ERROR_TEMP_2135",
+      errorClass = "FAILED_PARSE_EMPTY_STRING",
       messageParameters = Map(
-        "dataType" -> dataType.catalogString))
+        "dataType" -> toSQLType(dataType)))

Review Comment:
   ```scala
         messageParameters = Map("dataType" -> toSQLType(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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to