Skip to content

[SPARK-37945][SQL][CORE] Use error classes in the execution errors of arithmetic ops#38273

Closed
khalidmammadov wants to merge 13 commits intoapache:masterfrom
khalidmammadov:error_class2
Closed

[SPARK-37945][SQL][CORE] Use error classes in the execution errors of arithmetic ops#38273
khalidmammadov wants to merge 13 commits intoapache:masterfrom
khalidmammadov:error_class2

Conversation

@khalidmammadov
Copy link
Contributor

What changes were proposed in this pull request?

Migrate the following errors in QueryExecutionErrors onto use error classes:

unscaledValueTooLargeForPrecisionError -> UNSCALED_VALUE_TOO_LARGE_FOR_PRECISION
decimalPrecisionExceedsMaxPrecisionError -> DECIMAL_PRECISION_EXCEEDS_MAX_PRECISION
integerOverflowError -> INTEGER_OVERFLOW
outOfDecimalTypeRangeError -> OUT_OF_DECIMAL_TYPE_RANGE

Why are the changes needed?

Porting ArithmeticExceptions to the new error framework

Does this PR introduce any user-facing change?

Yes, errors will indicate that it's controlled Spark exception

How was this patch tested?

./build/sbt "catalyst/testOnly org.apache.spark.sql.types.DecimalSuite"
./build/sbt "sql/testOnly org.apache.spark.sql.execution.streaming.sources.RateStreamProviderSuite"
./build/sbt "core/testOnly testOnly org.apache.spark.SparkThrowableSuite"

@khalidmammadov khalidmammadov changed the title [SPARK-37945][SQL][CATALYST] Use error classes in the execution errors of arithmetic ops [SPARK-37945][SQL][CORE] Use error classes in the execution errors of arithmetic ops Oct 16, 2022
@khalidmammadov
Copy link
Contributor Author

@MaxGekk Please review

Copy link
Member

Choose a reason for hiding this comment

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

Does the error class have at least one test? If not, please add one. The same question about other new error classes.

Copy link
Contributor

Choose a reason for hiding this comment

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

I am pretty sure there is one already: _LEGACY_ERROR_TEMP_2118.

Please double check before adding more new error messages.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@amaliujia apart from INTEGER_OVERFLOW rest of the changes are merely replacing name for the existing class metaname
@MaxGekk all of these are already unit tested within relevant use cases via intercept[] but I can work on changing those cases to assert additionally the class name/msg using checkError( ... errorClass="CLASS_NAME")

Copy link
Member

Choose a reason for hiding this comment

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

I can work on changing those cases to assert additionally the class name/msg using checkError ...

Please, do that. The purpose is to make the tests independent from error messages (only valuable message parameters), so, in this way tech editors could edit error message in error-classes.json and don't worry about internal Spark 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.

sure, working on it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@MaxGekk Can you please check if all good or not?

@AmplabJenkins
Copy link

Can one of the admins verify this patch?

Copy link
Member

Choose a reason for hiding this comment

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

What's the difference with ARITHMETIC_OVERFLOW? Can't you re-use the last one?

Copy link
Member

Choose a reason for hiding this comment

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

nit: Please, upper case the first letter to be consistent w/ other error messages.

Copy link
Member

Choose a reason for hiding this comment

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

ANSIEnabled -> ansiConfig, see other error classes.

Copy link
Member

Choose a reason for hiding this comment

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

The method integerOverflowError is invoked from only 2 places. Let's introduce specific error classes for both cases, and don't pass arbitrary message.

Could you image that we will output errors according to locale in a local language. In that case, we will translate entire error-classes.json to the language but some text will pass in English from source code. That looks inconsistent.

Copy link
Member

Choose a reason for hiding this comment

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

Could you re-use the existing exception: SparkRuntimeException, please. We don't need to introduce additional things as we already have error classes that users can use to distinguish errors.

Comment on lines 2390 to 2392
Copy link
Member

Choose a reason for hiding this comment

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

Comment on lines 2402 to 2404
Copy link
Member

Choose a reason for hiding this comment

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

Please, fix indentation.

Copy link
Member

Choose a reason for hiding this comment

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

Wrap the config by toSQLConf(), see example in the file.

@MaxGekk
Copy link
Member

MaxGekk commented Oct 22, 2022

@khalidmammadov Could you re-trigger tests/builds by merging the recent master, please.

@MaxGekk
Copy link
Member

MaxGekk commented Oct 23, 2022

+1, LGTM. Merging to master.
Thank you, @khalidmammadov and @amaliujia for review.

@MaxGekk MaxGekk closed this in 6c00918 Oct 23, 2022
@khalidmammadov
Copy link
Contributor Author

@MaxGekk thanks for reviews and merge!

SandishKumarHN pushed a commit to SandishKumarHN/spark that referenced this pull request Dec 12, 2022
… arithmetic ops

### What changes were proposed in this pull request?
Migrate the following errors in QueryExecutionErrors onto use error classes:

unscaledValueTooLargeForPrecisionError -> UNSCALED_VALUE_TOO_LARGE_FOR_PRECISION
decimalPrecisionExceedsMaxPrecisionError -> DECIMAL_PRECISION_EXCEEDS_MAX_PRECISION
integerOverflowError -> INTEGER_OVERFLOW
outOfDecimalTypeRangeError -> OUT_OF_DECIMAL_TYPE_RANGE

### Why are the changes needed?
Porting ArithmeticExceptions to the new error framework

### Does this PR introduce _any_ user-facing change?
Yes, errors will indicate that it's controlled Spark exception

### How was this patch tested?
./build/sbt "catalyst/testOnly org.apache.spark.sql.types.DecimalSuite"
./build/sbt "sql/testOnly org.apache.spark.sql.execution.streaming.sources.RateStreamProviderSuite"
./build/sbt "core/testOnly testOnly org.apache.spark.SparkThrowableSuite"

Closes apache#38273 from khalidmammadov/error_class2.

Lead-authored-by: Khalid Mammadov <khalidmammadov9@gmail.com>
Co-authored-by: khalidmammadov <khalidmammadov9@gmail.com>
Signed-off-by: Max Gekk <max.gekk@gmail.com>
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.

4 participants