Skip to content
Closed
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
9 changes: 9 additions & 0 deletions python/pyarrow/tests/test_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,15 @@ def test_schema_equals_propagates_check_metadata():
assert schema1.equals(schema2, check_metadata=False)


def test_schema_equals_invalid_type():
# ARROW-5873
schema = pa.schema([pa.field("a", pa.int64())])

for val in [None, 'string', pa.array([1, 2])]:
with pytest.raises(TypeError):
schema.equals(val)


def test_schema_equality_operators():
fields = [
pa.field('foo', pa.int32()),
Expand Down
5 changes: 2 additions & 3 deletions python/pyarrow/types.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -811,7 +811,7 @@ cdef class Schema:
metadata=self.metadata
)

def equals(self, other, bint check_metadata=True):
def equals(self, Schema other not None, bint check_metadata=True):
"""
Test if this schema is equal to the other

Expand All @@ -825,8 +825,7 @@ cdef class Schema:
-------
is_equal : boolean
"""
cdef Schema _other = other
return self.sp_schema.get().Equals(deref(_other.schema),
return self.sp_schema.get().Equals(deref(other.schema),
check_metadata)

@classmethod
Expand Down