Redis IO plugin for Polars
Project description
polars-redis
Query Redis like a database. Transform with Polars. Write back without ETL.
New to Polars? Polars is a lightning-fast DataFrame library for Python and Rust. Check out the Polars User Guide to get started.
What is polars-redis?
polars-redis makes Redis a first-class data source in your Polars workflows. Query, transform, and write back - Redis becomes just another connector alongside Parquet, CSV, and databases.
import polars as pl
import polars_redis as redis
# Redis is just another source
users = redis.read_hashes(url, "user:*", schema)
orders = pl.read_parquet("s3://bucket/orders.parquet")
# Full Polars transformation power
result = (
users.join(orders, on="user_id")
.group_by("region")
.agg(pl.col("amount").sum())
)
# Write back to Redis
redis.write_hashes(result, url, key_prefix="region_stats:")
Installation
pip install polars-redis
When to Use What
| Your data | Use | Why |
|---|---|---|
| User profiles, configs | scan_hashes() |
Field-level access, projection pushdown |
| Nested documents | scan_json() |
Full document structure |
| Counters, flags, caches | scan_strings() |
Simple key-value |
| Tags, memberships | scan_sets() |
Unique members |
| Queues, recent items | scan_lists() |
Ordered elements |
| Leaderboards, rankings | scan_zsets() |
Score-based ordering |
Quick Start
import polars as pl
import polars_redis as redis
url = "redis://localhost:6379"
# Scan with schema
lf = redis.scan_hashes(
url,
pattern="user:*",
schema={"name": pl.Utf8, "age": pl.Int64, "active": pl.Boolean},
)
# Filter and collect (projection pushdown applies)
active_users = lf.filter(pl.col("active")).select(["name", "age"]).collect()
# Write with TTL
redis.write_hashes(active_users, url, key_prefix="cache:user:", ttl=3600)
RediSearch (Server-Side Filtering)
from polars_redis import col
# Filter in Redis, not Python - only matching docs are transferred
df = redis.search_hashes(
url,
index="users_idx",
query=(col("age") > 30) & (col("status") == "active"),
schema={"name": pl.Utf8, "age": pl.Int64, "status": pl.Utf8},
).collect()
# Server-side aggregation
df = redis.aggregate_hashes(
url,
index="users_idx",
query="*",
group_by=["@department"],
reduce=[("COUNT", [], "count"), ("AVG", ["@salary"], "avg_salary")],
)
Parallel Fetching
# Speed up large scans with parallel workers
lf = redis.scan_hashes(
url,
pattern="user:*",
schema={"name": pl.Utf8, "age": pl.Int64},
parallel=4, # Use 4 parallel workers
)
Features
Read:
scan_hashes()/read_hashes()- Redis hashesscan_json()/read_json()- RedisJSON documentsscan_strings()/read_strings()- Redis stringsscan_sets()/read_sets()- Redis setsscan_lists()/read_lists()- Redis listsscan_zsets()/read_zsets()- Redis sorted sets- Projection pushdown (fetch only requested fields)
- Schema inference (
infer_hash_schema(),infer_json_schema()) - Metadata columns (key, TTL, row index)
- Parallel fetching for improved throughput
RediSearch (Predicate Pushdown):
search_hashes()- Server-side filtering with FT.SEARCHaggregate_hashes()- Server-side aggregation with FT.AGGREGATE- Polars-like query builder:
col("age") > 30
Write:
write_hashes(),write_json(),write_strings()write_sets(),write_lists(),write_zsets()- TTL support
- Key prefix
- Write modes: fail, replace, append
Supported Types
| Polars | Redis |
|---|---|
Utf8 |
string |
Int64 |
parsed int |
Float64 |
parsed float |
Boolean |
true/false, 1/0, yes/no |
Date |
YYYY-MM-DD or epoch days |
Datetime |
ISO 8601 or Unix timestamp |
Requirements
- Python 3.9+
- Redis 7.0+ (RedisJSON module for JSON support)
Documentation
Full documentation at joshrotenberg.github.io/polars-redis
License
MIT or Apache-2.0
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file polars_redis-0.1.6.tar.gz.
File metadata
- Download URL: polars_redis-0.1.6.tar.gz
- Upload date:
- Size: 305.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
67a4754142bd77093d4c43b459a0d257449a251661d3e86abb722f370c5f7002
|
|
| MD5 |
e16c497f9083351a17f825d633592b32
|
|
| BLAKE2b-256 |
9554d1f6aee7a893fb511c7e5eb59e9b6ae99e2b0b047cd2ae478ab37dc4e7a5
|
Provenance
The following attestation bundles were made for polars_redis-0.1.6.tar.gz:
Publisher:
publish.yml on joshrotenberg/polars-redis
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
polars_redis-0.1.6.tar.gz -
Subject digest:
67a4754142bd77093d4c43b459a0d257449a251661d3e86abb722f370c5f7002 - Sigstore transparency entry: 798907398
- Sigstore integration time:
-
Permalink:
joshrotenberg/polars-redis@c80dd81279a51c17a9d5d4196582e483d5a5f8f7 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/joshrotenberg
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c80dd81279a51c17a9d5d4196582e483d5a5f8f7 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file polars_redis-0.1.6-cp314-cp314-macosx_11_0_arm64.whl.
File metadata
- Download URL: polars_redis-0.1.6-cp314-cp314-macosx_11_0_arm64.whl
- Upload date:
- Size: 2.1 MB
- Tags: CPython 3.14, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0790567eba8f916051c8efb0a157c9452628561be2f0e250260452469a05c92a
|
|
| MD5 |
eb7f464608f365aea1168c5ca8eb5391
|
|
| BLAKE2b-256 |
d29cd26741aa2db7d19c85ca176fb0b552d395201c0911b2221393685ee9fb0e
|
Provenance
The following attestation bundles were made for polars_redis-0.1.6-cp314-cp314-macosx_11_0_arm64.whl:
Publisher:
publish.yml on joshrotenberg/polars-redis
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
polars_redis-0.1.6-cp314-cp314-macosx_11_0_arm64.whl -
Subject digest:
0790567eba8f916051c8efb0a157c9452628561be2f0e250260452469a05c92a - Sigstore transparency entry: 798907401
- Sigstore integration time:
-
Permalink:
joshrotenberg/polars-redis@c80dd81279a51c17a9d5d4196582e483d5a5f8f7 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/joshrotenberg
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c80dd81279a51c17a9d5d4196582e483d5a5f8f7 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file polars_redis-0.1.6-cp314-cp314-macosx_10_12_x86_64.whl.
File metadata
- Download URL: polars_redis-0.1.6-cp314-cp314-macosx_10_12_x86_64.whl
- Upload date:
- Size: 2.2 MB
- Tags: CPython 3.14, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dadd8e312500dd5bb6f1504a124d58f2f1ad8cf7b993fe2511ab31af94865b2f
|
|
| MD5 |
f5160f8299d660f5d24cc1f28930a99e
|
|
| BLAKE2b-256 |
9228cf2463a8a5f5fe04d742695357dc7cda57e0b07548d4321cfbfd4393bf75
|
Provenance
The following attestation bundles were made for polars_redis-0.1.6-cp314-cp314-macosx_10_12_x86_64.whl:
Publisher:
publish.yml on joshrotenberg/polars-redis
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
polars_redis-0.1.6-cp314-cp314-macosx_10_12_x86_64.whl -
Subject digest:
dadd8e312500dd5bb6f1504a124d58f2f1ad8cf7b993fe2511ab31af94865b2f - Sigstore transparency entry: 798907405
- Sigstore integration time:
-
Permalink:
joshrotenberg/polars-redis@c80dd81279a51c17a9d5d4196582e483d5a5f8f7 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/joshrotenberg
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c80dd81279a51c17a9d5d4196582e483d5a5f8f7 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file polars_redis-0.1.6-cp39-cp39-win_amd64.whl.
File metadata
- Download URL: polars_redis-0.1.6-cp39-cp39-win_amd64.whl
- Upload date:
- Size: 2.0 MB
- Tags: CPython 3.9, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
26d8e56fb80330548d605355e9d1e8565fc9f690e71be857f86e4e449c63f654
|
|
| MD5 |
bba1b821146600deb97bde5f2ed2231b
|
|
| BLAKE2b-256 |
d09bfe5614210c13560e57fef742bceb0bb3d1de3dd15f6ff407d5236a8b9e7c
|
Provenance
The following attestation bundles were made for polars_redis-0.1.6-cp39-cp39-win_amd64.whl:
Publisher:
publish.yml on joshrotenberg/polars-redis
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
polars_redis-0.1.6-cp39-cp39-win_amd64.whl -
Subject digest:
26d8e56fb80330548d605355e9d1e8565fc9f690e71be857f86e4e449c63f654 - Sigstore transparency entry: 798907404
- Sigstore integration time:
-
Permalink:
joshrotenberg/polars-redis@c80dd81279a51c17a9d5d4196582e483d5a5f8f7 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/joshrotenberg
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c80dd81279a51c17a9d5d4196582e483d5a5f8f7 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file polars_redis-0.1.6-cp38-cp38-manylinux_2_24_x86_64.whl.
File metadata
- Download URL: polars_redis-0.1.6-cp38-cp38-manylinux_2_24_x86_64.whl
- Upload date:
- Size: 2.6 MB
- Tags: CPython 3.8, manylinux: glibc 2.24+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5aec490480d94f75ec651b7896e2a7ac2fc0e3b7fa9517d35b347879ae0b91be
|
|
| MD5 |
38dc4d4a6e1d050e0aec1a38abf05f56
|
|
| BLAKE2b-256 |
9ea1eda4b07cc8234d233856db63f313912c67af1b86fb032f4acf70b413c2f3
|
Provenance
The following attestation bundles were made for polars_redis-0.1.6-cp38-cp38-manylinux_2_24_x86_64.whl:
Publisher:
publish.yml on joshrotenberg/polars-redis
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
polars_redis-0.1.6-cp38-cp38-manylinux_2_24_x86_64.whl -
Subject digest:
5aec490480d94f75ec651b7896e2a7ac2fc0e3b7fa9517d35b347879ae0b91be - Sigstore transparency entry: 798907400
- Sigstore integration time:
-
Permalink:
joshrotenberg/polars-redis@c80dd81279a51c17a9d5d4196582e483d5a5f8f7 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/joshrotenberg
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c80dd81279a51c17a9d5d4196582e483d5a5f8f7 -
Trigger Event:
workflow_dispatch
-
Statement type: