diff --git a/ibis/expr/sql.py b/ibis/expr/sql.py index c6fe415e9458..9492af3a94a0 100644 --- a/ibis/expr/sql.py +++ b/ibis/expr/sql.py @@ -465,6 +465,30 @@ def to_sql( str Formatted SQL string + Examples + -------- + >>> import ibis + >>> t = ibis.table({"a": "int", "b": "int"}, name="t") + >>> expr = t.mutate(c=t.a + t.b) + >>> ibis.to_sql(expr) + SELECT + "t0"."a", + "t0"."b", + "t0"."a" + "t0"."b" AS "c" + FROM "t" AS "t0" + + You can also specify the SQL dialect to use for compilation: + >>> ibis.to_sql(expr, dialect="mysql") + SELECT + `t0`.`a`, + `t0`.`b`, + `t0`.`a` + `t0`.`b` AS `c` + FROM `t` AS `t0` + + See Also + -------- + [`Table.compile()`](./expression-tables.qmd#ibis.expr.types.relations.Table.compile) + """ import ibis.backends.sql.compilers as sc