Skip to content

Commit

Permalink
GH-36659: [Python] Fix pyarrow.dataset.Partitioning.__eq__ when compa…
Browse files Browse the repository at this point in the history
…ring with other type (#36661)

### Rationale for this change

Ensure that `part == other` doesn't crash with `other` is not a Partitioning instance

Small follow-up on #36462

* Closes: #36659

Authored-by: Joris Van den Bossche <[email protected]>
Signed-off-by: Joris Van den Bossche <[email protected]>
  • Loading branch information
jorisvandenbossche authored Jul 13, 2023
1 parent fbf8a97 commit 994c73b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
5 changes: 2 additions & 3 deletions python/pyarrow/_dataset.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -2348,10 +2348,9 @@ cdef class Partitioning(_Weakrefable):
return self.wrapped

def __eq__(self, other):
try:
if isinstance(other, Partitioning):
return self.partitioning.Equals(deref((<Partitioning>other).unwrap()))
except TypeError:
return False
return False

def parse(self, path):
cdef CResult[CExpression] result
Expand Down
1 change: 1 addition & 0 deletions python/pyarrow/tests/test_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,7 @@ def test_partitioning():
partitioning = klass(schema)
assert isinstance(partitioning, ds.Partitioning)
assert partitioning == klass(schema)
assert partitioning != "other object"

schema = pa.schema([
pa.field('group', pa.int64()),
Expand Down

0 comments on commit 994c73b

Please sign in to comment.