Skip to content

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

@andygrove

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions