Skip to content

Commit

Permalink
fix(api): selection using a selector yielding multiple columns (#8215)
Browse files Browse the repository at this point in the history
  • Loading branch information
kszucs authored Feb 4, 2024
1 parent 2ce7573 commit 0a87137
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
8 changes: 4 additions & 4 deletions ibis/expr/types/relations.py
Original file line number Diff line number Diff line change
Expand Up @@ -764,13 +764,13 @@ def __getitem__(self, what):
# Projection case
return self.select(what)

(what,) = bind(self, what)
if isinstance(what, BooleanValue):
items = tuple(bind(self, what))
if util.all_of(items, BooleanValue):
# TODO(kszucs): this branch should be removed, .filter should be
# used instead
return self.filter([what])
return self.filter(items)
else:
return self.select(what)
return self.select(items)

def __len__(self):
raise com.ExpressionError("Use .count() instead")
Expand Down
13 changes: 13 additions & 0 deletions ibis/tests/expr/test_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,19 @@ def test_getitem_column_select(table):
assert isinstance(col, Column)


def test_select_using_selector(table):
expr = table[s.numeric()]
expected = table.select(
table.a,
table.b,
table.c,
table.d,
table.e,
table.f,
)
assert expr.equals(expected)


def test_table_tab_completion():
table = ibis.table({"a": "int", "b": "int", "for": "int", "with spaces": "int"})
# Only valid python identifiers in getattr tab completion
Expand Down

0 comments on commit 0a87137

Please sign in to comment.