Fix Python UDAF Accumulator Interface example to Properly Handle State and Updates with List[Array] Types #1192
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
MyAccumulator
implementation 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.Array
instead of a singlepa.Array
for 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.py
example. They should now provide and expectlist[pa.Array]
forupdate
,merge
, andstate
methods, in alignment with PyArrow expectations.