Skip to main content

polars-avro

build pypi docs

A polars io plugin for reading and writing Apache Avro files, built on arrow-avro. It provides scan support with predicate pushdown, map type reading, and continued avro support as polars deprecates its built-in implementation.

Python Usage

from polars_avro import scan_avro, read_avro, write_avro

lazy = scan_avro(path)
frame = read_avro(path)
write_avro([frame], path)

Both scan_avro and read_avro accept cloud and other URLs (s3://, gs://, az://, http(s)://, ...), read through fsspec — install the relevant backend (e.g. s3fs) and pass storage_options (forwarded to fsspec.open) for credentials:

lazy = scan_avro("s3://bucket/data.avro", storage_options={"anon": True})
frame = read_avro("s3://bucket/data.avro", storage_options={"anon": True})

Rust Usage

There are two main exports: [Reader] for iterating arrow RecordBatches from avro sources, and [Writer] for writing RecordBatches to an avro file.

use polars_avro::{ReadOptions, Reader, Writer};
use std::fs::File;
use std::io::BufReader;

// `Reader` yields arrow `RecordBatch`es from one or more avro sources
let mut reader = Reader::try_new(
    [File::open("data.avro").map(BufReader::new)],
    ReadOptions::default(),
).unwrap();

// copy them into a new file; `Writer` needs a schema up front, so take it
// from the first batch
let first = reader.next().unwrap().unwrap();
let mut writer = Writer::try_new(
    File::create("copy.avro").unwrap(),
    first.schema(),
    None,
).unwrap();
writer.write(&first).unwrap();
for batch in reader {
    writer.write(&batch.unwrap()).unwrap();
}
writer.finish().unwrap();

ℹ️ Avro supports writing with file compression schemes. In rust these need to be enabled via feature flags: deflate, snappy, bzip2, xz, zstd. Decompression is handled automatically.

Idiosyncrasies

Avro and Arrow don't align fully, and polars only supports a subset of arrow. Some types require casting before writing, and some avro types map to different polars types than you might expect when reading.

Writing

The following polars types error when writing and must be cast first:

Polars Type Cast To
large UInt64 Wrap to Int64
Categorical Int32 or String
Enum Int32 or String

Times will get truncated to micro seconds.

Compression is supported via feature flags: deflate, snappy, bzip2, xz, zstd.

Reading

utf8_view behavior — the utf8_view option (default false) changes how certain types are read:

Type utf8_view=false (default) utf8_view=true
UUID binary (16 bytes) formatted string
nullable strings preserves nulls replaces null with "" (lossy)

Since polars tends to work with string views internally, utf8_view=true is likely faster if you don't mind losing null string distinctions.

Type mappings of note:

Avro Type Polars Type
Enum Categorical (not Enum)
Map Map with String keys
BigDecimal Binary
Duration unsupported (errors)
Date Date (days since epoch)
TimeMillis, TimeMicros Time (nanoseconds)
TimestampMillis/Micros/Nanos Datetime with matching precision and UTC tz
LocalTimestampMillis/Micros/Nanos Datetime with matching precision and no tz

Constraints: the root avro schema must be a Record, and all files in a multi-file read must share the same schema.

Benchmarks

Python reports median (file reads, in-memory writes). Rust reports mean. native = polars built-in avro. Ratio relative to native; bold = fastest. Complex rows use nested/struct types.

Benchmark native polars-avro jetliner
python read 1K × 2 64 µs (1.00x) 99 µs (1.54x) 180 µs (2.79x)
python read 64K × 2 2.7 ms (1.00x) 2.1 ms (0.78x) 2.8 ms (1.04x)
python read 1K × 8 183 µs (1.00x) 242 µs (1.32x) 337 µs (1.84x)
python read 1M × 8 159 ms (1.00x) 114 ms (0.72x) 145 ms (0.91x)
python read 1M × 128 2.6 s (1.00x) 1.8 s (0.69x) 2.8 s (1.09x)
python read complex 1K × 8 — 449 µs 592 µs
python read complex 1M × 8 — 181 ms 260 ms
python read proj 1M × 128 → 8 1.6 s (1.00x) 1.2 s (0.75x) 1.2 s (0.77x)
python read proj 1K × 8 → 2 133 µs (1.00x) 297 µs (2.24x) 264 µs (1.99x)
python write 1K × 2 42 µs (1.00x) 30 µs (0.72x) —
python write 64K × 2 1.5 ms (1.00x) 1.1 ms (0.71x) —
python write 1K × 8 143 µs (1.00x) 114 µs (0.80x) —
python write 1M × 8 87 ms (1.00x) 93 ms (1.07x) —
python write 1M × 128 1.5 s (1.00x) 2.2 s (1.48x) —
rust read 1K × 2 42 µs (1.00x) 34 µs (0.80x) —
rust read 1M × 128 2.8 s (1.00x) 2.0 s (0.69x) —
rust read proj 1M × 128 → 8 1.3 s (1.00x) 1.2 s (0.87x) —
rust read proj 1K × 8 → 2 109 µs (1.00x) 116 µs (1.06x) —
rust write 1K × 2 42 µs (1.00x) 22 µs (0.53x) —
rust write 64K × 2 1.5 ms (1.00x) 1.0 ms (0.67x) —
rust write 1K × 8 135 µs (1.00x) 93 µs (0.69x) —
rust write 1M × 8 97 ms (1.00x) 89 ms (0.92x) —
rust write 1M × 128 1.6 s (1.00x) 1.4 s (0.88x) —

Development

Rust

Standard cargo commands will build and test the rust library.

Python

The python library is built with uv and maturin. uv sync compiles the rust extension once, after which you can use and test the library from python.

You may need to recompile the python bindings with uv run maturin develop.

Testing

cargo fmt --check
cargo clippy --all-features --tests -- -D warnings
cargo test
uv run ruff format --check
uv run ruff check
uv run pyright
uv run pytest

Benchmarking

Benchmarks must run against an optimized build. maturin develop (used for normal testing) compiles the extension unoptimized, which makes the Python benchmarks meaningless (~20x slower). Build release first:

cargo +nightly bench
uv run maturin develop --release
uv run pytest --benchmark-only

Releasing

Releases are automated. Trigger the release workflow from the Actions tab (or gh workflow run release.yml), choosing the version bump (patch, minor, or major). It gates on the full test suite, builds wheels and an sdist, commits and tags the version bump, and publishes to PyPI via OIDC trusted publishing.

Metadata

Release files for polars-avro 0.13.1

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

Source distribution (sdist)

Source distribution for polars-avro 0.13.1
File Size Uploaded Provenance Actions
polars_avro-0.13.1.tar.gz 209.8 kB With provenance Details for polars_avro-0.13.1.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for polars-avro 0.13.1
File Interpreter ABI Platform Actions
polars_avro-0.13.1-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl CPython 3.10 abi3 Linux glibc 2.17+ x86-64 Details for polars_avro-0.13.1-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
polars_avro-0.13.1-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl CPython 3.10 abi3 Linux glibc 2.17+ ARM64 Details for polars_avro-0.13.1-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
polars_avro-0.13.1-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details for polars_avro-0.13.1-cp310-abi3-macosx_11_0_arm64.whl

Total release size: 4.7 MB

Release files / polars_avro-0.13.1.tar.gz

Download URL polars_avro-0.13.1.tar.gz
Size 209.8 kB
Tags Source
SHA-256 checksum
How to use checksums
aa6d9e01a7e350ca5d2062fcfe5b40083c310746eb9674fe97d82de039fa84d0
BLAKE2b-256 checksum
How to use checksums
235b32ada77ffe8ea3bef47012491c9e95b91137e18e2c37c83fd871ce479180
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 1, 2026.

Transparency log

Release files / polars_avro-0.13.1-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL polars_avro-0.13.1-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 1.6 MB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
7ba433ef2abdadaef6cb99558e88e86a8455fbe6d1653442b9a0347cbde16038
BLAKE2b-256 checksum
How to use checksums
df46029ea0ee1bbaae5c013bd9ca045649c2f5ed93d85beffaf2d2db108670d5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 1, 2026.

Transparency log

Release files / polars_avro-0.13.1-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL polars_avro-0.13.1-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 1.6 MB
Tags CPython 3.10 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
72a512fbfed19b6db79832bb96fa07ec4fb90e8c886caee3d90034fafa967fe5
BLAKE2b-256 checksum
How to use checksums
ce20ce7ad5149e689814f535bb467694b789497760e71f7cdc5474539598889f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 1, 2026.

Transparency log

Release files / polars_avro-0.13.1-cp310-abi3-macosx_11_0_arm64.whl

Download URL polars_avro-0.13.1-cp310-abi3-macosx_11_0_arm64.whl
Size 1.3 MB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
7f70b694e55cbefa157a0657f26efd106a08fcc14be7bd9ef750aa9ad5484dee
BLAKE2b-256 checksum
How to use checksums
cf0e89f674621055123867c28d96f89cb2708ebea54748038e7afa5ee1809f44
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 1, 2026.

Transparency log

Security for polars-avro 0.13.1

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.

Full provenance

All 4 files in this release have been uploaded with provenance metadata.

Select from 4 files

Attestation for polars_avro-0.13.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 1, 2026.

Transparency log

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