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

feat(api): add get_backend to expr #10228

Merged
merged 1 commit into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
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
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