You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Sean R. Owen (Jira)" <ji...@apache.org> on 2022/08/31 17:01:00 UTC

[jira] [Commented] (SPARK-40290) Uncatchable exceptions in SparkSession Java API

    [ https://issues.apache.org/jira/browse/SPARK-40290?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17598506#comment-17598506 ] 

Sean R. Owen commented on SPARK-40290:
--------------------------------------

It doesn't make sense to consider it a RuntimeException. You're identifying a general issue with how Scala code looks from Java. Yes, sometimes not convenient, but not specific to Spark.

> 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
>            Priority: Major
>
> 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-unsubscribe@spark.apache.org
For additional commands, e-mail: issues-help@spark.apache.org