Skip to main content

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 its tableReference is {"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, and list_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_sql and query, and for the registration APIs. dry_run is concurrency-safe for statements that EXPLAIN only plans. An ANALYZE-prefixed input becomes EXPLAIN ANALYZE and executes; like a state-mutating statement accepted by query(), it is outside the concurrency contract. Function lookup methods are read-only and concurrency-safe.
  • register_parquet / register_csv are safe under distinct table names; registering the same name concurrently is unsupported.
  • list_tables is a best-effort enumeration: registrations that land mid-call may or may not appear, but the result is always well-formed.
  • load_mdl must not overlap other calls on the same context; overlapping calls raise RuntimeError.

Developer Guide

Environment Setup

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 to target/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.7.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for wren-core-py 0.7.6
File Size Uploaded
wren_core_py-0.7.6.tar.gz 225.4 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for wren-core-py 0.7.6
File
wren_core_py-0.7.6-cp311-abi3-win_amd64.whl CPython 3.11 abi3 Windows x86-64 Details
wren_core_py-0.7.6-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.7.6-cp311-abi3-macosx_11_0_arm64.whl CPython 3.11 abi3 macOS 11.0+ ARM64 Details
wren_core_py-0.7.6-cp311-abi3-macosx_10_12_x86_64.whl CPython 3.11 abi3 macOS 10.12+ x86-64 Details

Total release size: 173.3 MB

Release files / wren_core_py-0.7.6.tar.gz

Download URL wren_core_py-0.7.6.tar.gz
Size 225.4 kB
Tags Source
SHA-256 checksum
How to use checksums
cc12c7526ca0c5f9991a4fb942d410b16bec1289db900f4804b1a3478bb2deac
BLAKE2b-256 checksum
How to use checksums
c34b8c1424e86666d6923c30c6a3974701a188fba59ea9764b5640797a364225
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.7.6-cp311-abi3-win_amd64.whl

Download URL wren_core_py-0.7.6-cp311-abi3-win_amd64.whl
Size 41.5 MB
Tags CPython 3.11 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
3c4adfa1658666dcefc48422e791755eda7d8b0582b0ec63e5f87e929da020b4
BLAKE2b-256 checksum
How to use checksums
3c40ab34f8b97ce21c11e9180dde63069f86f3c294fb6d875de9a22d77b8b966
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.7.6-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL wren_core_py-0.7.6-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
c561fa1dd693764e443792a5720ebaa1f8fabd7752939a569198de07b4f05576
BLAKE2b-256 checksum
How to use checksums
f1f37db7a18a2afbbab324c8924146d2ed29caa39477ca95289b131686d0b167
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.7.6-cp311-abi3-macosx_11_0_arm64.whl

Download URL wren_core_py-0.7.6-cp311-abi3-macosx_11_0_arm64.whl
Size 41.6 MB
Tags CPython 3.11 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
c7900188267f87608cdf91b8ee4db9e6de96cdb3c139730f593154558dc592fd
BLAKE2b-256 checksum
How to use checksums
d8386cb500f650c71c822c48765bdbfad638607f28464e72ec5251b8ced80dea
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.7.6-cp311-abi3-macosx_10_12_x86_64.whl

Download URL wren_core_py-0.7.6-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
7164de0c8ab7f3572863d17d8188878631c7fa325e66d2446c5c3a5a7386174b
BLAKE2b-256 checksum
How to use checksums
3f93b0c1cab6e30e3d0eefd316659df420f62036155c3f20e21e1a95e9f478ad
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page