Skip to content

Commit

Permalink
feat: add get_backend to expr (#10228)
Browse files Browse the repository at this point in the history
  • Loading branch information
mesejo committed Sep 27, 2024
1 parent df08d5e commit 4b34a61
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
5 changes: 5 additions & 0 deletions ibis/backends/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,3 +136,8 @@ def test_unbind(alltypes, expr_fn):

assert "Unbound" not in repr(expr)
assert "Unbound" in repr(expr.unbind())


def test_get_backend(con, alltypes):
assert alltypes.get_backend() is con
assert alltypes.id.min().get_backend() is con
11 changes: 11 additions & 0 deletions ibis/expr/types/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,17 @@ def _find_backend(self, *, use_default: bool = False) -> BaseBackend:

return backends[0]

def get_backend(self):
"""Get the current Ibis backend of the expression.
Returns
-------
BaseBackend
The Ibis backend.
"""
return self._find_backend(use_default=True)

def execute(
self,
limit: int | str | None = "default",
Expand Down

0 comments on commit 4b34a61

Please sign in to comment.