[ https://issues.apache.org/jira/browse/SPARK-40290?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17598747#comment-17598747 ]
Gérald Quintana commented on SPARK-40290: ----------------------------------------- I agree that if I was using the SparkSession from Scala I wouldn't be impacted. Yet I don't fully agree that it's general, first because SparkSession is a public API which is designed and documented to be used in Java (I wouldn' mind if this was in Scala internals), then because it's specific to the sql method and the AnalysisException tree. The issue title should be changed to reflect this. > 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-unsubscr...@spark.apache.org For additional commands, e-mail: issues-h...@spark.apache.org