Skip to content

fix: implement custom nullability for spark abs function - #19395

Merged
Jefffrey merged 5 commits into
apache:mainfrom
batmnnn:fix-spark-abs-nullability
Dec 25, 2025
Merged

Jefffrey merged 5 commits into
apache:mainfrom
batmnnn:fix-spark-abs-nullability

Conversation

@batmnnn

@batmnnn batmnnn commented Dec 19, 2025

Copy link
Copy Markdown
Contributor

Fixes apache/datafusion #19162

The SparkAbs UDF was using the default is_nullable=true for all outputs, even when inputs were non-nullable. This commit implements return_field_from_args to properly propagate nullability from input arguments.

Changes:

  • Add return_field_from_args implementation to SparkAbs
  • Output nullability now matches input nullability
  • Handle edge case where scalar argument is explicitly null
  • Add tests for nullability behavior

Which issue does this PR close?

Closes #19162

Rationale for this change

SparkAbs was always returning nullable=true even for non-nullable inputs.

What changes are included in this PR?

Implement return_field_from_args to propagate nullability from input arguments.

Are these changes tested?

Yes, added 2 tests for nullability behavior.

Are there any user-facing changes?

No.

Fixes apache#19162

The SparkAbs UDF was using the default is_nullable=true for all outputs,
even when inputs were non-nullable. This commit implements
return_field_from_args to properly propagate nullability from input
arguments.

Changes:
- Add return_field_from_args implementation to SparkAbs
- Output nullability now matches input nullability
- Handle edge case where scalar argument is explicitly null
- Add tests for nullability behavior
@github-actions github-actions Bot added the spark label Dec 19, 2025
@batmnnn

batmnnn commented Dec 19, 2025

Copy link
Copy Markdown
Contributor Author

@martin-g @rluvaton can you please review this

Comment thread datafusion/spark/src/function/math/abs.rs Outdated
Comment thread datafusion/spark/src/function/math/abs.rs Outdated
Co-authored-by: Martin Grigorov <martin-g@users.noreply.github.com>
@batmnnn

batmnnn commented Dec 19, 2025

Copy link
Copy Markdown
Contributor Author

thanks @martin-g

Comment thread datafusion/spark/src/function/math/abs.rs Outdated
Comment thread datafusion/spark/src/function/math/abs.rs Outdated
@Jefffrey
Jefffrey added this pull request to the merge queue Dec 25, 2025
Merged via the queue into apache:main with commit e586ff5 Dec 25, 2025
27 checks passed
@Jefffrey

Copy link
Copy Markdown
Contributor

Thanks @batmnnn & @martin-g

@batmnnn

batmnnn commented Dec 25, 2025

Copy link
Copy Markdown
Contributor Author

thanks for guidance and help @Jefffrey & @martin-g

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

Labels

3 participants