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 <jorisvandenbossche@gmail.com>
Signed-off-by: Joris Van den Bossche <jorisvandenbossche@gmail.com>
  • Loading branch information
jorisvandenbossche authored and raulcd committed Jul 13, 2023
1 parent 629c6a1 commit b4c3b41
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 b4c3b41

Please sign in to comment.