Vyrham opened a new pull request, #454: URL: https://github.com/apache/datafusion-spark/pull/454
Closes #192. Closes #193. Implements Spark-compatible `raise_error` and `assert_true` as one PR, since `assert_true` lowers to `raise_error` exactly as Spark does. `raise_error(expr)` raises `[USER_RAISED_EXCEPTION] <expr> SQLSTATE: P0001` (Spark 4.0+ form) and returns VOID; it is volatile and deliberately not null-intolerant, so `raise_error(NULL)` raises with message `null`. `assert_true` rewrites to `If(cond, NULL, raise_error(msg))` in `simplify`, with a native `invoke_with_args` fallback for plans that bypass simplification; its default message follows Spark 4.1+ `toPrettySQL` (binary conditions and `NOT` parenthesised, literals not). Includes Rust unit tests and sqllogictest coverage (`misc/raise_error.slt`, `misc/assert_true.slt`) and updates the function docs. Notes for reviewers: - The docs in `docs/functions/` were updated by hand following the docgen format; please let me know if `dev/update_function_docs.sh` produces anything different and I will align them. - Known divergence, documented in the code and the `.slt` header: a cast condition renders as DataFusion writes it (`'CAST(0 AS Boolean)' is not true!`) where Spark 4.1+ writes `'0'`; the two-argument form with a caller-supplied message is the primary API for an exact message. The default message also differs between `simplify` mode (expression rendering) and `evaluate` mode (value rendering) for column conditions, so those cases are asserted loosely in the `.slt`. - Open questions: is the Spark 4.1+ `toPrettySQL` default-message rendering the right alignment, given the cast-condition divergence? Should `spark.sql.legacy.raiseErrorWithoutErrorClass` be supported, or is error-class-only acceptable? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
