Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(examples): add ibis.get_backend examples #10489

Merged
merged 3 commits into from
Nov 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading