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.

Many concatenations at once, each a concat with the same output, run in parallel with the GIL released (in Rust, pq_glue::concat_many, feature parallel):

rows = pq_glue.concat_many([(["a.parquet", "b.parquet"], "ab.parquet"), (["c.parquet"], "c2.parquet")])

For many small concatenations, whose time goes on opening files and writing footers, one call is quicker than a concat per job.

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.
  • Writer and sorting: the inputs' created_by, format version and row groups' sorting columns, where all the inputs have the same. created_by names the writer that encoded the column chunks, which readers use to work around known writers' bugs. A file written as separate row groups and glued declares what the file written whole declares. Where the inputs differ, the output has parquet-rs's created_by and format version, and its row groups declare no sorting columns: parquet-rs gives every row group the same sorting columns, and declaring one row group's for another could be false.

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.2.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.2.0
File Size Uploaded Provenance Actions
pq_glue-0.2.0.tar.gz 131.0 kB Without provenance Details for pq_glue-0.2.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for pq-glue 0.2.0
File Actions
pq_glue-0.2.0-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details for pq_glue-0.2.0-cp310-abi3-win_amd64.whl
pq_glue-0.2.0-cp310-abi3-manylinux_2_28_aarch64.whl CPython 3.10 abi3 Linux glibc 2.28+ ARM64 Details for pq_glue-0.2.0-cp310-abi3-manylinux_2_28_aarch64.whl
pq_glue-0.2.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.2.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
pq_glue-0.2.0-cp310-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl CPython 3.10 abi3 Linux glibc 2.17+ ARMv7l Details for pq_glue-0.2.0-cp310-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
pq_glue-0.2.0-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details for pq_glue-0.2.0-cp310-abi3-macosx_11_0_arm64.whl
pq_glue-0.2.0-cp310-abi3-macosx_10_12_x86_64.whl CPython 3.10 abi3 macOS 10.12+ x86-64 Details for pq_glue-0.2.0-cp310-abi3-macosx_10_12_x86_64.whl

Total release size: 14.6 MB

Release files / pq_glue-0.2.0.tar.gz

Download URL pq_glue-0.2.0.tar.gz
Size 131.0 kB
Tags Source
SHA-256 checksum
How to use checksums
7b445f15beaee7a02ba08ccc13c76087336db9c53cce1c0d9cca3152fee2c582
BLAKE2b-256 checksum
How to use checksums
c75bf76a7cfa8c741a6df009c7f3f46ec771ea78e6e08094c59d0c59539b44a1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.15.0

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

Download URL pq_glue-0.2.0-cp310-abi3-win_amd64.whl
Size 2.5 MB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
e3d5d1773f2ce281504942758e5db11f957b382849f4b76d499213a9824ecf34
BLAKE2b-256 checksum
How to use checksums
6d3f10cba49e8ad50a88263f82c9052abc8314f840c1fdd0d4130a84e765160b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.15.0

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

Download URL pq_glue-0.2.0-cp310-abi3-manylinux_2_28_aarch64.whl
Size 2.3 MB
Tags CPython 3.10 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
79ffa11ec9ab527473f44841e69871239394e74d1105dbed9cbcc4f3595a4e6d
BLAKE2b-256 checksum
How to use checksums
7b9f86ca88d0bd820d83a5978d39dc7f592b94fd61aae3564d58fd9b96671c80
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.15.0

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

Download URL pq_glue-0.2.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 2.5 MB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
37abf1245f47c5ce9f553acbbb97cb075098f3d9a1cb512124c775608f23a364
BLAKE2b-256 checksum
How to use checksums
3f36d48ce8811b647737c15be57e7e6c1754624120181620ef40255a25c4733a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.15.0

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

Download URL pq_glue-0.2.0-cp310-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Size 2.5 MB
Tags CPython 3.10 Linux glibc 2.17+ ARMv7l abi3
SHA-256 checksum
How to use checksums
298b037297fb946c7052859e60e3adb88d0e9b500fe85067ab5a682d440aa538
BLAKE2b-256 checksum
How to use checksums
ce325eebcad8a89edaf48b5bc73fe5cdffbeab879a928704ddc228f40803aa13
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.15.0

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

Download URL pq_glue-0.2.0-cp310-abi3-macosx_11_0_arm64.whl
Size 2.2 MB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
90b92ddea55b414e054cfaf16804fda5c2988dfde763a8770d65276682793392
BLAKE2b-256 checksum
How to use checksums
1209fd1b236743bb6cf45867ea98ea55d454636bb46ae9fa70d2feb7f0c66297
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.15.0

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

Download URL pq_glue-0.2.0-cp310-abi3-macosx_10_12_x86_64.whl
Size 2.4 MB
Tags CPython 3.10 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
919a08e7496dec5a620d6f5891a5327b5e3d59edf6fc337becf3aadc2cfa6553
BLAKE2b-256 checksum
How to use checksums
883f679aeaa724b0bfa3512108d10129e14bdeaf622910246e7d6b7fe9d6d67e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.15.0

Security for pq-glue 0.2.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