diff --git a/pandas/tests/io/test_parquet.py b/pandas/tests/io/test_parquet.py index f7eb9a21bb747..6bd05284d93d3 100644 --- a/pandas/tests/io/test_parquet.py +++ b/pandas/tests/io/test_parquet.py @@ -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,23 @@ 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(temp_file, request): + # GH 61602 + df = pd.DataFrame({"id": [uuid.uuid4(), uuid.uuid4()]}) + + df.to_parquet(temp_file, engine="pyarrow") + result = read_parquet(temp_file, engine="pyarrow") + + # If upstream PyArrow nightly/py314 returns raw bytes instead of UUIDs, + # we dynamically add the xfail marker to satisfy both Ruff and Pandas architecture. + if len(result) > 0 and isinstance(result.loc[0, "id"], bytes): + request.node.add_marker( + pytest.mark.xfail( + reason="PyArrow nightly bug: returns raw bytes instead of UUIDs" + ) + ) + + tm.assert_frame_equal(result, df)