pq-glue
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 aslarge_stringand 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_bynames 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'screated_byand 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.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pq_glue-0.3.0.tar.gz | 137.2 kB | Without provenance | Details for pq_glue-0.3.0.tar.gz |
Built distributions (wheels)
Total release size: 14.6 MB
Release files / pq_glue-0.3.0.tar.gz
| Download URL | pq_glue-0.3.0.tar.gz |
|---|---|
| Size | 137.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
da6d1dc4d16eb922f6def21cbb9e12444fd23df9c955e62410a7c98d92b90dc6
|
|
BLAKE2b-256 checksum How to use checksums |
f925a88d73e50faf10c266033b6b96893d659a6c7ee42ed9c51bc5702a28e343
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.15.0
|
Release files / pq_glue-0.3.0-cp310-abi3-win_amd64.whl
| Download URL | pq_glue-0.3.0-cp310-abi3-win_amd64.whl |
|---|---|
| Size | 2.6 MB |
| Tags | CPython 3.10 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
857fd9facb6ef87e0f5ad9c8a969202b5850a5be57e70708e08e574cade9acbc
|
|
BLAKE2b-256 checksum How to use checksums |
12574ea040269e05dbb4ffdcc72b946073582590246801c84621906951a78e33
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.15.0
|
Release files / pq_glue-0.3.0-cp310-abi3-manylinux_2_28_aarch64.whl
| Download URL | pq_glue-0.3.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 |
4575005ddfecc63ee26d4590b74bf312a0fb3f6a717d1db6f41a43aa7cefad0e
|
|
BLAKE2b-256 checksum How to use checksums |
03f72879b855e9bdf7c1e0f1ccb4e64eb5e237b2f27627794be5adc495480107
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.15.0
|
Release files / pq_glue-0.3.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | pq_glue-0.3.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 |
03489424e0b62f78ea3d345411cf5f787179c27e8631636b36fe468c0ae5cbe5
|
|
BLAKE2b-256 checksum How to use checksums |
8f9068eaf902f4f8a75776bf206cf18314dbbb06a9cff015f691b38dadd02855
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.15.0
|
Release files / pq_glue-0.3.0-cp310-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
| Download URL | pq_glue-0.3.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 |
7067f237dd217f543ac781837f28dc2718c66ca23f47a84659c0ce8e7dc580e8
|
|
BLAKE2b-256 checksum How to use checksums |
9105cf9b3f2ed7289f7b6c3705abf6995003b3c78c3d60a8c83a39325481dddf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.15.0
|
Release files / pq_glue-0.3.0-cp310-abi3-macosx_11_0_arm64.whl
| Download URL | pq_glue-0.3.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 |
ed4088d8e0f9269efe6a40b4194d81b266661da5d543acc6c603aae22e98edc0
|
|
BLAKE2b-256 checksum How to use checksums |
cc9f25c424ebafeefefcfdf0cdfd493b0256424664156896ecddbc878a47e014
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.15.0
|
Release files / pq_glue-0.3.0-cp310-abi3-macosx_10_12_x86_64.whl
| Download URL | pq_glue-0.3.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 |
d35123155f879017ec0fbc2081cf0dd19f0e658c7d55570e96de817755d4a013
|
|
BLAKE2b-256 checksum How to use checksums |
b1786553284ffdc6f6523f405f6b3989e437e78d5e0f656ad389aea1566a16f8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.15.0
|
Security for pq-glue 0.3.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.