polars-redis
Query Redis like a database. Transform with Polars. Write back without ETL.
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.
# Redis is just another source
=
=
# Full Polars transformation power
=
# Write back to Redis
Installation
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
=
# Scan with schema
=
# Filter and collect (projection pushdown applies)
=
# Write with TTL
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)
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