Rust engine mode is the explicit product surface for opting into the native Rust runtime from Python-facing workflows.
| Mode | Behavior |
|---|---|
python |
Use Python validation, compilation, and rewrite paths. |
rust |
Use the versioned Rust semantic-input path; reject unavailable or unsupported requirements unless fallback is enabled. |
auto |
Select Rust when supported; permit Python fallback for typed unavailable or unsupported requirements. |
The current supported boundary and conformance evidence are documented in Semantic input contract. Invalid definitions and unexpected compiler failures remain errors in every mode. Automatic fallback does not hide those failures. Fallback diagnostics are written to stderr; SQL and data remain on stdout.
Build the optional Rust backend in the repository environment:
git clone https://github.com/sidequery/sqlctx.git
cd sqlctx
uv sync --extra rustRun the examples below with uv run from that checkout. The default engine is
Python. Select Rust explicitly for each command.
Validation:
sqlctx validate ./models --engine rustSemantic SQL dry run:
sqlctx query "select orders.total_revenue from metrics" --models ./models --engine rust --dry-runSemantic SQL rewrite without execution:
sqlctx rewrite "select orders.total_revenue from metrics" --models ./models --engine rustFallback:
sqlctx query "select orders.total_revenue from metrics" --models ./models --engine rust --fallbackruntime:
engine: rust
fallback: falseCLI --engine and --fallback/--no-fallback override config values for the command invocation.
layer = SemanticLayer(engine="rust")This enables:
- Rust-backed query reference validation.
- Rust-backed structured query compilation.
- No Python SQL string verification, because Rust and Python SQL do not need byte-for-byte parity.
layer = SemanticLayer(engine="rust", fallback=True)This permits Python fallback when the Rust extension's versioned entrypoints are
unavailable or a required capability is unsupported. Other compiler errors
propagate. layer.last_engine_selection reports the selected engine and reason.
The older environment variables still work for CI and migration tests:
SQLCTX_RS_SQL_GENERATORSQLCTX_RS_QUERY_VALIDATIONSQLCTX_RS_REWRITERSQLCTX_RS_SQL_GENERATOR_VERIFYSQLCTX_RS_NO_FALLBACK
They should not be the primary documented user interface.