Skip to content

Conversation

@Peng-Lei
Copy link
Contributor

What changes were proposed in this pull request?

Refactor some exceptions in QueryExecutionErrors to use error classes. as follows:

columnChangeUnsupportedError
logicalHintOperatorNotRemovedDuringAnalysisError
cannotEvaluateExpressionError
cannotGenerateCodeForExpressionError
cannotTerminateGeneratorError
castingCauseOverflowError
cannotChangeDecimalPrecisionError
invalidInputSyntaxForNumericError
cannotCastFromNullTypeError
cannotCastError
cannotParseDecimalError
simpleStringWithNodeIdUnsupportedError
evaluateUnevaluableAggregateUnsupportedError
dataTypeUnsupportedError
dataTypeUnsupportedError
failedExecuteUserDefinedFunctionError
divideByZeroError
invalidArrayIndexError
mapKeyNotExistError
rowFromCSVParserNotExpectedError

Why are the changes needed?

SPARK-36107

Does this PR introduce any user-facing change?

No

How was this patch tested?

Existed UT Testcase

@AmplabJenkins
Copy link

Can one of the admins verify this patch?

@Peng-Lei Peng-Lei changed the title [WIP][SPARK-36107][SQL] Refactor first set of 20 query execution errors to use error classes [SPARK-36107][SQL] Refactor first set of 20 query execution errors to use error classes Jul 27, 2021
@Peng-Lei Peng-Lei force-pushed the SPARK-36017 branch 2 times, most recently from 245b6a3 to 6ec85b9 Compare July 27, 2021 12:17
@Peng-Lei
Copy link
Contributor Author

Peng-Lei commented Jul 27, 2021

@karenfeng FYI

Copy link
Contributor

@karenfeng karenfeng left a comment

Choose a reason for hiding this comment

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

Thanks for working on this! We'll need to create some new SparkThrowable implementations; if we simply throw the existing exception types, the error class and SQLSTATE are not propagated through.

Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add a new exception type that mixes UnsupportedOperationException with SparkThrowable? It'd look like SparkArithmeticException. Then we can catch these exceptions and use their error classes/SQLSTATEs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Of course, I'll do it. Thank you.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@karenfeng I also add SparkUnsupportedOperationException, SparkIllegalStateException,SparkNumberFormatException,SparkIllegalArgumentException,SparkArrayIndexOutOfBoundsException,SparkNoSuchElementException that with SparkThrowable.

@Peng-Lei Peng-Lei force-pushed the SPARK-36017 branch 8 times, most recently from 43d06f0 to 8f1508c Compare July 28, 2021 13:31
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe that HY represents CLI-specific conditions. This seems to be triggered by overflows; maybe 22023 is a better fit.

Copy link
Contributor Author

@Peng-Lei Peng-Lei Jul 29, 2021

Choose a reason for hiding this comment

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

Yeah. Maybe 22023 is a better fit. The exception is triggered by invalid parameter value. Thank you.

Copy link
Contributor

@karenfeng karenfeng left a comment

Choose a reason for hiding this comment

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

Thanks for doing this! LGTM. @HyukjinKwon, can you also take a look?

@Peng-Lei Peng-Lei force-pushed the SPARK-36017 branch 2 times, most recently from 98d7635 to db6d8d3 Compare August 23, 2021 09:20
1. add SparkUnsupportedOperationException
       SparkIllegalStateException
       SparkNumberFormatException
       SparkIllegalArgumentException
       SparkArrayIndexOutOfBoundsException
       SparkNoSuchElementException
2. change the sqlstate suitable code and order the error in
   error-class.json
3. others
@Peng-Lei
Copy link
Contributor Author

@HyukjinKwon Could you take a look?

HyukjinKwon pushed a commit that referenced this pull request Aug 25, 2021
…xecutionErrors

### What changes were proposed in this pull request?
When we refactor the query execution errors to use error classes in QueryExecutionErrors, we need define some exception that mix SparkThrowable into a base Exception type.
according the example [SparkArithmeticException](https://github.com/apache/spark/blob/f90eb6a5db0778fd18b0b544f93eac3103bbf03b/core/src/main/scala/org/apache/spark/SparkException.scala#L75)

Add SparkXXXException as follows:
- `SparkClassNotFoundException`
- `SparkConcurrentModificationException`
- `SparkDateTimeException`
- `SparkFileAlreadyExistsException`
- `SparkFileNotFoundException`
- `SparkNoSuchMethodException`
- `SparkIndexOutOfBoundsException`
- `SparkIOException`
- `SparkSecurityException`
- `SparkSQLException`
- `SparkSQLFeatureNotSupportedException`

Refactor some exceptions in QueryExecutionErrors to use error classes and new exception for testing new exception

Some added by [PR](#33538) as follows:

- `SparkUnsupportedOperationException`
- `SparkIllegalStateException`
- `SparkNumberFormatException`
- `SparkIllegalArgumentException`
- `SparkArrayIndexOutOfBoundsException`
- `SparkNoSuchElementException`

### Why are the changes needed?
[SPARK-36336](https://issues.apache.org/jira/browse/SPARK-36336)

### Does this PR introduce _any_ user-facing change?
No

### How was this patch tested?
existed ut test

Closes #33573 from Peng-Lei/SPARK-36336.

Authored-by: PengLei <[email protected]>
Signed-off-by: Hyukjin Kwon <[email protected]>
},
"FAILED_EXECUTE_UDF" : {
"message" : [ "Failed to execute user defined function (%s: (%s) => %s)" ],
"sqlState" : "45000"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The SQLSTATE '45000' is not valid. Because it is not included in README

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@karenfeng I delete it.

@HyukjinKwon
Copy link
Member

seems like the tests fail. Can you fix it up please?

@Peng-Lei
Copy link
Contributor Author

seems like the tests fail. Can you fix it up please?

Thank you. Done

@Peng-Lei
Copy link
Contributor Author

@HyukjinKwon
Copy link
Member

Sorry I saw this late. There have been few changes made. @karenfeng mind double checking before we go ahead please?

Copy link
Contributor

@karenfeng karenfeng left a comment

Choose a reason for hiding this comment

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

Thanks for working on this @Peng-Lei! I left some comments - please tag me once you address them.

@Peng-Lei
Copy link
Contributor Author

@karenfeng I've already address the comments. Please check. Thank you.

Copy link
Contributor

@karenfeng karenfeng left a comment

Choose a reason for hiding this comment

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

LGTM, thanks @Peng-Lei! @HyukjinKwon, can you help take a second look?

@HyukjinKwon
Copy link
Member

Merged to master.

@Peng-Lei Peng-Lei deleted the SPARK-36017 branch September 20, 2021 09:16
@Peng-Lei
Copy link
Contributor Author

@karenfeng @HyukjinKwon Thank you!

"message" : [ "Field name %s is ambiguous and has %s matching fields in the struct." ],
"sqlState" : "42000"
},
"CANNOT_CAST_DATATYPE" : {
Copy link
Member

Choose a reason for hiding this comment

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

Any ideas how to trigger this error class? I haven't found any ways how trigger it from user code. WDYT? @cloud-fan @HyukjinKwon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants