From 6433c148d0cc6275ff6f987abafea719627651c2 Mon Sep 17 00:00:00 2001 From: Wes McKinney Date: Tue, 9 May 2017 23:50:25 -0400 Subject: [PATCH] Add Parquet unit test for fixed size binary Change-Id: I33ed65360d04b61a846d856737c5e46ac5af65ca --- python/pyarrow/tests/test_parquet.py | 33 +++++++++++++++++++++------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/python/pyarrow/tests/test_parquet.py b/python/pyarrow/tests/test_parquet.py index bb3a9ed5f4a..7144de2a685 100644 --- a/python/pyarrow/tests/test_parquet.py +++ b/python/pyarrow/tests/test_parquet.py @@ -349,9 +349,7 @@ def test_column_of_lists(tmpdir): @parquet -def test_date_time_types(tmpdir): - buf = io.BytesIO() - +def test_date_time_types(): t1 = pa.date32() data1 = np.array([17259, 17260, 17261], dtype='int32') a1 = pa.Array.from_pandas(data1, type=t1) @@ -388,11 +386,7 @@ def test_date_time_types(tmpdir): ['date32', 'date64', 'timestamp[us]', 'time32[s]', 'time64[us]', 'time32[s]']) - pq.write_table(table, buf, version="2.0") - buf.seek(0) - - result = pq.read_table(buf) - assert result.equals(expected) + _check_roundtrip(table, expected=expected, version='2.0') # Unsupported stuff def _assert_unsupported(array): @@ -408,6 +402,29 @@ def _assert_unsupported(array): _assert_unsupported(a7) +@parquet +def test_fixed_size_binary(): + t0 = pa.binary(10) + data = [b'fooooooooo', None, b'barooooooo', b'quxooooooo'] + a0 = pa.array(data, type=t0) + + table = pa.Table.from_arrays([a0], + ['binary[10]']) + _check_roundtrip(table) + + +def _check_roundtrip(table, expected=None, **params): + buf = io.BytesIO() + pq.write_table(table, buf, **params) + buf.seek(0) + + if expected is None: + expected = table + + result = pq.read_table(buf) + assert result.equals(expected) + + @parquet def test_multithreaded_read(): df = alltypes_sample(size=10000)