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. load_mdlmust not overlap other calls on the same context; overlapping calls raiseRuntimeError.
For complete runnable examples (fixture files, matching manifests, decoding
the returned bytes), see tests/test_physical_tables.py.
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
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 wren_core_py-0.7.4.tar.gz.
File metadata
- Download URL: wren_core_py-0.7.4.tar.gz
- Upload date:
- Size: 222.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6a3ce3a6ab5517b68a9ace8e456af8c6689c0f7cfc74b3a1131ddae0cb46f096
|
|
| MD5 |
c3a488b064e11955dd5eef0b21dc49bb
|
|
| BLAKE2b-256 |
a3af2bfaf3605212d999dbaab17decc6744b02139d3c5950abef3c00c67981d3
|
File details
Details for the file wren_core_py-0.7.4-cp311-abi3-win_amd64.whl.
File metadata
- Download URL: wren_core_py-0.7.4-cp311-abi3-win_amd64.whl
- Upload date:
- Size: 41.4 MB
- Tags: CPython 3.11+, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
20062e2a0633503fd14af2da04c0cde2ac5c542c776a91f52046f9e89f3278e2
|
|
| MD5 |
079eb59b321f48d733149e93c93e3f38
|
|
| BLAKE2b-256 |
a33bcb35479f576cc676f7e236ab7a0ac7c53363ed96b979c8522865cc116cd7
|
File details
Details for the file wren_core_py-0.7.4-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: wren_core_py-0.7.4-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 46.4 MB
- Tags: CPython 3.11+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6ca62246f459c9eb2acc44501271d4f15e29be9d3543af9b80eed245a1562136
|
|
| MD5 |
03c491ab5e91082c2436a5f5b8c7e7ba
|
|
| BLAKE2b-256 |
3f63271c79c9abdd9da7fe9e148afa37a5a78cc24bd00281f821385413d1095e
|
File details
Details for the file wren_core_py-0.7.4-cp311-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: wren_core_py-0.7.4-cp311-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 41.6 MB
- Tags: CPython 3.11+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
70779ffd9cad51cb41d60c2107777c84471f6f2c2f0f1c9493b3785147c6fa3d
|
|
| MD5 |
9365f6d5e3bdc186c5dc5c319917fd77
|
|
| BLAKE2b-256 |
1106d5b6d10a0da05404318b9524cf3bbd0b643727a24bf48d1828566b52494a
|
File details
Details for the file wren_core_py-0.7.4-cp311-abi3-macosx_10_12_x86_64.whl.
File metadata
- Download URL: wren_core_py-0.7.4-cp311-abi3-macosx_10_12_x86_64.whl
- Upload date:
- Size: 43.4 MB
- Tags: CPython 3.11+, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4ac33c857906906f59d03492ace0873c723124108e32d181ba475d726efc9595
|
|
| MD5 |
654f6a864e2285b9290a52b2bab34ef2
|
|
| BLAKE2b-256 |
6a8652b636d394e0099ca92642c3081bf4a49a53bddfa439df150e2010b94bf2
|