Wren Core Python Binding
Python bindings for wren-core, the Rust semantic engine behind Wren Engine. Built with PyO3 and Maturin.
Wren Engine translates SQL queries through a semantic layer (MDL - Modeling Definition Language) and executes them against 22+ data sources (PostgreSQL, BigQuery, Snowflake, etc.).
Installation
pip install wren-core-py
Requires Python >= 3.11.
Pre-built wheels are available for:
- Linux x86_64
- macOS x86_64 / ARM64 (Apple Silicon)
- Windows x86_64
Linux ARM64 wheels are not yet available. To use on that platform, build from source (requires Rust toolchain).
Quick Start
from wren_core import SessionContext
# Create a session context from a base64-encoded MDL JSON string
base64_mdl_json = "<your-base64-encoded-mdl-json>"
ctx = SessionContext(base64_mdl_json)
# Transform a SQL query through the semantic layer
planned_sql = ctx.transform_sql("SELECT * FROM my_model")
Registering local files (Parquet/CSV)
Physical files can back MDL models via two-phase initialization — register the files, then load the MDL so models resolve to them:
from wren_core import SessionContext
base64_mdl_json = "<your-base64-encoded-mdl-json>"
ctx = SessionContext()
ctx.register_parquet("customer", "/data/customer.parquet")
ctx.register_csv("orders", "/data/orders.csv")
ctx.load_mdl(base64_mdl_json) # MDL models now resolve to the files
# Query by the MDL's catalog.schema.model name; returns Arrow IPC stream bytes
ipc_bytes = ctx.query("SELECT * FROM my_catalog.my_schema.customer")
Visibility contract:
- Tables land in the pre-existing default catalog (
datafusion.public). An MDL model resolves to a registered file only if itstableReferenceis{"catalog": "datafusion", "schema": "public", "table": "<registered name>"}and the columns it declares exist in the file. - Registering after the context was created still works: the internals of
pre-existing catalogs are live-shared with derived contexts, so the table is
visible to
query,dry_run, andlist_tables. - Brand-new top-level catalogs are the exception — they must exist before
MDL construction,
load_mdl, or a transform, each of which snapshots the top-level catalog list. - For
load_mdl's overlap rule, see the Concurrency section below.
For complete runnable examples (fixture files, matching manifests, decoding
the returned bytes), see tests/test_physical_tables.py.
Concurrency
Calls on one SessionContext run in parallel. Each transform_sql works
on a private top-level catalog snapshot and analyzer state is
per-invocation, so supported concurrent calls never observe each other's
intermediate state. The contract:
- Concurrent execution is supported for the read-only inputs accepted by
transform_sqlandquery, and for the registration APIs.dry_runis concurrency-safe for statements thatEXPLAINonly plans. AnANALYZE-prefixed input becomesEXPLAIN ANALYZEand executes; like a state-mutating statement accepted byquery(), it is outside the concurrency contract. Function lookup methods are read-only and concurrency-safe. register_parquet/register_csvare safe under distinct table names; registering the same name concurrently is unsupported.list_tablesis a best-effort enumeration: registrations that land mid-call may or may not appear, but the result is always well-formed.load_mdlmust not overlap other calls on the same context; overlapping calls raiseRuntimeError.
Developer Guide
Environment Setup
- Install Rust and Cargo
- Install Python
- Install uv
- Install casey/just
Test and Build
After installing casey/just, you can use the following commands:
just install— Create Python venv and install dependencies.just develop— Build the Rust package for local development (required before running Python tests).just test-rs— Run Rust tests only.just test-py— Run Python tests only.just test— Run both Rust and Python tests.just build— Build the Python wheel. Output goes totarget/wheels/.
Coding Style
Format via just format.
Publishing
See scripts/publish.sh for local publishing to PyPI/TestPyPI:
./scripts/publish.sh --build # Build wheel only
./scripts/publish.sh --test # Build + publish to TestPyPI
./scripts/publish.sh # Build + publish to PyPI
License
Apache-2.0
Metadata
Release files for wren-core-py 0.8.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 | |
|---|---|---|---|
| wren_core_py-0.8.0.tar.gz | 226.9 kB | Details |
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| wren_core_py-0.8.0-cp311-abi3-win_amd64.whl | CPython 3.11 | abi3 | Windows x86-64 | Details |
| wren_core_py-0.8.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl | CPython 3.11 | abi3 | Linux glibc 2.17+ x86-64 | Details |
| wren_core_py-0.8.0-cp311-abi3-macosx_11_0_arm64.whl | CPython 3.11 | abi3 | macOS 11.0+ ARM64 | Details |
| wren_core_py-0.8.0-cp311-abi3-macosx_10_12_x86_64.whl | CPython 3.11 | abi3 | macOS 10.12+ x86-64 | Details |
Total release size: 173.2 MB
Release files / wren_core_py-0.8.0.tar.gz
| Download URL | wren_core_py-0.8.0.tar.gz |
|---|---|
| Size | 226.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d67b98c63c56db30f2f1ec4613c8c4a39258a20b7923f5128edd7551eab4c1c9
|
|
BLAKE2b-256 checksum How to use checksums |
0d7a950b688918be993d8416ba9bde82733915dd9c9bc2479773793fabd51f8f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / wren_core_py-0.8.0-cp311-abi3-win_amd64.whl
| Download URL | wren_core_py-0.8.0-cp311-abi3-win_amd64.whl |
|---|---|
| Size | 41.5 MB |
| Tags | CPython 3.11 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
cecec08e238a374bc20db1c2745c5cb8b39f0cc7a3d558e58b1f9de64a4cfe36
|
|
BLAKE2b-256 checksum How to use checksums |
e7a4e21859cd59551665f2f1feb3d7b26d3a9c52f4d59d96ab5189ae03d1c57d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / wren_core_py-0.8.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | wren_core_py-0.8.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 46.5 MB |
| Tags | CPython 3.11 Linux glibc 2.17+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
a9ac3a13d02a198d4e8d7cbe3d9e119abbc8ba44716b4ee45147714137d0501e
|
|
BLAKE2b-256 checksum How to use checksums |
d321dea58346f29702a01ee2c25e73e0910608a5bc6634da24f0ce7bf4e26c44
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / wren_core_py-0.8.0-cp311-abi3-macosx_11_0_arm64.whl
| Download URL | wren_core_py-0.8.0-cp311-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 41.5 MB |
| Tags | CPython 3.11 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
bd020d7d99d454bc813855954e31b02d9ede8dc55a71555ca5c5701f115d6128
|
|
BLAKE2b-256 checksum How to use checksums |
b1610d13ba6faa913bb2a0fda179ee2da12e0366a0a4e4d6d15415a89065ace5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / wren_core_py-0.8.0-cp311-abi3-macosx_10_12_x86_64.whl
| Download URL | wren_core_py-0.8.0-cp311-abi3-macosx_10_12_x86_64.whl |
|---|---|
| Size | 43.4 MB |
| Tags | CPython 3.11 abi3 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
da9bd0a14eaec6c41d4729ad4c4348b5430f4a8ca074c82a19bf96888ccb7ce2
|
|
BLAKE2b-256 checksum How to use checksums |
eae9c654fee0c877e42ac0be141456bdab99a90a4e2ea70b04bbe5c68b18164d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|