You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "watanaberin (via GitHub)" <gi...@apache.org> on 2025/12/10 22:31:07 UTC
[PR] fix: spark crc32 custom nullability [datafusion]
watanaberin opened a new pull request, #19271:
URL: https://github.com/apache/datafusion/pull/19271
## Which issue does this PR close?
<!--
We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123.
-->
- Closes #19157
## Rationale for this change
<!--
Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed.
Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes.
-->
The `crc32` UDF was using the default return_type implementation which does not preserve nullability information [Spark CRC32](https://github.com/apache/spark/blob/master/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/hash.scala#L213-L240)
* Only returns the data type (Int64)
* Doesn't consider nullability of inputs
* Would always mark output as non-nullable
## What changes are included in this PR?
<!--
There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
-->
* Implemented `return_field_from_args`: Creates a field with Int64 type and correctly propagates nullability from input fields and scalar arguments
* Updated `return_type`: Now returns an error directing users to use return_field_from_args instead
* Added necessary imports: `Field`, `FieldRef`, and `ReturnFieldArgs` to support the new implementation
* Added comprehensive nullability tests: Verifies that nullable inputs, non-nullable inputs, and null scalar literals are handled correctly
## Are these changes tested?
<!--
We typically require tests for all PRs in order to:
1. Prevent the code from being accidentally broken by subsequent changes
2. Serve as another way to document the expected behavior of the code
If tests are not included in your PR, please explain why (for example, are they covered by existing tests)?
-->
* Non-nullable Binary input produces non-nullable Int64 output
* Nullable Binary input produces nullable Int64 output
* Null scalar literal (e.g., crc32(NULL)) produces nullable Int64 output
* Data type is correctly set to Int64 in all cases
## Are there any user-facing changes?
<!--
If there are user-facing changes then we may require documentation to be updated before approving the PR.
-->
<!--
If there are any breaking changes to public APIs, please add the `api change` label.
-->
This is a bug fix that corrects schema metadata only, it does not change the actual computation or introduce any breaking changes to the API.
--
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: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] fix: spark crc32 custom nullability [datafusion]
Posted by "Jefffrey (via GitHub)" <gi...@apache.org>.
Jefffrey commented on PR #19271:
URL: https://github.com/apache/datafusion/pull/19271#issuecomment-3679666049
Thanks @watanaberin & @comphead
--
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: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] fix: spark crc32 custom nullability [datafusion]
Posted by "Jefffrey (via GitHub)" <gi...@apache.org>.
Jefffrey merged PR #19271:
URL: https://github.com/apache/datafusion/pull/19271
--
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: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org