Skip to content

Conversation

kosiew
Copy link
Contributor

@kosiew kosiew commented Jul 27, 2025

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 using list[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?

  • Updated update() method signature to accept list[pa.Array] instead of a single pa.Array.
  • Modified the merge() method to correctly index into the first element of states, assuming it's a list.
  • Changed state() to return a list of pa.Array instead of a single pa.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 expect list[pa.Array] for update, merge, and state methods, in alignment with PyArrow expectations.

kosiew added 7 commits July 27, 2025 15:38
- 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
Copy link
Member

@timsaucer timsaucer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @kosiew !

@timsaucer timsaucer merged commit be88837 into apache:main Jul 28, 2025
17 checks passed
@kosiew
Copy link
Contributor Author

kosiew commented Jul 29, 2025

@timsaucer , You're welcome.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

the python udaf example cannot print the result

2 participants