## Report.to_sql()


The verified plan as SQL whose meaning is the proof's, in


Usage

``` python
Report.to_sql(dialect="duckdb")
```


`dialect`.

The SQL keeps every run-time check, as [run](Report.run.md#sverify.Report.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](Report.run.md#sverify.Report.run) checks them first ([check_inputs](Report.check_inputs.md#sverify.Report.check_inputs)).


## Parameters


`dialect: Any = ``"duckdb"`  
`"duckdb"` (the default), `"snowflake"` or `"spark"`, or one of [sverify.engines.DUCKDB](engines.DUCKDB.md#sverify.engines.DUCKDB), [SNOWFLAKE](engines.SNOWFLAKE.md#sverify.engines.SNOWFLAKE) and [SPARK](engines.SPARK.md#sverify.engines.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](verify.md#sverify.verify)), or `dialect` is 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

``` python
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"))
```
