Report.to_sql()
The verified plan as SQL whose meaning is the proof’s, in
Usage
Report.to_sql(dialect="duckdb")dialect.
The SQL keeps every run-time check, as run does. Where the report is deterministic (no window ties on data that meets the preconditions), windows need no row-order tiebreak, so Snowflake and Spark take them. A plan verified under an engine’s semantics (semantics="duckdb") is written only for an engine its route reaches (sverify.routes.choose). Snowflake takes plans verified under the reference. Run the SQL on data that meets the preconditions (requires); run checks them first (check_inputs).
Parameters
dialect: Any = "duckdb"-
"duckdb"(the default),"snowflake"or"spark", or one of sverify.engines.DUCKDB, SNOWFLAKE and SPARK.
Returns
str-
One SQL query, reading the plan’s tables by the names it was
verified with.
Raises
ValueError-
The report has no plan (it was not made by verify), or
dialectis unknown. sverify.errors.UnverifiedRunError-
The plan is not proved.
sverify.errors.RouteError-
No route takes the plan to the dialect’s engine.
sverify.errors.Unsupported- The dialect cannot express the plan.
Examples
report = sv.verify(
"SELECT host, max(cpu) AS m FROM t GROUP BY host",
tables={"t": t},
ensures=[sv.unique("host")],
)
print(report.to_sql("snowflake"))