Skip to content

Commit

Permalink
ARROW-7762: [Python] Do not ignore exception for invalid version in P…
Browse files Browse the repository at this point in the history
…arquetWriter
  • Loading branch information
jorisvandenbossche committed Feb 4, 2020
1 parent 0326ea3 commit 9353658
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 3 additions & 2 deletions python/pyarrow/_parquet.pyx
Expand Up @@ -1304,14 +1304,15 @@ cdef class ParquetWriter:
else:
props.disallow_truncated_timestamps()

cdef void _set_version(self, WriterProperties.Builder* props):
cdef int _set_version(self, WriterProperties.Builder* props) except -1:
if self.version is not None:
if self.version == "1.0":
props.version(ParquetVersion_V1)
elif self.version == "2.0":
props.version(ParquetVersion_V2)
else:
raise ArrowException("Unsupported Parquet format version")
raise ValueError("Unsupported Parquet format version: {0}"
.format(self.version))

cdef void _set_compression_props(self, WriterProperties.Builder* props):
if isinstance(self.compression, basestring):
Expand Down
6 changes: 6 additions & 0 deletions python/pyarrow/tests/test_parquet.py
Expand Up @@ -177,6 +177,12 @@ def test_pandas_parquet_2_0_roundtrip(tempdir, chunk_size):
tm.assert_frame_equal(df, df_read)


def test_parquet_invalid_version(tempdir):
table = pa.table({'a': [1, 2, 3]})
with pytest.raises(ValueError, match="Unsupported Parquet format version"):
_write_table(table, tempdir / 'test_version.parquet', version="2.2")


def test_set_data_page_size():
arr = pa.array([1, 2, 3] * 100000)
t = pa.Table.from_arrays([arr], names=['f0'])
Expand Down

0 comments on commit 9353658

Please sign in to comment.