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 / ARM64 (manylinux)
- macOS x86_64 / ARM64 (Apple Silicon)
- Windows x86_64
On any other platform pip falls back to the sdist and builds from source, which requires a 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.1
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.1.tar.gz | 233.5 kB | Details |
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| wren_core_py-0.8.1-cp311-abi3-win_amd64.whl | CPython 3.11 | abi3 | Windows x86-64 | Details |
| wren_core_py-0.8.1-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.1-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl | CPython 3.11 | abi3 | Linux glibc 2.17+ ARM64 | Details |
| wren_core_py-0.8.1-cp311-abi3-macosx_11_0_arm64.whl | CPython 3.11 | abi3 | macOS 11.0+ ARM64 | Details |
| wren_core_py-0.8.1-cp311-abi3-macosx_10_12_x86_64.whl | CPython 3.11 | abi3 | macOS 10.12+ x86-64 | Details |
Total release size: 246.6 MB
Release files / wren_core_py-0.8.1.tar.gz
| Download URL | wren_core_py-0.8.1.tar.gz |
|---|---|
| Size | 233.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5cf2f6c299fe68f718e833b0f5ab26c20d36257f0601842be50966b3dcf44108
|
|
BLAKE2b-256 checksum How to use checksums |
54c176cc0126ee2eea93d3b7921e91055e0a5b3b15cc29b7e398d6de0772d85a
|
| 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.1-cp311-abi3-win_amd64.whl
| Download URL | wren_core_py-0.8.1-cp311-abi3-win_amd64.whl |
|---|---|
| Size | 46.0 MB |
| Tags | CPython 3.11 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
13505326d61528eaf3bcc1280e3205d36efe38b101ff87ddeab57c035e3c4309
|
|
BLAKE2b-256 checksum How to use checksums |
a1db60eba335820e848339eb3e1ee8b5485446ec8a50798683f8984ff614ab75
|
| 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.1-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | wren_core_py-0.8.1-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 51.8 MB |
| Tags | CPython 3.11 Linux glibc 2.17+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
781baa9188845451d39f295083e5e07172ec2a186b9fa71d7df861c1982b2f6b
|
|
BLAKE2b-256 checksum How to use checksums |
6b59fb4cb1e4ceb45733c2b040b4e3a2a66139ac631b043369f5e03cc27a5b16
|
| 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.1-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | wren_core_py-0.8.1-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 53.6 MB |
| Tags | CPython 3.11 Linux glibc 2.17+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
afa541e5c095d4b144db0b7fea9d63fe268c59cbb0a459c1326a624c7687419e
|
|
BLAKE2b-256 checksum How to use checksums |
6f556d41c0fc14f9b7e2bd809461ee10c1c52b93979240db2c06f8f2c4dc1b65
|
| 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.1-cp311-abi3-macosx_11_0_arm64.whl
| Download URL | wren_core_py-0.8.1-cp311-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 46.5 MB |
| Tags | CPython 3.11 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
264331c7359c05744da661dc0402a3b96c60c3a5747b306398c8193653fc2263
|
|
BLAKE2b-256 checksum How to use checksums |
98eafab456a1e86eba8704eeb60717b2590b414a47206edb048041f97e23e474
|
| 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.1-cp311-abi3-macosx_10_12_x86_64.whl
| Download URL | wren_core_py-0.8.1-cp311-abi3-macosx_10_12_x86_64.whl |
|---|---|
| Size | 48.4 MB |
| Tags | CPython 3.11 abi3 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
eed71160e6f2aa0323071fa773e354fa6dfd6711d9731b6c0bf17d48b0003bff
|
|
BLAKE2b-256 checksum How to use checksums |
d0b01dbfdccfb27a7cfa3f2d2ec26ba5d4fd90af00487a0b1151eff6a4f5d79b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|