Skip to content

Commit ae7d919

Browse files
committed
GH-48254: [Python][Parquet] Support extension types in read_schema
1 parent 8ee7aeb commit ae7d919

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

python/pyarrow/parquet/core.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,9 @@ class ParquetFile:
259259
If nothing passed, will be inferred based on path.
260260
Path will try to be found in the local on-disk filesystem otherwise
261261
it will be parsed as an URI to determine the filesystem.
262+
arrow_extensions_enabled : bool, default True
263+
If True, read Parquet logical types as Arrow extension types where
264+
possible.
262265
page_checksum_verification : bool, default False
263266
If True, verify the checksum for each page read from the file.
264267
arrow_extensions_enabled : bool, default True
@@ -2382,7 +2385,7 @@ def read_metadata(where, memory_map=False, decryption_properties=None,
23822385

23832386

23842387
def read_schema(where, memory_map=False, decryption_properties=None,
2385-
filesystem=None):
2388+
filesystem=None, arrow_extensions_enabled=True):
23862389
"""
23872390
Read effective Arrow schema from Parquet file metadata.
23882391
@@ -2422,11 +2425,15 @@ def read_schema(where, memory_map=False, decryption_properties=None,
24222425

24232426
with file_ctx:
24242427
file = ParquetFile(
2425-
where, memory_map=memory_map,
2426-
decryption_properties=decryption_properties)
2428+
where,
2429+
memory_map=memory_map,
2430+
decryption_properties=decryption_properties,
2431+
arrow_extensions_enabled=arrow_extensions_enabled,
2432+
)
2433+
if arrow_extensions_enabled:
2434+
return file.schema_arrow
24272435
return file.schema.to_arrow_schema()
24282436

2429-
24302437
__all__ = (
24312438
"ColumnChunkMetaData",
24322439
"ColumnSchema",

0 commit comments

Comments
 (0)