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

fix(drop): ignore order for DropColumns equality #9677

Merged
merged 1 commit into from
Jul 24, 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
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
Loading