Skip to main content

polars io tools

Custom parsing extensions for lazy polars

Build Status codecov License PyPI

Overview

polars-io-tools extends Polars lazy execution with custom I/O sources that push filters and column projections all the way down into the systems that hold your data — SQL databases, ClickHouse, Datadog, and Delta Lake — instead of loading everything and filtering in memory. It also adds lazy-friendly operations (joins, multi-source composition, time-series windows, caching, distributed execution) that keep predicate pushdown working where vanilla Polars would otherwise give up and materialize the whole frame.

Everything is exposed through the piot LazyFrame namespace and a handful of top-level scan_* / sink_* functions, so it composes naturally with the Polars API you already use.

Who is this for

Reach for polars-io-tools when you want Polars' lazy API over data that lives in an external store, and you care about not fetching rows or columns you will immediately throw away. It is most valuable for large, partitioned, or remote datasets where a filter on a date or key column should translate into a smaller query against the source. If your data already fits comfortably in memory or lives in local Parquet/CSV, plain Polars is the simpler choice.

Installation

pip install polars-io-tools

polars-io-tools requires Python 3.11 or newer. See the Installation guide for conda and source builds.

Quickstart

Importing the package registers the piot namespace on every Polars LazyFrame:

import polars as pl
import polars_io_tools  # registers the .piot namespace

left = pl.LazyFrame({"x": [1, 2, 3], "y": [4, 5, 6]})
right = pl.LazyFrame({"x": [-1, -2, 3], "z": [7, 8, 9]})

# An inner join where the keys present on the left are pushed down as a
# filter on the right frame *before* the join runs.
result = left.piot.filtered_join(right, on="x").collect()
print(result)
# shape: (1, 3)
# ┌─────┬─────┬─────┐
# │ x   ┆ y   ┆ z   │
# │ --- ┆ --- ┆ --- │
# │ i64 ┆ i64 ┆ i64 │
# ╞═════╪═════╪═════╡
# │ 3   ┆ 6   ┆ 9   │
# └─────┴─────┴─────┘

For a guided walkthrough, start with the Getting Started tutorial.

What's included

  • Lazy I/O sources with predicate & projection pushdownscan_db (any ODBC database), scan_clickhouse, scan_datadog, scan_delta, and from_narwhals. Filters on the resulting LazyFrame are translated into the source's own query language (SQL WHERE, Datadog time ranges, Delta partition pruning) so only the matching rows and columns are fetched.
  • Lazy writerssink_delta and sink_clickhouse write a LazyFrame directly to Delta Lake or ClickHouse, including streaming/chunked writes and transparent handling of types the target store cannot represent natively.
  • Pushdown-preserving query buildingfiltered_join, filtered_join_asof, join_between, multi_source, concat_named, and ts_with_columns express joins, multi-source composition, and rolling/lookback time-series logic without blocking the filter pushdown that those operations normally defeat.
  • Cachingcache keeps an in-memory, column- and partition-level cache for iterative work; cache_parquet materializes date-partitioned Parquet on local disk or S3, fetching only the partitions a query needs.
  • Distributed executionexecute_on_ray splits a LazyFrame by calendar period and runs the partitions across an existing Ray cluster.
  • Ergonomicsiter_rows for memory-efficient row iteration, debug to inspect what Polars pushes into a source, and disable_optimizations to compare against plain Polars.

Documentation

Full documentation lives in the project wiki:

Contributing

Contributions are welcome. See the Contributing guide and Local Development Setup to get started.

License

polars-io-tools is licensed under the Apache 2.0 license.

Download files

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

Source Distribution

polars_io_tools-0.1.2.tar.gz (516.0 kB view details)

Uploaded Source

Built Distributions

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

polars_io_tools-0.1.2-cp311-abi3-win_amd64.whl (446.7 kB view details)

Uploaded CPython 3.11+Windows x86-64

polars_io_tools-0.1.2-cp311-abi3-manylinux_2_28_x86_64.whl (563.0 kB view details)

Uploaded CPython 3.11+manylinux: glibc 2.28+ x86-64

polars_io_tools-0.1.2-cp311-abi3-macosx_11_0_arm64.whl (541.4 kB view details)

Uploaded CPython 3.11+macOS 11.0+ ARM64

File details

Details for the file polars_io_tools-0.1.2.tar.gz.

File metadata

  • Download URL: polars_io_tools-0.1.2.tar.gz
  • Upload date:
  • Size: 516.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for polars_io_tools-0.1.2.tar.gz
Algorithm Hash digest
SHA256 5f6500917d5faa8d873f807e5a4ca04f1ddcdbafecca414c76905b6358029280
MD5 f8344d3e0ad174f4796d3f4eed19b68e
BLAKE2b-256 63d5fc7bcfd6d120e3949d501dce1ec191f7bd7cf31ad838e2a532cba3e97995

See more details on using hashes here.

File details

Details for the file polars_io_tools-0.1.2-cp311-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for polars_io_tools-0.1.2-cp311-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 9961eadc56fc7a50872ac91e1e57a4dec1cb781905408bf1b9d7b1f01264147d
MD5 436d3ce0b173674b1d09f04d73324d74
BLAKE2b-256 44a45aa236208ff10e5107ac851964942a70a63aede098c9835a111926b24d45

See more details on using hashes here.

File details

Details for the file polars_io_tools-0.1.2-cp311-abi3-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for polars_io_tools-0.1.2-cp311-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 8b1ef3b6ab6a7d4efaf837ec1d9c995f7840918a08312422382595931803c008
MD5 06d6e68f8922b647a59384cf94c0d2cd
BLAKE2b-256 713a819f7693e5d6b70299f1560a5b2def39f54926769c711a733bc22612a56f

See more details on using hashes here.

File details

Details for the file polars_io_tools-0.1.2-cp311-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for polars_io_tools-0.1.2-cp311-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7d6f8750bc6e3e99acda6c8c7abf1939be9310fea91b64798c24b99c9a303ff2
MD5 b6bf44613046cc49338767ba1b34b6f4
BLAKE2b-256 fa3ecc65b413b5802d51ae9f2f3fe57e09e1011a2d9143c45f5468215f2f4329

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 Sentry Error logging StatusPage Status page