EshwarCVS opened a new pull request, #22057: URL: https://github.com/apache/datafusion/pull/22057
## Which issue does this PR close? - Closes #19155 ## Rationale for this change Spark's `make_interval` nullability follows this rule (from Spark source): ```scala nullable = if (failOnError) children.exists(_.nullable) else true Where failOnError maps to DataFusion's enable_ansi_mode. The previous default implementation always reports nullable = true, which is correct for non-ANSI mode (overflow silently returns NULL) but too pessimistic for ANSI mode (overflow throws, so output is only nullable when inputs are). ``` Previous attempts ([#19248](https://github.com/EshwarCVS/datafusion/issues/19248), [#19606](https://github.com/EshwarCVS/datafusion/issues/19606)) tried to derive nullability from input fields inside return_field_from_args, but ReturnFieldArgs carries no ConfigOptions, so ANSI mode was inaccessible. ### What changes are included in this PR? Add ansi_mode: bool field to SparkMakeInterval, populated via a new new_with_config(config) constructor. Implement with_updated_config so the planner keeps the UDF in sync with session config (same pattern as SparkCast). Implement return_field_from_args with Spark's exact rule: nullary call → nullable = false (always returns zero interval) ANSI mode on → nullable = any input field is nullable ANSI mode off (default) → nullable = true In ANSI mode, make_interval_kernel now returns exec_err! on arithmetic overflow instead of silently appending NULL. ### Are these changes tested? Yes. Six new unit tests cover all branches: ``` return_field_nullary_is_not_nullable — zero-arg call is never nullable return_field_non_ansi_always_nullable — non-ANSI: always nullable even with non-null inputs return_field_ansi_mode_not_nullable_when_inputs_not_null — ANSI + non-null inputs → not nullable return_field_ansi_mode_nullable_when_any_input_nullable — ANSI + nullable input → nullable ansi_mode_overflow_returns_error — ANSI mode overflow is an error, not NULL non_ansi_overflow_returns_null — non-ANSI overflow is still NULL (regression guard) All 14 tests (8 existing + 6 new) pass. ``` ### Are there any user-facing changes? Non-ANSI mode (default): no behavior change. ANSI mode: make_interval with non-nullable inputs now correctly reports a non-nullable output field, and arithmetic overflow raises an error instead of silently returning NULL. -- 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]
