Skip to content

Commit 9877766

Browse files
IndexSeekcpcloud
authored andcommitted
docs(examples): add example and see also ref for ibis.to_sql
1 parent e69348b commit 9877766

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

ibis/expr/sql.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,30 @@ def to_sql(
465465
str
466466
Formatted SQL string
467467
468+
Examples
469+
--------
470+
>>> import ibis
471+
>>> t = ibis.table({"a": "int", "b": "int"}, name="t")
472+
>>> expr = t.mutate(c=t.a + t.b)
473+
>>> ibis.to_sql(expr)
474+
SELECT
475+
"t0"."a",
476+
"t0"."b",
477+
"t0"."a" + "t0"."b" AS "c"
478+
FROM "t" AS "t0"
479+
480+
You can also specify the SQL dialect to use for compilation:
481+
>>> ibis.to_sql(expr, dialect="mysql")
482+
SELECT
483+
`t0`.`a`,
484+
`t0`.`b`,
485+
`t0`.`a` + `t0`.`b` AS `c`
486+
FROM `t` AS `t0`
487+
488+
See Also
489+
--------
490+
[`Table.compile()`](./expression-tables.qmd#ibis.expr.types.relations.Table.compile)
491+
468492
"""
469493
import ibis.backends.sql.compilers as sc
470494

0 commit comments

Comments
 (0)