Skip to content

Commit

Permalink
docs(examples): add ibis.get_backend examples (#10489)
Browse files Browse the repository at this point in the history
Co-authored-by: Phillip Cloud <[email protected]>
  • Loading branch information
IndexSeek and cpcloud authored Nov 14, 2024
1 parent 161c61f commit 4d99018
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 object at 0x...>
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 object at 0x...>
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 4d99018

Please sign in to comment.