This is an automated email from the ASF dual-hosted git repository.
jorisvandenbossche pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow.git
The following commit(s) were added to refs/heads/main by this push:
new 994c73b019 GH-36659: [Python] Fix pyarrow.dataset.Partitioning.__eq__
when comparing with other type (#36661)
994c73b019 is described below
commit 994c73b019536b31248f1438278c622d2f0a0f94
Author: Joris Van den Bossche <[email protected]>
AuthorDate: Thu Jul 13 15:28:58 2023 +0200
GH-36659: [Python] Fix pyarrow.dataset.Partitioning.__eq__ when comparing
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 https://github.com/apache/arrow/pull/36462
* Closes: #36659
Authored-by: Joris Van den Bossche <[email protected]>
Signed-off-by: Joris Van den Bossche <[email protected]>
---
python/pyarrow/_dataset.pyx | 5 ++---
python/pyarrow/tests/test_dataset.py | 1 +
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/python/pyarrow/_dataset.pyx b/python/pyarrow/_dataset.pyx
index c5f0a663a8..925565804f 100644
--- a/python/pyarrow/_dataset.pyx
+++ b/python/pyarrow/_dataset.pyx
@@ -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
diff --git a/python/pyarrow/tests/test_dataset.py
b/python/pyarrow/tests/test_dataset.py
index 2f9b6a0922..a70cf2fbc7 100644
--- a/python/pyarrow/tests/test_dataset.py
+++ b/python/pyarrow/tests/test_dataset.py
@@ -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()),