You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2022/08/24 00:49:42 UTC

[GitHub] [spark] zzzzming95 opened a new pull request, #37636: url_decode() should the return an ERROR_CLASS

zzzzming95 opened a new pull request, #37636:
URL: https://github.com/apache/spark/pull/37636

   <!--
   Thanks for sending a pull request!  Here are some tips for you:
     1. If this is your first time, please read our contributor guidelines: https://spark.apache.org/contributing.html
     2. Ensure you have added or run the appropriate tests for your PR: https://spark.apache.org/developer-tools.html
     3. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP][SPARK-XXXX] Your PR title ...'.
     4. Be sure to keep the PR description updated to reflect all changes.
     5. Please write your PR title to summarize what this PR proposes.
     6. If possible, provide a concise example to reproduce the issue for a faster review.
     7. If you want to add a new configuration, please read the guideline first for naming configurations in
        'core/src/main/scala/org/apache/spark/internal/config/ConfigEntry.scala'.
     8. If you want to add or modify an error type or message, please read the guideline first in
        'core/src/main/resources/error/README.md'.
   -->
   
   ### What changes were proposed in this pull request?
   <!--
   Please clarify what changes you are proposing. The purpose of this section is to outline the changes and how this PR fixes the issue. 
   If possible, please consider writing useful notes for better and faster reviews in your PR. See the examples below.
     1. If you refactor some codes with changing classes, showing the class hierarchy will help reviewers.
     2. If you fix some SQL features, you can provide some references of other DBMSes.
     3. If there is design documentation, please add the link.
     4. If there is a discussion in the mailing list, please add the link.
   -->
   
   url_decode() return an ERROR_CLASS when Invalid parameter input. like :
   ```
   spark.sql("SELECT url_decode('http%3A%2F%2spark.apache.org')").show
   ```
   
   output:
   ```
   org.apache.spark.SparkIllegalArgumentException: [CANNOT_DECODE_URL] Cannot decode url : http%3A%2F%2spark.apache.org.
   URLDecoder: Illegal hex characters in escape (%) pattern - For input string: "2s"
   	at org.apache.spark.sql.errors.QueryExecutionErrors$.illegalUrlError(QueryExecutionErrors.scala:351)
   	at org.apache.spark.sql.catalyst.expressions.UrlCodec$.decode(urlExpressions.scala:117)
   	at org.apache.spark.sql.catalyst.expressions.UrlCodec.decode(urlExpressions.scala)
   	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
   	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   	at java.lang.reflect.Method.invoke(Method.java:498)
   	at org.apache.spark.sql.catalyst.expressions.objects.InvokeLike.invoke(objects.scala:148)
   ```
   
   ### Why are the changes needed?
   <!--
   Please clarify why the changes are needed. For instance,
     1. If you propose a new API, clarify the use case for a new API.
     2. If you fix a bug, you can clarify why it is a bug.
   -->
   
   url_decode() should the return an ERROR_CLASS.
   
   ### Does this PR introduce _any_ user-facing change?
   <!--
   Note that it means *any* user-facing change including all aspects such as the documentation fix.
   If yes, please clarify the previous behavior and the change this PR proposes - provide the console output, description and/or an example to show the behavior difference if possible.
   If possible, please also clarify if this is a user-facing change compared to the released Spark versions or within the unreleased branches such as master.
   If no, write 'No'.
   -->
   
   no
   
   ### How was this patch tested?
   <!--
   If tests were added, say they were added here. Please make sure to add some test cases that check the changes thoroughly including negative and positive cases if possible.
   If it was tested in a way different from regular unit tests, please clarify how you tested step by step, ideally copy and paste-able, so that other reviewers can test and check, and descendants can verify in the future.
   If tests were not added, please describe why they were not added and/or why it was difficult to add.
   If benchmark tests were added, please run the benchmarks in GitHub Actions for the consistent environment, and the instructions could accord to: https://spark.apache.org/developer-tools.html#github-workflow-benchmarks.
   -->
   
   build/sbt "sql/testOnly org.apache.spark.sql.SQLQueryTestSuite -- -z url-functions.sql"


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


[GitHub] [spark] MaxGekk commented on a diff in pull request #37636: [SPARK-40156][SQL] url_decode() should the return an ERROR_CLASS

Posted by GitBox <gi...@apache.org>.
MaxGekk commented on code in PR #37636:
URL: https://github.com/apache/spark/pull/37636#discussion_r955905388


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryExecutionErrors.scala:
##########
@@ -332,6 +332,13 @@ private[sql] object QueryExecutionErrors extends QueryErrorsBase {
       s"If necessary set ${SQLConf.ANSI_ENABLED.key} to false to bypass this error.", e)
   }
 
+  def illegalUrlError(url: UTF8String, e: IllegalArgumentException):
+  Throwable with SparkThrowable = {
+    new SparkIllegalArgumentException(errorClass = "CANNOT_DECODE_URL",
+      messageParameters = Array(url.toString, e.getMessage)

Review Comment:
   ok. Let's leave this as is.



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


[GitHub] [spark] HyukjinKwon commented on a diff in pull request #37636: [SPARK-40156][SQL] `url_decode()` should the return an error class

Posted by GitBox <gi...@apache.org>.
HyukjinKwon commented on code in PR #37636:
URL: https://github.com/apache/spark/pull/37636#discussion_r956538331


##########
sql/core/src/test/resources/sql-tests/results/url-functions.sql.out:
##########
@@ -95,6 +95,22 @@ struct<url_decode(https%3A%2F%2Fspark.apache.org):string>
 https://spark.apache.org
 
 
+-- !query

Review Comment:
   This test is broken with JDK 11 and 17:
   
   ```
   [info] - url-functions.sql *** FAILED *** (313 milliseconds)
   [info]   url-functions.sql
   [info]   Expected "...scape (%) pattern - [For input string]: \"2s\""
   [info]     }
   [info]   }", but got "...scape (%) pattern - [Error at index 1 in]: \"2s\""
   [info]     }
   [info]   }" Result did not match for query #12
   [info]   select url_decode('http%3A%2F%2spark.apache.org') (SQLQueryTestSuite.scala:476)
   [info]   org.scalatest.exceptions.TestFailedException:
   [info]   at org.scalatest.Assertions.newAssertionFailedException(Assertions.scala:472)
   [info]   at org.scalatest.Assertions.newAssertionFailedException$(Assertions.scala:471)
   [info]   at org.scalatest.funsuite.AnyFunSuite.newAssertionFailedException(AnyFunSuite.scala:1563)
   [info]   at org.scalatest.Assertions.assertResult(Assertions.scala:847)
   [info]   at org.scalatest.Assertions.assertResult$(Assertions.scala:842)
   [info]   at org.scalatest.funsuite.AnyFunSuite.assertResult(AnyFunSuite.scala:1563)
   ```
   
   https://github.com/apache/spark/runs/8040214816?check_suite_focus=true
   https://github.com/apache/spark/runs/8045261892?check_suite_focus=true
   
   Reverting for now.



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


[GitHub] [spark] MaxGekk commented on a diff in pull request #37636: [SPARK-40156][SQL]url_decode() should the return an ERROR_CLASS

Posted by GitBox <gi...@apache.org>.
MaxGekk commented on code in PR #37636:
URL: https://github.com/apache/spark/pull/37636#discussion_r954807344


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/urlExpressions.scala:
##########
@@ -110,7 +110,12 @@ object UrlCodec {
   }
 
   def decode(src: UTF8String, enc: UTF8String): UTF8String = {
-    UTF8String.fromString(URLDecoder.decode(src.toString, enc.toString))
+    try {
+      UTF8String.fromString(URLDecoder.decode(src.toString, enc.toString))
+    } catch {
+      case e: IllegalArgumentException =>

Review Comment:
   According to the doc of `URLDecoder.decode`, it can throw `UnsupportedEncodingException` too. Should we handle the Java exception too?



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


[GitHub] [spark] zzzzming95 commented on a diff in pull request #37636: [SPARK-40156][SQL] url_decode() should the return an ERROR_CLASS

Posted by GitBox <gi...@apache.org>.
zzzzming95 commented on code in PR #37636:
URL: https://github.com/apache/spark/pull/37636#discussion_r955523173


##########
core/src/main/resources/error/error-classes.json:
##########
@@ -632,5 +632,12 @@
       "Writing job aborted"
     ],
     "sqlState" : "40000"
+  },
+  "CANNOT_DECODE_URL" : {
+    "message" : [
+      "Cannot decode url : <url>.",
+      "<details>"
+    ],
+    "sqlState" : "42000"
   }
-}
+}

Review Comment:
   done



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


[GitHub] [spark] zzzzming95 commented on pull request #37636: [SPARK-40156][SQL] url_decode() should the return an ERROR_CLASS

Posted by GitBox <gi...@apache.org>.
zzzzming95 commented on PR #37636:
URL: https://github.com/apache/spark/pull/37636#issuecomment-1227867445

   Fixed sql out test, but still got a format correctly error.
   
   > SparkThrowableSuite.Error classes are correctly formatted
   
   I am not very clear about the problem, can you help me to check the error, thank you very much @MaxGekk 


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


[GitHub] [spark] MaxGekk commented on pull request #37636: [SPARK-40156][SQL] url_decode() should the return an ERROR_CLASS

Posted by GitBox <gi...@apache.org>.
MaxGekk commented on PR #37636:
URL: https://github.com/apache/spark/pull/37636#issuecomment-1227279545

   The test failure:
   ```
   [info] - url-functions.sql *** FAILED *** (315 milliseconds)
   [info]   url-functions.sql
   [info]   Expected "struct<[url_decode(http%3A%2F%2spark.apache.org):string]>", but got "struct<[]>" Schema did not match for query #12
   [info]   select url_decode('http%3A%2F%2spark.apache.org'): -- !query
   [info]   select url_decode('http%3A%2F%2spark.apache.org')
   [info]   -- !query schema
   [info]   struct<>
   [info]   -- !query output
   [info]   org.apache.spark.SparkIllegalArgumentException
   [info]   {
   [info]     "errorClass" : "CANNOT_DECODE_URL",
   [info]     "sqlState" : "42000",
   [info]     "messageParameters" : {
   [info]       "url" : "http%3A%2F%2spark.apache.org",
   [info]       "details" : "URLDecoder: Illegal hex characters in escape (%) pattern - For input string: \"2s\""
   [info]     }
   [info]   } (SQLQueryTestSuite.scala:472)
   ```
   is related to your changes. Please, regenerate the golden file.


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


[GitHub] [spark] MaxGekk commented on pull request #37636: [SPARK-40156][SQL] `url_decode()` should the return an error class

Posted by GitBox <gi...@apache.org>.
MaxGekk commented on PR #37636:
URL: https://github.com/apache/spark/pull/37636#issuecomment-1228333482

   +1, LGTM. Merging to master.
   Thank you, @zzzzming95.


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


[GitHub] [spark] zzzzming95 commented on a diff in pull request #37636: [SPARK-40156][SQL] url_decode() should the return an ERROR_CLASS

Posted by GitBox <gi...@apache.org>.
zzzzming95 commented on code in PR #37636:
URL: https://github.com/apache/spark/pull/37636#discussion_r955880202


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryExecutionErrors.scala:
##########
@@ -332,6 +332,13 @@ private[sql] object QueryExecutionErrors extends QueryErrorsBase {
       s"If necessary set ${SQLConf.ANSI_ENABLED.key} to false to bypass this error.", e)
   }
 
+  def illegalUrlError(url: UTF8String, e: IllegalArgumentException):
+  Throwable with SparkThrowable = {
+    new SparkIllegalArgumentException(errorClass = "CANNOT_DECODE_URL",
+      messageParameters = Array(url.toString, e.getMessage)

Review Comment:
   But sometimes, some Java exceptions information can help users locate the specific problem. For example, the exception of url_decode('http%3A%2F%2spark.apache.org') will indicate that the error is "2s".
   
   > Illegal hex characters in escape (%) pattern - For input string: "2s"
   
   This is beneficial for users to quickly locate, just like the parsing error of sql parse, what do you think?



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


[GitHub] [spark] zzzzming95 commented on a diff in pull request #37636: [SPARK-40156][SQL] url_decode() should the return an ERROR_CLASS

Posted by GitBox <gi...@apache.org>.
zzzzming95 commented on code in PR #37636:
URL: https://github.com/apache/spark/pull/37636#discussion_r954891685


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/urlExpressions.scala:
##########
@@ -110,7 +110,12 @@ object UrlCodec {
   }
 
   def decode(src: UTF8String, enc: UTF8String): UTF8String = {
-    UTF8String.fromString(URLDecoder.decode(src.toString, enc.toString))
+    try {
+      UTF8String.fromString(URLDecoder.decode(src.toString, enc.toString))
+    } catch {
+      case e: IllegalArgumentException =>

Review Comment:
   `URLDecoder.decode(String s, String enc)` throw `UnsupportedEncodingException` when the parameter `enc` is illegal, but in spark, the `enc` parameter is automatically filled by spark and cannot be set by the user (udf: url_decodez() only accepts one parameter). So I think there is no need to handle `UnsupportedEncodingException` exception.
   
   https://github.com/apache/spark/blob/7026b3c77cca6926289d7fbe10360f305f54321c/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/urlExpressions.scala#L90



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


[GitHub] [spark] zzzzming95 commented on a diff in pull request #37636: [SPARK-40156][SQL] url_decode() should the return an ERROR_CLASS

Posted by GitBox <gi...@apache.org>.
zzzzming95 commented on code in PR #37636:
URL: https://github.com/apache/spark/pull/37636#discussion_r954891685


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/urlExpressions.scala:
##########
@@ -110,7 +110,12 @@ object UrlCodec {
   }
 
   def decode(src: UTF8String, enc: UTF8String): UTF8String = {
-    UTF8String.fromString(URLDecoder.decode(src.toString, enc.toString))
+    try {
+      UTF8String.fromString(URLDecoder.decode(src.toString, enc.toString))
+    } catch {
+      case e: IllegalArgumentException =>

Review Comment:
   `URLDecoder.decode(String s, String enc)` throw `UnsupportedEncodingException` when the parameter `enc` is illegal, but in spark, the `enc` parameter is automatically filled by spark and cannot be set by the user (udf: url_decodez() only accepts one parameter). So I think there is no need to handle `UnsupportedEncodingException` exception.
   
   https://github.com/apache/spark/blob/7026b3c77cca6926289d7fbe10360f305f54321c/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/urlExpressions.scala#L95



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


[GitHub] [spark] AmplabJenkins commented on pull request #37636: [SPARK-40156][SQL]url_decode() should the return an ERROR_CLASS

Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on PR #37636:
URL: https://github.com/apache/spark/pull/37636#issuecomment-1225785665

   Can one of the admins verify this patch?


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


[GitHub] [spark] MaxGekk commented on a diff in pull request #37636: [SPARK-40156][SQL] url_decode() should the return an ERROR_CLASS

Posted by GitBox <gi...@apache.org>.
MaxGekk commented on code in PR #37636:
URL: https://github.com/apache/spark/pull/37636#discussion_r955519061


##########
core/src/main/resources/error/error-classes.json:
##########
@@ -632,5 +632,12 @@
       "Writing job aborted"
     ],
     "sqlState" : "40000"
+  },
+  "CANNOT_DECODE_URL" : {

Review Comment:
   Error classes should be sorted by names in the file. Please, put this before `CANNOT_INFER_DATE`



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


[GitHub] [spark] MaxGekk commented on a diff in pull request #37636: [SPARK-40156][SQL] url_decode() should the return an ERROR_CLASS

Posted by GitBox <gi...@apache.org>.
MaxGekk commented on code in PR #37636:
URL: https://github.com/apache/spark/pull/37636#discussion_r955519132


##########
core/src/main/resources/error/error-classes.json:
##########
@@ -632,5 +632,12 @@
       "Writing job aborted"
     ],
     "sqlState" : "40000"
+  },
+  "CANNOT_DECODE_URL" : {
+    "message" : [
+      "Cannot decode url : <url>.",
+      "<details>"
+    ],
+    "sqlState" : "42000"
   }
-}
+}

Review Comment:
   Revert this, please



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


[GitHub] [spark] zzzzming95 commented on a diff in pull request #37636: [SPARK-40156][SQL] url_decode() should the return an ERROR_CLASS

Posted by GitBox <gi...@apache.org>.
zzzzming95 commented on code in PR #37636:
URL: https://github.com/apache/spark/pull/37636#discussion_r954891685


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/urlExpressions.scala:
##########
@@ -110,7 +110,12 @@ object UrlCodec {
   }
 
   def decode(src: UTF8String, enc: UTF8String): UTF8String = {
-    UTF8String.fromString(URLDecoder.decode(src.toString, enc.toString))
+    try {
+      UTF8String.fromString(URLDecoder.decode(src.toString, enc.toString))
+    } catch {
+      case e: IllegalArgumentException =>

Review Comment:
   `URLDecoder.decode(String s, String enc)` throw `UnsupportedEncodingException` when the parameter `enc` is illegal, but in spark, the `enc` parameter is automatically filled by spark and cannot be set by the user (udf: url_decodez() only accepts one parameter). So I think there is no need to handle `UnsupportedEncodingException` exception.



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


[GitHub] [spark] MaxGekk commented on a diff in pull request #37636: [SPARK-40156][SQL] url_decode() should the return an ERROR_CLASS

Posted by GitBox <gi...@apache.org>.
MaxGekk commented on code in PR #37636:
URL: https://github.com/apache/spark/pull/37636#discussion_r954982586


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/urlExpressions.scala:
##########
@@ -110,7 +110,12 @@ object UrlCodec {
   }
 
   def decode(src: UTF8String, enc: UTF8String): UTF8String = {
-    UTF8String.fromString(URLDecoder.decode(src.toString, enc.toString))
+    try {
+      UTF8String.fromString(URLDecoder.decode(src.toString, enc.toString))
+    } catch {
+      case e: IllegalArgumentException =>

Review Comment:
   I see, thank you.



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


[GitHub] [spark] MaxGekk commented on a diff in pull request #37636: [SPARK-40156][SQL] url_decode() should the return an ERROR_CLASS

Posted by GitBox <gi...@apache.org>.
MaxGekk commented on code in PR #37636:
URL: https://github.com/apache/spark/pull/37636#discussion_r955767628


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryExecutionErrors.scala:
##########
@@ -332,6 +332,13 @@ private[sql] object QueryExecutionErrors extends QueryErrorsBase {
       s"If necessary set ${SQLConf.ANSI_ENABLED.key} to false to bypass this error.", e)
   }
 
+  def illegalUrlError(url: UTF8String, e: IllegalArgumentException):
+  Throwable with SparkThrowable = {
+    new SparkIllegalArgumentException(errorClass = "CANNOT_DECODE_URL",
+      messageParameters = Array(url.toString, e.getMessage)

Review Comment:
   We should avoid getting the error message from the nested Java exceptions. For example, if we will translate the error messages in error-classes.json to a local language, your error message will have mixed text in at least 2 languages. There is a mechanism to provide more details via sub-classes but so far let's remove  `<details>`.



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


[GitHub] [spark] MaxGekk closed pull request #37636: [SPARK-40156][SQL] `url_decode()` should the return an error class

Posted by GitBox <gi...@apache.org>.
MaxGekk closed pull request #37636: [SPARK-40156][SQL] `url_decode()` should the return an error class
URL: https://github.com/apache/spark/pull/37636


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