Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

(postponed, requires upstream fix) add support for UUID #24

Merged
merged 2 commits into from
Jan 31, 2025

Conversation

choucavalier
Copy link
Contributor

By default pydantic's UUID fields are serialized as UUID objects by model_dump

This does not work well with pyarrow, which does not support UUID objects but instead a byte representation of them (which can be obtained with my_uuid.bytes).

In the tests, I've added annotated the types with serializers to convert the UUID objects as bytes.

Not sure this is the way to go, though

@simw
Copy link
Owner

simw commented Jan 23, 2025

Thanks for looking at this and submitting a PR!

The underlying issue looks to be related to apache/arrow#43855. Once that is done (and your PR merged here), the conversion should happen seemlessly without the extra serializer. But for now, the serializer is needed.

I'll look at getting the checks to pass and also adding it to the documentation, in order to get this merged soon.

@choucavalier
Copy link
Contributor Author

Thanks! Yes we have to wait for that to be fixed. Right now I had to serialize the UUID as bytes which actually does not work. Let's wait for this to be fixed upstream.

@choucavalier choucavalier marked this pull request as draft January 23, 2025 19:58
@choucavalier choucavalier changed the title add support for UUID (postponed, requires upstream fix) add support for UUID Jan 23, 2025
@simw
Copy link
Owner

simw commented Jan 24, 2025

I think this works now? I've updated the code and tests slightly, mainly to add checks for the pyarrow version (as uuid only comes in pyarrow 18.0 and above). Yes, the serializer workaround is a little awkward, but it works (as far as i can tell) and this library won't have to change if / when the fix in pyarrow is released.

Let me know if you disagree. If not, I'll move ahead, merge and release it.

@simw simw marked this pull request as ready for review January 24, 2025 12:15
@simw simw merged commit 79418af into simw:main Jan 31, 2025
10 checks passed
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants