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
5 changes: 4 additions & 1 deletion python/pyarrow/_parquet.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -538,10 +538,13 @@ cdef class ParquetWriter:
def write_table(self, Table table, row_group_size=None):
cdef CTable* ctable = table.table

if row_group_size is None:
if row_group_size is None or row_group_size == -1:
row_group_size = ctable.num_rows()
elif row_group_size == 0:
raise ValueError('Row group size cannot be 0')

cdef int c_row_group_size = row_group_size

with nogil:
check_status(WriteTable(deref(ctable), self.allocator,
self.sink, c_row_group_size,
Expand Down
2 changes: 1 addition & 1 deletion python/pyarrow/parquet.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def write_table(table, sink, chunk_size=None, version='1.0',
----------
table : pyarrow.Table
sink: string or pyarrow.io.NativeFile
chunk_size : int
chunk_size : int, default None
The maximum number of rows in each Parquet RowGroup. As a default,
we will write a single RowGroup per file.
version : {"1.0", "2.0"}, default "1.0"
Expand Down
17 changes: 17 additions & 0 deletions python/pyarrow/tests/test_parquet.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,23 @@ def test_multithreaded_read():
assert table1.equals(table2)


@parquet
def test_min_chunksize():
data = pd.DataFrame([np.arange(4)], columns=['A', 'B', 'C', 'D'])
table = pa.Table.from_pandas(data.reset_index())

buf = io.BytesIO()
pq.write_table(table, buf, chunk_size=-1)

buf.seek(0)
result = pq.read_table(buf)

assert result.equals(table)

with pytest.raises(ValueError):
pq.write_table(table, buf, chunk_size=0)


@parquet
def test_pass_separate_metadata():
# ARROW-471
Expand Down