parse parquet metadata including page headers
Project description
Parquet-Pages
read a parquet files' metadata information, including each individual data-page headers. Exposes them directly as thrift structs deserialised in accordance with parquet.thrift (included from apache/parquet-format) These structs include:
FileMetaDataRowGroup(s)ColumnChunk(s)ColumnMetaDataOffsetIndexColumnIndexPageHeader(s)
can refer to these directly as:
from parquet_pages import ttypes
ttypes.FileMetaData # etc
Everything except the PageHeader structs are in the file's footer. So if you don't need the PageHeaders, there are other simpler tools to get the rest.
Since this tool reads the PageHeaders too (which are scattered all over the file) it might end up doing significant I/O if the parquet file is large enough.
So it is really only intended for development-time inspection/debugging.
Usage Examples
from parquet_pages import read_parquet_metadata
metadata = read_parquet_metadata("example.parquet")
with open("example2.parquet", "rb") as file:
file_contents = file.read()
metadata2 = read_parquet_metadata(file_contents)
or invoke as as a module which dumps repr(metadata) to stdout, with readable indentation
% python -m parquet_pages -h
usage: python -m parquet_pages [-h] -f FILEPATH [--default_repr_classes DEFAULT_REPR_CLASSES [DEFAULT_REPR_CLASSES ...]]
dump parquet's FileMetaData pretty-printed to stdout
options:
-h, --help show this help message and exit
-f, --filepath FILEPATH
Path to the file
--default_repr_classes DEFAULT_REPR_CLASSES [DEFAULT_REPR_CLASSES ...]
List of class names for which to force reverting to their default __repr__ implementations (default: empty list)
To use the above pretty-print inside a script you can:
import parquet_pages.utils
print(parquet_pages.utils.pretty_repr(metadata))
parquet_pages.utils.DEFAULT_REPR_CLASSES = ['SchemaElement', 'Statistics']
print(parquet_pages.utils.pretty_repr(metadata))
Shortcomings
Most thrift structs include the enum-integer values (0,2,3,8, etc) instead of a more descriptive identifier for some fields (encoding-type, data-type, compression-codec etc). You'd have to refer the parquet.thrift definition for understanding a given output (for example codec=6 means zstd)
Requirements
- Requires
thriftat runtime - Requires
thrift-compilerat build time- does NOT require this if installing from pypi
- see
Dockerfile,Makefilefor build (make publish)
License
This project is licensed under the MIT License. See the LICENSE file for details.
Third-Party Code
This project includes the file parquet.thrift from Apache Parquet Format, developed by the Apache Software Foundation.
That file is licensed under the Apache License, Version 2.0. See LICENSE-APACHE and NOTICE for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file parquet_pages-0.2.0.tar.gz.
File metadata
- Download URL: parquet_pages-0.2.0.tar.gz
- Upload date:
- Size: 48.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
96ac8b3011313df47cd2099ec7d46b3da03fb1c1c16aad085e9f85be6a62f1e5
|
|
| MD5 |
b87e51571c507edab71be0fc089ff91f
|
|
| BLAKE2b-256 |
039782ad4a0d95abda08cb5d7a34d9ec7e1e39e99e91a352f4c631512cae5f19
|
File details
Details for the file parquet_pages-0.2.0-py3-none-any.whl.
File metadata
- Download URL: parquet_pages-0.2.0-py3-none-any.whl
- Upload date:
- Size: 49.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
af64e96066b415ffa3f6f0314526612db6339e93fc5a3cc671a4f2f293a184df
|
|
| MD5 |
61594f9959868973147c0a769ea02e49
|
|
| BLAKE2b-256 |
49f4f3580b3bd9425e29cceaba6f88489ae767f0488ae3c462975e7398841c2c
|