fix: surface SparkArithmeticException(DIVIDE_BY_ZERO) for divide-by-zero in dispatched ScalaUDF path#4653
Open
0lai0 wants to merge 3 commits into
Open
fix: surface SparkArithmeticException(DIVIDE_BY_ZERO) for divide-by-zero in dispatched ScalaUDF path#46530lai0 wants to merge 3 commits into
0lai0 wants to merge 3 commits into
Conversation
Member
Contributor
Author
|
Thanks @andygrove. Just to confirm, should I revert both the #4517 workaround (SQLQueryTestSuite DIVIDE_BY_ZERO) and the #4516 workaround (SQLQuerySuite UDF call-count) from dev/diffs? The #4517 one is clearly no longer needed with this fix, but wanted to check on #4516 since that issue is still open. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue does this PR close?
Closes #4517 .
Rationale for this change
DataFusion 53+ wraps errors with
.context(...), producingDataFusionError::Context(_, Box<inner>).Previous handling mostly matched top-level
DataFusionError::External(...), soContext-wrapped Spark errors could bypass typed conversion and leak asCometNativeExceptioninstead of Spark’sSparkArithmeticException(DIVIDE_BY_ZERO).What changes are included in this PR?
native/core/src/execution/expressions/arithmetic.rsCheckedBinaryExpr::evaluatenow matches genericErr(e)(when query context exists), then recursively extractsSparkErrorviaextract_spark_error.DataFusionError::Contextand nestedExternal.Err(e)as-is (instead of re-wrapping asExternal).native/jni-bridge/src/errors.rsSparkPayloadandextract_spark_payloadto recursively unwrapContext/ nestedExternal.throw_exceptionnow handles allCometError::DataFusion { source }throughextract_spark_payload, covering:JavaExceptionpassthroughSparkErrorWithContextJSON throw pathSparkErrorJSON throw pathspark/src/test/scala/org/apache/comet/CometCodegenSuite.scaladivide-by-zero through dispatched ScalaUDF surfaces SparkArithmeticException (#4517).SELECT 1 / identity_int(a)over data containing zero, and validates exception propagation semantics.How are these changes tested?
./mvnw test -Dtest=none -Dsuites=org.apache.comet.CometCodegenSuite