-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-46490][SQL] Require error classes in SparkThrowable sub-classes
#44464
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SPARK-46490][SQL] Require error classes in SparkThrowable sub-classes
#44464
Conversation
dongjoon-hyun
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you make the CI happy? The failure messages seem to be related.
|
I am trying to fix some issues in the PR #44468. So far, will convert this PR to a draft. |
SparkThrowable sub-classesSparkThrowable sub-classes
connector/connect/server/src/main/scala/org/apache/spark/sql/connect/utils/ErrorUtils.scala
Outdated
Show resolved
Hide resolved
| params.errorClass.orNull, | ||
| params.messageParameters, | ||
| params.queryContext)), | ||
| errorConstructor[NumberFormatException](params => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before this PR, we converted Java exception to Spark exception at the client side by passing the message as is (error class and message parameters was null or empty) like: NumberFormatException("invalid format 9hh99") -> SparkNumberFormatException("invalid format 9hh99", errorClass = null).
After the changes, the conversion still exists but I put the original message to a parameter:
NumberFormatException("invalid format 9hh99") -> SparkNumberFormatException(errorClass = "_LEGACY_ERROR_TEMP_3104", messageParameters = Map("message" -> "invalid format 9hh99"))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Eventually, we should convert all Java exceptions to Spark exceptions but since Spark SQL still raises such exceptions, different error class will allow to identify which Java exceptions haven't been ported yet.
SparkThrowable sub-classesSparkThrowable sub-classes
|
@cloud-fan @dongjoon-hyun @HyukjinKwon @heyihong Please, review this PR. |
|
Could you make the CI successful, @MaxGekk ? |
|
@dongjoon-hyun I guess Run / Run Spark on Kubernetes Integration test is not related to the changes, but I re-ran it again. I am observing the same failure in other PRs. |
heyihong
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with one nit
.../client/jvm/src/test/scala/org/apache/spark/sql/connect/client/SparkConnectClientSuite.scala
Outdated
Show resolved
Hide resolved
heyihong
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On a second look, we may need some logics to handle cases that error classes are actually set
| params.queryContext)), | ||
| errorConstructor[NumberFormatException](params => | ||
| new SparkNumberFormatException( | ||
| errorClass = "_LEGACY_ERROR_TEMP_3104", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, this may need some special handling since params.errorClass and params.messageParameters may be set
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe
errorClass = params.errorClass.orElse("_LEGACY_ERROR_TEMP_3104"),
messageParameters = params.errorClass match {
case Some(_) => params.messageParameters
case None => Map("message" -> params.message)
}There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How can it be set for non-SparkThrowable like here NumberFormatException?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
params.errorClass is None for non SparkThrowable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
got it. will do.
...nnect/common/src/main/scala/org/apache/spark/sql/connect/client/GrpcExceptionConverter.scala
Outdated
Show resolved
Hide resolved
...nnect/common/src/main/scala/org/apache/spark/sql/connect/client/GrpcExceptionConverter.scala
Outdated
Show resolved
Hide resolved
| params.message, | ||
| params.errorClass, | ||
| params.messageParameters)), | ||
| errorClass = "_LEGACY_ERROR_TEMP_3107", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
...nnect/common/src/main/scala/org/apache/spark/sql/connect/client/GrpcExceptionConverter.scala
Outdated
Show resolved
Hide resolved
...nnect/common/src/main/scala/org/apache/spark/sql/connect/client/GrpcExceptionConverter.scala
Outdated
Show resolved
Hide resolved
| errorClass = Some("DUPLICATE_KEY"), | ||
| messageParameters = Map("keyColumn" -> "`abc`"), | ||
| queryContext = Array.empty) | ||
| val error = constructor(testParams) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be nice to update the test to cover both errorClass = Some(...) and errorClass = None
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
|
Merging to master. Thank you, @heyihong and @dongjoon-hyun for review. |
What changes were proposed in this pull request?
In the PR, I propose to create
SparkThrowablesub-classes only with an error class by making the constructor withmessageprivate.Why are the changes needed?
To improve user experience with Spark SQL by unifying error exceptions: the final goal is all Spark exception should contain an error class.
Does this PR introduce any user-facing change?
No since user's code shouldn't throw
SparkThrowablesub-classes but it can if it depends on error message formats.How was this patch tested?
By existing test test suites like:
Was this patch authored or co-authored using generative AI tooling?
No.