Skip to main content

transpile

Function transpile 

Source
pub fn transpile(
    sql: &str,
    read_dialect: Dialect,
    write_dialect: Dialect,
) -> Result<String>
Expand description

Transpile a SQL string from one dialect to another.

This is the primary high-level API, corresponding to Python sqlglot’s sqlglot.transpile().

§Example

use sqlglot_rust::{transpile, Dialect};

let result = transpile(
    "SELECT CAST(x AS INT) FROM t",
    Dialect::Ansi,
    Dialect::Postgres,
).unwrap();

§Errors

Returns a SqlglotError if parsing fails.