Skip to content

Commit

Permalink
docs(examples): add ibis.get_backend examples
Browse files Browse the repository at this point in the history
  • Loading branch information
IndexSeek committed Nov 14, 2024
1 parent 56ec371 commit 21e1279
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions ibis/expr/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1734,6 +1734,8 @@ def set_backend(backend: str | BaseBackend) -> None:
def get_backend(expr: Expr | None = None) -> BaseBackend:
"""Get the current Ibis backend to use for a given expression.
Parameters
----------
expr
An expression to get the backend from. If not passed, the default
backend is returned.
Expand All @@ -1743,6 +1745,25 @@ def get_backend(expr: Expr | None = None) -> BaseBackend:
BaseBackend
The Ibis backend.
Examples
--------
>>> import ibis
Get the default backend.
>>> ibis.get_backend() # doctest: +ELLIPSIS
<ibis.backends.duckdb.Backend at 0x7fffbd7e1ee0>
Get the backend for a specific expression.
>>> polars_con = ibis.polars.connect()
>>> t = polars_con.create_table("t", ibis.memtable({"a": [1, 2, 3]}))
>>> ibis.get_backend(t) # doctest: +ELLIPSIS
<ibis.backends.polars.Backend at 0x7fffab10a5d0>
See Also
--------
[`get_backend()`](./expression-tables.qmd#ibis.expr.types.relations.Table.get_backend)
"""
if expr is None:
from ibis.config import _default_backend
Expand Down

0 comments on commit 21e1279

Please sign in to comment.