Skip to content

Commit

Permalink
feat: add get_backend to expr
Browse files Browse the repository at this point in the history
closes #10197
  • Loading branch information
mesejo committed Sep 25, 2024
1 parent a54ecea commit cb56a4a
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 cb56a4a

Please sign in to comment.