You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "MaxGekk (via GitHub)" <gi...@apache.org> on 2023/04/04 09:31:12 UTC

[GitHub] [spark] MaxGekk commented on a diff in pull request #40657: [SPARK-42844][SQL]Update error_class "_LEGACY_ERROR_TEMP_2008" to "INVALID_URL_STRING"

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


##########
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/StringExpressionsSuite.scala:
##########
@@ -1832,16 +1833,28 @@ class StringExpressionsSuite extends SparkFunSuite with ExpressionEvalHelper {
   }
 
   test("SPARK-33468: ParseUrl in ANSI mode should fail if input string is not a valid url") {
+    val url = "https://a.b.c/index.php?params1=a|b&params2=x"
     withSQLConf(SQLConf.ANSI_ENABLED.key -> "true") {
       val msg = intercept[IllegalArgumentException] {
         evaluateWithoutCodegen(
-          ParseUrl(Seq("https://a.b.c/index.php?params1=a|b&params2=x", "HOST")))
+          ParseUrl(Seq(url, "HOST")))
       }.getMessage
       assert(msg.contains("Find an invalid url string"))
     }
-    withSQLConf(SQLConf.ANSI_ENABLED.key -> "false") {
+    withSQLConf(SQLConf.ANSI_ENABLED.key -> "true") {
+            checkError(exception = intercept[SparkIllegalArgumentException]{
+              evaluateWithoutCodegen(
+             ParseUrl(Seq(url, "HOST")))

Review Comment:
   Could you trigger the error from user code, please. For example `sql("select parse_url(...)")`



##########
core/src/main/resources/error/error-classes.json:
##########
@@ -1062,6 +1062,11 @@
     ],
     "sqlState" : "42604"
   },
+  "INVALID_URL_STRING" : {

Review Comment:
   Could you make it shorter `INVALID_URL`, please. The word `_STRING` doesn't bring any additional info, IMHO.



##########
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/StringExpressionsSuite.scala:
##########
@@ -1832,16 +1833,28 @@ class StringExpressionsSuite extends SparkFunSuite with ExpressionEvalHelper {
   }
 
   test("SPARK-33468: ParseUrl in ANSI mode should fail if input string is not a valid url") {
+    val url = "https://a.b.c/index.php?params1=a|b&params2=x"
     withSQLConf(SQLConf.ANSI_ENABLED.key -> "true") {
       val msg = intercept[IllegalArgumentException] {
         evaluateWithoutCodegen(
-          ParseUrl(Seq("https://a.b.c/index.php?params1=a|b&params2=x", "HOST")))
+          ParseUrl(Seq(url, "HOST")))
       }.getMessage
       assert(msg.contains("Find an invalid url string"))
     }
-    withSQLConf(SQLConf.ANSI_ENABLED.key -> "false") {
+    withSQLConf(SQLConf.ANSI_ENABLED.key -> "true") {
+            checkError(exception = intercept[SparkIllegalArgumentException]{
+              evaluateWithoutCodegen(
+             ParseUrl(Seq(url, "HOST")))
+            },
+              errorClass = "INVALID_URL_STRING",

Review Comment:
   Please, fix indentations around.



##########
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/StringExpressionsSuite.scala:
##########
@@ -1832,16 +1833,28 @@ class StringExpressionsSuite extends SparkFunSuite with ExpressionEvalHelper {
   }
 
   test("SPARK-33468: ParseUrl in ANSI mode should fail if input string is not a valid url") {
+    val url = "https://a.b.c/index.php?params1=a|b&params2=x"
     withSQLConf(SQLConf.ANSI_ENABLED.key -> "true") {
       val msg = intercept[IllegalArgumentException] {
         evaluateWithoutCodegen(
-          ParseUrl(Seq("https://a.b.c/index.php?params1=a|b&params2=x", "HOST")))
+          ParseUrl(Seq(url, "HOST")))
       }.getMessage
       assert(msg.contains("Find an invalid url string"))
     }

Review Comment:
   Could you remove this since it duplicates the check below.



##########
core/src/main/resources/error/error-classes.json:
##########
@@ -1062,6 +1062,11 @@
     ],
     "sqlState" : "42604"
   },
+  "INVALID_URL_STRING" : {
+    "message" : [
+      "Find an invalid url string <url>. If necessary set <ansiConfig> to false to bypass this error."

Review Comment:
   Please, quote `false`:
   ```suggestion
         "The url is invalid: <url>. If necessary set <ansiConfig> to \"false\" to bypass this error."
   ```



-- 
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-unsubscribe@spark.apache.org

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


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