Skip to content

Commit

Permalink
fix(api): support passing literal booleans to filter
Browse files Browse the repository at this point in the history
  • Loading branch information
jcrist authored and kszucs committed Feb 12, 2024
1 parent 62992c3 commit 2aa31f4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ibis/expr/types/relations.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def f( # noqa: D417
# nested inputs
def bind(table: TableExpr, value: Any, prefer_column=True) -> Iterator[ir.Value]:
"""Bind a value to a table expression."""
if prefer_column and isinstance(value, (str, int)):
if prefer_column and type(value) in (str, int):
yield table._get_column(value)
elif isinstance(value, ValueExpr):
yield value
Expand Down
12 changes: 12 additions & 0 deletions ibis/tests/expr/test_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -730,6 +730,18 @@ def test_aggregate_keywords(table):
assert_equal(expr2, expected)


def test_filter_on_literal_boolean(table):
expr1 = table.filter(True)
expr2 = table.filter(ibis.literal(True))
assert expr1.equals(expr2)


def test_filter_on_literal_string_is_column(table):
expr1 = table.filter("h")
expr2 = table.filter(table.h)
assert expr1.equals(expr2)


def test_filter_on_literal_then_aggregate(table):
# Mostly just a smoketest, this used to error on construction
expr = table.filter(ibis.literal(True)).agg(lambda t: t.a.sum().name("total"))
Expand Down

0 comments on commit 2aa31f4

Please sign in to comment.