Skip to content
Open
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
5 changes: 4 additions & 1 deletion python/pyarrow/_dataset.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1121,7 +1121,8 @@ cdef class FileSystemDataset(Dataset):
cdef:
CFileSystemDataset* filesystem_dataset

def __init__(self, fragments, Schema schema, FileFormat format,
def __init__(self, fragments, Schema schema not None,
FileFormat format not None,
FileSystem filesystem=None, root_partition=None):
cdef:
FileFragment fragment=None
Expand All @@ -1138,6 +1139,8 @@ cdef class FileSystemDataset(Dataset):
)

for fragment in fragments:
if fragment is None:
raise TypeError("Fragment must not be None")
c_fragments.push_back(
static_pointer_cast[CFileFragment, CFragment](
fragment.unwrap()))
Expand Down
5 changes: 3 additions & 2 deletions python/pyarrow/_parquet.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,8 @@ cdef class SortingColumn:
self.nulls_first = nulls_first

@classmethod
def from_ordering(cls, Schema schema, sort_keys, null_placement='at_end'):
def from_ordering(cls, Schema schema not None, sort_keys,
null_placement='at_end'):
"""
Create a tuple of SortingColumn objects from the same arguments as
:class:`pyarrow.compute.SortOptions`.
Expand Down Expand Up @@ -816,7 +817,7 @@ cdef class SortingColumn:
return tuple(sorting_columns)

@staticmethod
def to_ordering(Schema schema, sorting_columns):
def to_ordering(Schema schema not None, sorting_columns):
"""
Convert a tuple of SortingColumn objects to the same format as
:class:`pyarrow.compute.SortOptions`.
Expand Down
5 changes: 3 additions & 2 deletions python/pyarrow/array.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -4293,8 +4293,9 @@ cdef class DictionaryArray(Array):
return self._indices

@staticmethod
def from_buffers(DataType type, int64_t length, buffers, Array dictionary,
int64_t null_count=-1, int64_t offset=0):
def from_buffers(DataType type not None, int64_t length, buffers,
Array dictionary not None, int64_t null_count=-1,
int64_t offset=0):
"""
Construct a DictionaryArray from buffers.

Expand Down
6 changes: 6 additions & 0 deletions python/pyarrow/tests/parquet/test_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,12 @@ def test_parquet_sorting_column():
with pytest.raises(ValueError):
pq.SortingColumn.from_ordering(schema, (("a", "not a valid sort order")))

with pytest.raises(TypeError, match="Argument 'schema' has incorrect type"):
pq.SortingColumn.from_ordering(None, ())

with pytest.raises(TypeError, match="Argument 'schema' has incorrect type"):
pq.SortingColumn.to_ordering(None, ())

with pytest.raises(ValueError, match="inconsistent null placement"):
sorting_cols = (
pq.SortingColumn(1, nulls_first=True),
Expand Down
7 changes: 7 additions & 0 deletions python/pyarrow/tests/test_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -928,6 +928,13 @@ def test_dictionary_from_buffers(offset):
offset=offset)
assert a[offset:] == b

with pytest.raises(TypeError, match="Argument 'type' has incorrect type"):
pa.DictionaryArray.from_buffers(
None, len(a), a.indices.buffers(), a.dictionary)
with pytest.raises(TypeError, match="Argument 'dictionary' has incorrect type"):
pa.DictionaryArray.from_buffers(
a.type, len(a), a.indices.buffers(), None)


@pytest.mark.numpy
def test_dictionary_from_numpy():
Expand Down
6 changes: 6 additions & 0 deletions python/pyarrow/tests/test_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,12 @@ def test_filesystem_dataset(mockfs):
# validation of required arguments
with pytest.raises(TypeError, match="incorrect type"):
ds.FileSystemDataset(fragments, file_format, schema)
with pytest.raises(TypeError, match="Fragment must not be None"):
ds.FileSystemDataset([None], schema=schema, format=file_format)
with pytest.raises(TypeError, match="Argument 'schema' has incorrect type"):
ds.FileSystemDataset(fragments, schema=None, format=file_format)
with pytest.raises(TypeError, match="Argument 'format' has incorrect type"):
ds.FileSystemDataset(fragments, schema=schema, format=None)
# validation of root_partition
with pytest.raises(TypeError, match="incorrect type"):
ds.FileSystemDataset(fragments, schema=schema,
Expand Down