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


##########
core/src/main/resources/error/error-classes.json:
##########
@@ -187,6 +187,11 @@
     ],
     "sqlState" : "22003"
   },
+  "CODEC_NOT_AVAILABLE" : {
+    "message" : [
+      "Codec [<codecName>] is not available. Consider setting 
<configKey>=<configVal>"

Review Comment:
   nit:
   ```suggestion
         "The codec <codecName> is not available. Consider to set the config 
<configKey> to <configVal>."
   ```



##########
core/src/test/scala/org/apache/spark/io/CompressionCodecSuite.scala:
##########
@@ -127,9 +127,10 @@ class CompressionCodecSuite extends SparkFunSuite {
   }
 
   test("bad compression codec") {
-    intercept[IllegalArgumentException] {
+    val e = intercept[SparkIllegalArgumentException] {
       CompressionCodec.createCodec(conf, "foobar")
     }
+    assert(e.getErrorClass == "CODEC_NOT_AVAILABLE")

Review Comment:
   Please, use `checkError()`



##########
core/src/main/scala/org/apache/spark/io/CompressionCodec.scala:
##########
@@ -88,8 +88,12 @@ private[spark] object CompressionCodec {
     } catch {
       case _: ClassNotFoundException | _: IllegalArgumentException => None
     }
-    codec.getOrElse(throw new IllegalArgumentException(s"Codec [$codecName] is 
not available. " +
-      s"Consider setting $configKey=$FALLBACK_COMPRESSION_CODEC"))
+    codec.getOrElse(throw new SparkIllegalArgumentException(
+      errorClass = "CODEC_NOT_AVAILABLE",
+      messageParameters = Map(
+        "codecName" -> codecName,
+        "configKey" -> configKey,

Review Comment:
   Please, wrap it by `toSQLConf`



##########
core/src/main/scala/org/apache/spark/io/CompressionCodec.scala:
##########
@@ -88,8 +88,12 @@ private[spark] object CompressionCodec {
     } catch {
       case _: ClassNotFoundException | _: IllegalArgumentException => None
     }
-    codec.getOrElse(throw new IllegalArgumentException(s"Codec [$codecName] is 
not available. " +
-      s"Consider setting $configKey=$FALLBACK_COMPRESSION_CODEC"))
+    codec.getOrElse(throw new SparkIllegalArgumentException(
+      errorClass = "CODEC_NOT_AVAILABLE",
+      messageParameters = Map(
+        "codecName" -> codecName,
+        "configKey" -> configKey,
+        "configVal" -> FALLBACK_COMPRESSION_CODEC)))

Review Comment:
   Could you wrap it by `toSQLConfVal`



##########
core/src/main/resources/error/error-classes.json:
##########
@@ -1385,6 +1390,11 @@
       "No handler for UDAF '<functionName>'. Use 
sparkSession.udf.register(...) instead."
     ]
   },
+  "NO_SHORT_NAME_FOR_CODEC" : {
+    "message" : [
+      "No short name for codec <codecName>."

Review Comment:
   nit:
   ```suggestion
         "Not found a short name for the codec <codecName>."
   ```



##########
core/src/main/scala/org/apache/spark/io/CompressionCodec.scala:
##########
@@ -88,8 +88,12 @@ private[spark] object CompressionCodec {
     } catch {
       case _: ClassNotFoundException | _: IllegalArgumentException => None
     }
-    codec.getOrElse(throw new IllegalArgumentException(s"Codec [$codecName] is 
not available. " +
-      s"Consider setting $configKey=$FALLBACK_COMPRESSION_CODEC"))
+    codec.getOrElse(throw new SparkIllegalArgumentException(
+      errorClass = "CODEC_NOT_AVAILABLE",
+      messageParameters = Map(
+        "codecName" -> codecName,

Review Comment:
   Please, wrap it, for instance by `toSQLValue`



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