Skip to main content

engines.substrait_json()

Compile DuckDB’s SQL to a Substrait plan with sverify’s lift

Usage

Source

engines.substrait_json(
    con,
    sql,
    semantics="reference",
)

(sverify.sql_lift, SQLGlot), as protobuf JSON.

The plan reads the connection’s tables by name, and states every choice DuckDB’s SQL leaves implicit: casts, output types, function options and sort directions.

Parameters

con: Connection

The connection whose tables the SQL reads.

sql: str

A query in DuckDB’s SQL dialect.

semantics: str = "reference"
"reference" (the default, as for sv.verify and sv.sql): what sverify’s reference model computes; or "duckdb": what DuckDB computes where the two differ. Before 0.6 the default was "duckdb".

Returns

str
The Substrait plan as protobuf JSON.

Raises

Unsupported
The query is outside what the lift reads (a ValueError), saying what.