Gérald Quintana created SPARK-40290:
---------------------------------------

             Summary: Uncatchable exceptions in SparkSession Java API
                 Key: SPARK-40290
                 URL: https://issues.apache.org/jira/browse/SPARK-40290
             Project: Spark
          Issue Type: Improvement
          Components: SQL
    Affects Versions: 3.2.1
            Reporter: Gérald Quintana


SparkSession#sql may raise exceptions extending 
org.apache.spark.sql.AnalysisException like 
org.apache.spark.sql.catalyst.analysis.NoSuchPartitionException for instance. 
These exceptions extend java.lang.Exception.

As a result, they are considered as *checked* Exception by the Java compiler, 
they can not be caught from Java code because the Java compiler considers 
SparkSession#sql doesn't throw this kind of method (there is not throws 
AnalysisException in the signature).

The only workaround is to catch java.lang.Exception which produces a very wide 
catch.

A cleaner solution would be to make org.apache.spark.sql.AnalysisException 
extends java.lang.RuntimeException



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@spark.apache.org
For additional commands, e-mail: issues-h...@spark.apache.org

Reply via email to