Skip to content

Commit

Permalink
fix(drop): ignore order for DropColumns equality
Browse files Browse the repository at this point in the history
  • Loading branch information
deepyaman authored and cpcloud committed Jul 24, 2024
1 parent efae2ec commit d5a2923
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ibis/expr/operations/relations.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def schema(self):
@public
class DropColumns(Relation):
parent: Relation
columns_to_drop: VarTuple[str]
columns_to_drop: frozenset[str]

@attribute
def schema(self):
Expand Down
2 changes: 1 addition & 1 deletion ibis/expr/types/relations.py
Original file line number Diff line number Diff line change
Expand Up @@ -2501,7 +2501,7 @@ def drop(self, *fields: str | Selector) -> Table:
# no-op if nothing to be dropped
return self

columns_to_drop = tuple(
columns_to_drop = frozenset(
map(operator.methodcaller("get_name"), self._fast_bind(*fields))
)
return ops.DropColumns(parent=self, columns_to_drop=columns_to_drop).to_expr()
Expand Down
6 changes: 6 additions & 0 deletions ibis/tests/expr/test_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -1886,6 +1886,12 @@ def test_drop():
t.drop("e")


def test_drop_equality():
t = ibis.table(dict.fromkeys("abcd", "int"))

assert t.drop("a", "b").equals(t.drop("b", "a"))


def test_python_table_ambiguous():
with pytest.raises(NotImplementedError):
ibis.memtable(
Expand Down

0 comments on commit d5a2923

Please sign in to comment.