AlenkaF commented on code in PR #36266:
URL: https://github.com/apache/arrow/pull/36266#discussion_r1398859556


##########
python/pyarrow/tests/test_csv.py:
##########
@@ -1972,6 +1972,41 @@ def test_write_csv_decimal(tmpdir, type_factory):
     assert out.column('col').cast(type) == table.column('col')
 
 
[email protected]("data_size", (
+    int(1E2),
+    int(1E4),
+    int(1E6)
+))
+def test_large_binary_write_to_csv(tmpdir, data_size):
+    file_name = tmpdir / "fixedsize_"+str(data_size)+".csv"
+
+    nparr = np.frombuffer(np.random.randint(65, 91, data_size, 'u1'), 'S4')
+
+    fixed_arr = pa.array(nparr, pa.binary(4))
+    fixed_table = pa.Table.from_arrays([fixed_arr], names=['fixedsize'])
+    fixed_table = fixed_table.combine_chunks()
+
+    write_options = WriteOptions(include_header=True, batch_size=2048,
+                                 delimiter='|')
+    write_csv(fixed_table, file_name, write_options=write_options)
+
+    assert os.path.exists(file_name)
+
+    parse_options = ParseOptions(delimiter="|")
+    convert_options = ConvertOptions(column_types={"fixedsize": pa.binary(4)})
+    read_options = ReadOptions(block_size=2048)
+
+    res_table = read_csv(file_name, parse_options=parse_options,
+                         convert_options=convert_options,
+                         read_options=read_options)
+    res_table = res_table.combine_chunks()
+
+    if not res_table.equals(fixed_table):
+        assert assert res_table.schema == fixed_table.schema
+        assert assert res_table.num_rows == fixed_table.num_rows

Review Comment:
   ```suggestion
           assert res_table.schema == fixed_table.schema
           assert res_table.num_rows == fixed_table.num_rows
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to