Skip to main content

parse parquet metadata including page headers

Project description

Parquet-Pages

reads a parquet files' metadata information, including each individual data-page headers. Exposes them directly as thrift structs deserialised in accordance with apache's parquet.thrift. That file has extensive comments describing the precise meaning of each field (and the lack thereof, if it is deprecated) These structs include:

  • FileMetaData
    • RowGroup (s)
      • ColumnChunk (s)
        • ColumnMetaData
        • OffsetIndex (if present)
        • ColumnIndex (if present)
        • PageHeader (s)

(.. etc)

The intended way is to invoke this package as a module to get an interactive TUI that displays this information with collapsible sections. But, one may also instead read it into a FileMetaData object inside a script (see details below), in which case the above thrift-generated classes are also exposed via:

from parquet_pages import ttypes
ttypes.FileMetaData
ttypes.ColumnMetaData # etc

NOTE

From a thrift spec perspective, OffsetIndex and ColumnIndex (when present) are not actually a part of ColumnChunk, but are located separately before the rest of the metadata footer. PageHeader is not in the footer at all (more details below). But they are presented in the above hierarchy for ease.

Usage Examples

% python -m parquet_pages -h                                    
usage: python -m parquet_pages [-h] -f FILEPATH [--expand] [--eager] [--show-None] [--raw]

reads given parquet's FileMetaData and displays it in an interactive TUI with collapsible sections

options:
  -h, --help            show this help message and exit
  -f, --filepath FILEPATH
                        Path to the parquet file
  --expand              [TUI only] expand all collapsible sections at start
  --eager               eagerly load all page headers at start. default is to lazy load on click (or to not load at all incase of --raw)
  --show-None           show `None` attributes as well
  --raw                 disable TUI and dump formatted repr directly to stdout
  • optionally, can also instead dump repr(metadata) to stdout without any TUI, with readable indentation (--raw)
  • by default, we lazy-load the PageHeaders (only read them from the file when requested).
    • this can be changed with the --eager flag
    • This is lazy-loaded because all the other thrift-serialised-structs (except PageHeaders) are together in the file's footer, but the page-headers (which are before every page's payload) would be scattered all over the file. Eagerly loading them all might end up doing significant I/O if the parquet file is large enough.
      • but since we are only reading the headers and not the payload as well, it wouldn't be more work than reading the entire file contents, for perspective. In most cases eager loading shouldn't feel any slower at all.

TUI Example

To read in a script:

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)
  • This eagerly-loads PageHeaders by default, for simplicity.
  • To load them lazily like what happens in the TUI, we can pass the argument lazy_load_pg_hdrs=True
    • the argument is ignored when reading from a bytes object, as it only would have made a difference when reading from a file on disk.
    • it replaces PageHeader objects with parquet_bytes.LazyLoaded objects, calling whose .load() method will actually read and return the struct.

Requirements

Runtime

  • Requires thrift
  • Only optionally requires, but recommended: textual
    • not optional during install, so would be installed automatically, but someone might uninstall it and core functionality will still work
      • parquet_pages.read_parquet_metadata does not require it
      • python -m parquet_pages --raw ... does not require it
    • only to manage TUI display after metadata is read

Build-time

  • Requires thrift-compiler
    • but does NOT require this if installing from pypi
    • see Dockerfile, Makefile (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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

parquet_pages-0.5.1.tar.gz (52.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

parquet_pages-0.5.1-py3-none-any.whl (52.4 kB view details)

Uploaded Python 3

File details

Details for the file parquet_pages-0.5.1.tar.gz.

File metadata

  • Download URL: parquet_pages-0.5.1.tar.gz
  • Upload date:
  • Size: 52.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for parquet_pages-0.5.1.tar.gz
Algorithm Hash digest
SHA256 3a42b0c7d54fa07b40fb28d77640bb6159c1e0736a27b92a54ae71058de76bf8
MD5 90f4b5590af244c5bc96ae546ee9260c
BLAKE2b-256 bcb090693181d8f91703fe04e7d2c4afd38b96de5b0a5c106b9369e6feaab5b6

See more details on using hashes here.

File details

Details for the file parquet_pages-0.5.1-py3-none-any.whl.

File metadata

  • Download URL: parquet_pages-0.5.1-py3-none-any.whl
  • Upload date:
  • Size: 52.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for parquet_pages-0.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f051834798c9a415760225b95a90d46e73ed024eb3952e63dcbf1ed1dabb288e
MD5 34b5fb910be0b88fd44e90cd1896f34c
BLAKE2b-256 b2aaaf4775826ca2fb6133c22266e17ff37582ee218d77f9631d60556957a7d7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page