MaxGekk opened a new pull request #35467:
URL: https://github.com/apache/spark/pull/35467


   ### What changes were proposed in this pull request?
   In the PR, I propose to propagate `SparkThrowable` to user space AS IS in 
constructing of function builder. This allows to preserve the error class, for 
instance.
   
   ### Why are the changes needed?
   This fixes the issues portrayed by the example below:
   ```scala
   scala> try { sql("select format_string('%0$s', 'Hello')") } catch { case e: 
org.apache.spark.sql.AnalysisException => println(e.getErrorClass) }
   null
   ``` 
   The expected error should be `ILLEGAL_SUBSTRING`. It sets at 
https://github.com/apache/spark/blob/899d3bb44d7c72dc0179545189ac8170bde993a8/sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryCompilationErrors.scala#L71.
   
   ### Does this PR introduce _any_ user-facing change?
   Yes, the PR changes exceptions that can be handles by users.
   
   After the changes:
   ```scala
   scala> try { sql("select format_string('%0$s', 'Hello')") } catch { case e: 
org.apache.spark.sql.AnalysisException => println(e.getErrorClass) }
   ILLEGAL_SUBSTRING
   ```
   
   ### How was this patch tested?
   By running new test:
   ```
   $ build/sbt "test:testOnly *QueryCompilationErrorsSuite"
   ```


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