Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SPARK-48806][SQL] Pass actual exception when url_decode fails
### What changes were proposed in this pull request? Pass actual exception for url_decode. Follow-up to https://issues.apache.org/jira/browse/SPARK-40156 ### Why are the changes needed? Currently url_decode function ignores actual exception, which contains information that is useful for quickly locating the problem. Like executing this sql: ``` select url_decode('https%3A%2F%2spark.apache.org'); ``` We only get the error message: ``` org.apache.spark.SparkIllegalArgumentException: [CANNOT_DECODE_URL] The provided URL cannot be decoded: https%3A%2F%2spark.apache.org. Please ensure that the URL is properly formatted and try again. at org.apache.spark.sql.errors.QueryExecutionErrors$.illegalUrlError(QueryExecutionErrors.scala:376) at org.apache.spark.sql.catalyst.expressions.UrlCodec$.decode(urlExpressions.scala:118) at org.apache.spark.sql.catalyst.expressions.UrlCodec.decode(urlExpressions.scala) ``` However, the actual useful exception information is ignored: ``` java.lang.IllegalArgumentException: URLDecoder: Illegal hex characters in escape (%) pattern - Error at index 1 in: "2s" ``` After this pr we will get: ``` org.apache.spark.SparkIllegalArgumentException: [CANNOT_DECODE_URL] The provided URL cannot be decoded: https%3A%2F%2spark.apache.org. Please ensure that the URL is properly formatted and try again. SQLSTATE: 22546 at org.apache.spark.sql.errors.QueryExecutionErrors$.illegalUrlError(QueryExecutionErrors.scala:372) at org.apache.spark.sql.catalyst.expressions.UrlCodec$.decode(urlExpressions.scala:119) at org.apache.spark.sql.catalyst.expressions.UrlCodec.decode(urlExpressions.scala) ... Caused by: java.lang.IllegalArgumentException: URLDecoder: Illegal hex characters in escape (%) pattern - Error at index 1 in: "2s" at java.base/java.net.URLDecoder.decode(URLDecoder.java:237) at java.base/java.net.URLDecoder.decode(URLDecoder.java:147) at org.apache.spark.sql.catalyst.expressions.UrlCodec$.decode(urlExpressions.scala:116) ... 135 more ``` ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? unit test ### Was this patch authored or co-authored using generative AI tooling? No Closes apache#47211 from wForget/SPARK-48806. Lead-authored-by: wforget <[email protected]> Co-authored-by: Kent Yao <[email protected]> Signed-off-by: Kent Yao <[email protected]> (cherry picked from commit 310f8ea) Signed-off-by: Kent Yao <[email protected]>
- Loading branch information