Skip to main content

pq-glue

PyPI crates.io: pq-glue Documentation MIT licensed

Concatenate Parquet files without decoding them.

pq-glue copies the row groups of several Parquet files into one new file. Each column chunk is copied as bytes: it is not decompressed, decoded or re-encoded. The time taken depends on the number of bytes copied, not on the number of columns or how deeply they are nested.

Installation

Python (3.10 or later):

pip install pq-glue

Rust:

cargo add pq-glue

Usage

Python:

import pq_glue

rows = pq_glue.concat(["a.parquet", "b.parquet"], "ab.parquet")

Rust:

use std::path::{Path, PathBuf};

let inputs = [PathBuf::from("a.parquet"), PathBuf::from("b.parquet")];
let rows = pq_glue::concat(&inputs, Path::new("ab.parquet"))?;

concat returns the number of rows written.

The output file

The output file contains:

  • Row groups: every input's row groups, in input order. Each column chunk is unchanged: the same pages, dictionary page, encodings, compression and statistics.
  • Schema and metadata: the first input's Parquet schema and key-value metadata. The key-value metadata includes ARROW:schema, which pyarrow and Polars use to restore Arrow types such as large_string and field nullability.
  • Column orders: the inputs' column orders (see Float statistics).
  • Indexes and filters: the inputs' page indexes (column and offset indexes) and bloom filters, where the inputs have them.

Requirements on the inputs

All inputs must have the same Parquet schema, key-value metadata and column orders.

concat writes nothing and returns an error when:

  • the inputs differ in any of those;
  • there are no inputs;
  • the output path is one of the input paths;
  • an input is not a Parquet file or cannot be opened.

In Python these raise ValueError, except a file that cannot be opened, which raises OSError. In Rust they are variants of pq_glue::Error.

If the copy fails after the output file has been created, the output file is deleted.

Float statistics

A Parquet file declares, for each column, the sort order used for that column's min/max statistics (its column order).

parquet-rs, which pq-glue uses to write the file, declares IEEE 754 total order for every float column. A plain copy would therefore pair statistics computed under one order with a declaration of another. Files written by pyarrow, for example, use the type-defined order. Arrow C++ (pyarrow) then ignores the min/max of those float columns, because IEEE 754 total order also requires NaN counts that the copied statistics do not have.

pq-glue writes the inputs' column orders instead. After parquet-rs writes the footer, pq-glue rewrites the footer's column_orders list in place:

  • Same length: the two encodings are both 3 bytes, so no offsets or lengths change.
  • Checked: every entry must be one of the two known encodings, or the output is rejected.
  • Verified: the footer is read back and compared with the inputs' column orders.
  • Old files: inputs written without column orders (before parquet-format 2.4) get the type-defined order, which is what such files meant.

Performance

Concatenating 66 files (555 MB, 9.4 million rows, 93 nested leaf columns) took 1.1 to 1.5 s with pq-glue, against 61 s with Polars and 56 s with pyarrow. See the benchmarks page for all the figures, and bench/ to reproduce them.

Development

See DEVELOPMENT.md. In short:

just py       # build the extension in development mode and run the Python tests
just test     # Rust tests (cargo nextest)
just pc       # formatting and lints

License

MIT

Metadata

Release files for pq-glue 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pq-glue 0.1.0
File Size Uploaded Provenance Actions
pq_glue-0.1.0.tar.gz 96.9 kB Without provenance Details for pq_glue-0.1.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for pq-glue 0.1.0
File Actions
pq_glue-0.1.0-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details for pq_glue-0.1.0-cp310-abi3-win_amd64.whl
pq_glue-0.1.0-cp310-abi3-manylinux_2_28_aarch64.whl CPython 3.10 abi3 Linux glibc 2.28+ ARM64 Details for pq_glue-0.1.0-cp310-abi3-manylinux_2_28_aarch64.whl
pq_glue-0.1.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.10 abi3 Linux glibc 2.17+ x86-64 Details for pq_glue-0.1.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
pq_glue-0.1.0-cp310-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl CPython 3.10 abi3 Linux glibc 2.17+ ARMv7l Details for pq_glue-0.1.0-cp310-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
pq_glue-0.1.0-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details for pq_glue-0.1.0-cp310-abi3-macosx_11_0_arm64.whl
pq_glue-0.1.0-cp310-abi3-macosx_10_12_x86_64.whl CPython 3.10 abi3 macOS 10.12+ x86-64 Details for pq_glue-0.1.0-cp310-abi3-macosx_10_12_x86_64.whl

Total release size: 2.2 MB

Release files / pq_glue-0.1.0.tar.gz

Download URL pq_glue-0.1.0.tar.gz
Size 96.9 kB
Tags Source
SHA-256 checksum
How to use checksums
458c10babef2f267322bed0ec82b9c2861ef7f339fd617ef520bdd07996a3170
BLAKE2b-256 checksum
How to use checksums
84f135a0cf0782a849443da887cf2fe0cdbdace1af4ce6b88093ecd54f69225d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.15.0

Release files / pq_glue-0.1.0-cp310-abi3-win_amd64.whl

Download URL pq_glue-0.1.0-cp310-abi3-win_amd64.whl
Size 286.5 kB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
b57af5f80008cfda8a668f3c3b685a9fed3e5f7775f3b255ca240154bf064a0c
BLAKE2b-256 checksum
How to use checksums
69537d09e3dc869ecb6806c756224659d26517a8c0c8ba7f545ff64484d36c7c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.15.0

Release files / pq_glue-0.1.0-cp310-abi3-manylinux_2_28_aarch64.whl

Download URL pq_glue-0.1.0-cp310-abi3-manylinux_2_28_aarch64.whl
Size 356.9 kB
Tags CPython 3.10 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
28d279af25476369c928c0fc8f1aee6af743c7f87e99686e7d30665456fd1db4
BLAKE2b-256 checksum
How to use checksums
2390708c76714b9f2927f4e00024b4bfca1c25282d1c771279e8eac2f655ba75
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.15.0

Release files / pq_glue-0.1.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL pq_glue-0.1.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 371.8 kB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
6c0eb7f23c1942643a6ce03cea6faa88dbdad55a9561175fe5b34c6384f5451a
BLAKE2b-256 checksum
How to use checksums
b0617777849112c75e043aa07d5221d36cfea5ec789378e43b0eb62b02faefa1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.15.0

Release files / pq_glue-0.1.0-cp310-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl

Download URL pq_glue-0.1.0-cp310-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Size 369.2 kB
Tags CPython 3.10 Linux glibc 2.17+ ARMv7l abi3
SHA-256 checksum
How to use checksums
c094ac410faf58f16e2c5906f04fc0164f53c67afa70e5be7ddb6d46f402e213
BLAKE2b-256 checksum
How to use checksums
b737cef37d61f1e6233db146b2650977087009a0e0b3e1ca0be2055697e30724
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.15.0

Release files / pq_glue-0.1.0-cp310-abi3-macosx_11_0_arm64.whl

Download URL pq_glue-0.1.0-cp310-abi3-macosx_11_0_arm64.whl
Size 340.4 kB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
fbb233a3308f255ee48d20718de5e18bfbe514d8ed1ccae5b5d9c52eb8f5d835
BLAKE2b-256 checksum
How to use checksums
4ea82ccd29d4b677a928f8c741cc994d108a6ab5aca10083a4cf22c1f63d800f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.15.0

Release files / pq_glue-0.1.0-cp310-abi3-macosx_10_12_x86_64.whl

Download URL pq_glue-0.1.0-cp310-abi3-macosx_10_12_x86_64.whl
Size 351.8 kB
Tags CPython 3.10 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
6fad517aeda2ce04901aa5bf6b6bfa8159c61327c2bd937caa3f78be0485d1f9
BLAKE2b-256 checksum
How to use checksums
d2c616b1c4826e0c09df7dbd797d6af1d65a0279bc545a1fe0c5dc51e9ba0720
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.15.0

Security for pq-glue 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page