Skip to content

Comments

[SPARK-40530][SQL] Add error-related developer APIs#37969

Closed
cloud-fan wants to merge 2 commits intoapache:masterfrom
cloud-fan:error
Closed

[SPARK-40530][SQL] Add error-related developer APIs#37969
cloud-fan wants to merge 2 commits intoapache:masterfrom
cloud-fan:error

Conversation

@cloud-fan
Copy link
Contributor

What changes were proposed in this pull request?

Third-party Spark plugins may define their own errors using the same framework as Spark: put error definition in json files. This PR moves some error-related code to a new file and marks them as developer APIs, so that others can reuse them instead of writing its own json reader.

Why are the changes needed?

make it easier for Spark plugins to define errors.

Does this PR introduce any user-facing change?

no

How was this patch tested?

existing tests

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not related to this PR, but I found this method is not called anywhere.

@cloud-fan
Copy link
Contributor Author

cc @MaxGekk @viirya

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this method is called no where.

Copy link
Contributor Author

@cloud-fan cloud-fan Sep 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MaxGekk I think this is a mistake. The STANDARD mode is a combination of PRETTY and MINIMAL mode: it can get all the structured information, as well as the original pretty message.

Copy link
Member

@MaxGekk MaxGekk Sep 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The STANDARD mode is a combination of PRETTY and MINIMAL mode

From where it comes? In the current implementation, the info is orthogonal. If you need, you can substitute params yourself as you want.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, we should allow the caller side to do substitution as they want.

* A reader to load error information from one or more JSON files. Note that, if one error appears
* in more than one JSON files, the latter wins.
*/
@DeveloperApi
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a developer API, do we need to briefly describe the error JSON format here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added the reference to the readme file of the error framework.

val subErrorClass = errorClasses.tail.headOption
val errorInfo = errorInfoMap.getOrElse(
mainErrorClass,
throw SparkException.internalError(s"Cannot find error class '$errorClass'"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here should be mainErrorClass? in the internal error message?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's better to include more information and put the full error class (main + sub)

} else {
val errorSubInfo = errorInfo.subClass.get.getOrElse(
subErrorClass.get,
throw SparkException.internalError(s"Cannot find sub error class '${subErrorClass.get}'"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not keep IllegalArgumentException?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because this means a bug and it's better to throw intenal error.


test("Check if error class is missing") {
val ex1 = intercept[IllegalArgumentException] {
val ex1 = intercept[SparkException] {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

@viirya viirya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall. Just a few minor comments.

| }
|}
|""".stripMargin)
val reader = new ErrorClassesJsonReader(Seq(errorJsonFilePath.toUri.toURL, json.toURL))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you use the existing JSON file? How can you guarantee that one JSON overrides the standard one? Maybe you will add small one for testing to check that it overrides error-classes.json?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test uses 2 JSON files: the existing official one and a temporary one which was written in this test.

@cloud-fan
Copy link
Contributor Author

thanks for review, merging to master!

@cloud-fan cloud-fan closed this in 2bf26df Sep 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants