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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wren_core_py-0.7.5.tar.gz (223.3 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

wren_core_py-0.7.5-cp311-abi3-win_amd64.whl (41.4 MB view details)

Uploaded CPython 3.11+Windows x86-64

wren_core_py-0.7.5-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (46.4 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.17+ x86-64

wren_core_py-0.7.5-cp311-abi3-macosx_11_0_arm64.whl (41.6 MB view details)

Uploaded CPython 3.11+macOS 11.0+ ARM64

wren_core_py-0.7.5-cp311-abi3-macosx_10_12_x86_64.whl (43.4 MB view details)

Uploaded CPython 3.11+macOS 10.12+ x86-64

File details

Details for the file wren_core_py-0.7.5.tar.gz.

File metadata

  • Download URL: wren_core_py-0.7.5.tar.gz
  • Upload date:
  • Size: 223.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for wren_core_py-0.7.5.tar.gz
Algorithm Hash digest
SHA256 a1e42efc4a8eb6ed60ce04c76fd08466169d346de3f530873b913a78fadc10e9
MD5 1aa8df27ebfb222a81bbf0b7ed82c357
BLAKE2b-256 8d0543add76ef792f29396be457a145deb4078ce573c09976e9c2dcd42ae6e3e

See more details on using hashes here.

File details

Details for the file wren_core_py-0.7.5-cp311-abi3-win_amd64.whl.

File metadata

  • Download URL: wren_core_py-0.7.5-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

Hashes for wren_core_py-0.7.5-cp311-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 1f4be094465bc324c63967d3696c2f7d2f2353afa12d0551310823c1a8734bf6
MD5 e5678f0ad6a0025d8fa086d622a8510f
BLAKE2b-256 ef26386d02b53b5e0c12e483f6c9ae4ecda70225ce073c71df171525c3c94e7a

See more details on using hashes here.

File details

Details for the file wren_core_py-0.7.5-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for wren_core_py-0.7.5-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 04bf5c5f9a52cf458e09eaaf49c939b36961be7d648129cd525d9c5579437877
MD5 65a92f6c92ed4da625b23cde05053c33
BLAKE2b-256 5cc37c160c35b6337a3269deb8292b1c491a823125dd405a192a71a4be281d82

See more details on using hashes here.

File details

Details for the file wren_core_py-0.7.5-cp311-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for wren_core_py-0.7.5-cp311-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0bf427671e10df08e12fd70654f8b5d071b5a55aed16d83b13f7a3d3a887185e
MD5 bfe40a0cc240860eea85b46fc3b1bd7d
BLAKE2b-256 bb1ee63d7abbda38a7c380a06bc87d68d145d26befd1d83ab787974ef339dd38

See more details on using hashes here.

File details

Details for the file wren_core_py-0.7.5-cp311-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for wren_core_py-0.7.5-cp311-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 1bd3c616a15c79f62376b8b8998b62cb38ce2d23f91be79df0ece3e99ba25144
MD5 a45372c02158262849828e50097afa18
BLAKE2b-256 2e6f157ad227c3e94f9853fb0b8caefb3ab2f05e929390219ad1d40c5c8bbf69

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page