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
10 changes: 5 additions & 5 deletions python/pyarrow/_parquet.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ cdef class Statistics(_Weakrefable):
except TypeError:
return NotImplemented

def equals(self, Statistics other):
def equals(self, Statistics other not None):
"""
Return whether the two column statistics objects are equal.

Expand Down Expand Up @@ -521,7 +521,7 @@ cdef class ColumnChunkMetaData(_Weakrefable):
except TypeError:
return NotImplemented

def equals(self, ColumnChunkMetaData other):
def equals(self, ColumnChunkMetaData other not None):
"""
Return whether the two column chunk metadata objects are equal.

Expand Down Expand Up @@ -919,7 +919,7 @@ cdef class RowGroupMetaData(_Weakrefable):
except TypeError:
return NotImplemented

def equals(self, RowGroupMetaData other):
def equals(self, RowGroupMetaData other not None):
"""
Return whether the two row group metadata objects are equal.

Expand Down Expand Up @@ -1295,7 +1295,7 @@ cdef class ParquetSchema(_Weakrefable):
except TypeError:
return NotImplemented

def equals(self, ParquetSchema other):
def equals(self, ParquetSchema other not None):
"""
Return whether the two schemas are equal.

Expand Down Expand Up @@ -1350,7 +1350,7 @@ cdef class ColumnSchema(_Weakrefable):
def __reduce__(self):
return ColumnSchema, (self.parent, self.index)

def equals(self, ColumnSchema other):
def equals(self, ColumnSchema other not None):
"""
Return whether the two column schemas are equal.

Expand Down
25 changes: 25 additions & 0 deletions python/pyarrow/tests/parquet/test_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -893,3 +893,28 @@ def test_geospatial_types(parquet_test_datadir):
column_schema = metadata.schema.column(1)
assert column_schema.name == "geography"
assert column_schema.logical_type.type == "GEOGRAPHY"


def test_parquet_metadata_equality_with_none():
table = pa.table({"a": [1, 2, 3]})
with pa.BufferOutputStream() as out:
pq.write_table(table, out)
buf = out.getvalue()
metadata = pq.read_metadata(pa.BufferReader(buf))
row_group = metadata.row_group(0)
column = row_group.column(0)
schema = metadata.schema
objects = (
metadata,
row_group,
column,
column.statistics,
schema,
schema.column(0),
)
none = None
for obj in objects:
with pytest.raises(TypeError, match="Argument 'other' has incorrect type"):
obj.equals(none)
assert (obj == none) is False
assert (obj != none) is True
Loading