Skip to content

Native divide-by-zero in a dispatched ScalaUDF surfaces CometNativeException instead of SparkArithmeticException #4517

Description

@andygrove

When a ScalaUDF dispatched into the native plan (#4514) participates in an expression that raises a divide-by-zero under ANSI mode (e.g. 1/udf(a)), the error surfaces as org.apache.comet.CometNativeException ("DivideByZero") instead of the Spark org.apache.spark.SparkArithmeticException with error class DIVIDE_BY_ZERO. DataFusion wraps the typed error so the JNI bridge cannot downcast it back to the matching Spark exception.

This is observable in Spark's SQLQueryTestSuite golden test udf/postgreSQL/udf-select_having.sql (query SELECT 1 AS one FROM test_having WHERE 1/udf(a) = 1 HAVING 1 < 2). Same error category, different surface.

Follow-on from #4514. We should preserve the typed Spark exception (exception class plus error class) end to end so native evaluation matches Spark's ANSI error behavior.

Activity

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

Metadata

Metadata

Assignees

Labels

area:expressionsExpression evaluationpriority:mediumFunctional bugs, performance regressions, broken features

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions