Fix Python UDAF Accumulator Interface example to Properly Handle State and Updates with List[Array] Types#1192
Merged
timsaucer merged 7 commits intoapache:mainfrom Jul 28, 2025
Merged
Conversation
- Implement MyAccumulator class following Accumulator interface - Register UDAF named "my_accumulator" in SessionContext - Create test DataFrame and run SQL query using UDAF with GROUP BY - Verify results match expected aggregated values - Ensure correct integration and functionality of UDAF in Python bindings
timsaucer
approved these changes
Jul 28, 2025
Contributor
Author
|
@timsaucer , You're welcome. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue does this PR close?
Rationale for this change
This PR updates the
MyAccumulatorimplementation in the Python UDAF example to properly handle updates and state usinglist[pa.Array]types, aligning with the expected interface in newer versions of PyArrow. Without this change, the accumulator may behave incorrectly or fail when integrating with systems expecting lists of arrays.What changes are included in this PR?
update()method signature to acceptlist[pa.Array]instead of a singlepa.Array.merge()method to correctly index into the first element ofstates, assuming it's a list.state()to return a list ofpa.Arrayinstead of a singlepa.Arrayfor consistency with updated interface expectations.Are these changes tested?
The patch updates an example file, which may be executed to validate expected behavior. If automated tests are not available for this specific UDAF example, manual verification is recommended.
Are there any user-facing changes?
Yes, this affects users who are following or adapting the
sql-using-python-udaf.pyexample. They should now provide and expectlist[pa.Array]forupdate,merge, andstatemethods, in alignment with PyArrow expectations.