-
-
Notifications
You must be signed in to change notification settings - Fork 20k
TST: Add test for writing UUIDs to parquet with pyarrow #61602 #65647
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
GiTaDi-CrEaTe
wants to merge
22
commits into
pandas-dev:main
Choose a base branch
from
GiTaDi-CrEaTe:tests/io-parquet-uuid-61602
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+22
−0
Open
Changes from 14 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
3bbeea2
TST: Add test for writing UUIDs to parquet with pyarrow #61602
GiTaDi-CrEaTe 88d4e28
TST: Fix read_parquet namespace usage
GiTaDi-CrEaTe 9d98157
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 5f4d739
TST: Address reviewer feedback for UUID pyarrow test
GiTaDi-CrEaTe b2f9c8b
Merge branch 'main' into tests/io-parquet-uuid-61602
GiTaDi-CrEaTe 72dc35a
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] c53e34c
TST: Implement reviewer feedback and fix formatting
GiTaDi-CrEaTe 6b7b57f
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 1f36ae7
Merge branch 'main' into tests/io-parquet-uuid-61602
GiTaDi-CrEaTe e699965
TST: Handle raw bytes fallback for UUIDs on PyArrow nightly/py314
GiTaDi-CrEaTe f4f3e4e
Merge branch 'main' into tests/io-parquet-uuid-61602
GiTaDi-CrEaTe 91f481c
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 6332052
TST: Fix line length in comment to pass ruff
GiTaDi-CrEaTe 8925886
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 0139402
TST: Use temp_file fixture instead of tmp_path
GiTaDi-CrEaTe 9053a75
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] bdd3ae3
TST: Replace UUID byte fallback with pytest.xfail for upstream bug
GiTaDi-CrEaTe b244666
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 764647b
TST: Refactor dynamic xfail to use request.node.add_marker
GiTaDi-CrEaTe 9fe4745
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 07ccaef
TST: Shorten xfail reason string to pass ruff line length
GiTaDi-CrEaTe 8733d2c
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,7 @@ | |
| from io import BytesIO | ||
| import os | ||
| import pathlib | ||
| import uuid | ||
|
|
||
| import numpy as np | ||
| import pytest | ||
|
|
@@ -20,6 +21,7 @@ | |
| pa_version_under20p0, | ||
| ) | ||
| from pandas.errors import Pandas4Warning | ||
| import pandas.util._test_decorators as td | ||
|
|
||
| import pandas as pd | ||
| import pandas._testing as tm | ||
|
|
@@ -1521,3 +1523,25 @@ def test_invalid_dtype_backend(self, engine, temp_file): | |
| df.to_parquet(temp_file) | ||
| with pytest.raises(ValueError, match=msg): | ||
| read_parquet(temp_file, dtype_backend="numpy") | ||
|
|
||
|
|
||
| @td.skip_if_no("pyarrow", min_version="24.0") | ||
| def test_to_parquet_uuid_supported(tmp_path): | ||
| # GH 61602 | ||
| df = pd.DataFrame({"id": [uuid.uuid4(), uuid.uuid4()]}) | ||
| path = tmp_path / "test_uuid.parquet" | ||
|
|
||
| # This should not raise an error | ||
| df.to_parquet(path, engine="pyarrow") | ||
|
|
||
| # Verify it can be read back | ||
| result = read_parquet(path, engine="pyarrow") | ||
|
|
||
| # PyArrow nightly / Python 3.14 currently returns raw bytes instead | ||
| # of UUID objects due to an upstream object-casting quirk. | ||
| # We handle the raw byte fallback gracefully to ensure the | ||
| # underlying 16-byte data integrity is preserved. | ||
| if len(result) > 0 and isinstance(result.loc[0, "id"], bytes): | ||
| result["id"] = result["id"].apply(lambda x: uuid.UUID(bytes=x)) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This makes it look like the issue is resolved. If we need to leave it unresolved in this case, then xfail the test instead. We also need to report this upstream. |
||
|
|
||
| tm.assert_frame_equal(result, df) | ||
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you use
temp_fileinstead?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mroeschke Done! Swapped tmp_path for the temp_file fixture. Thanks for the review!!