AlenkaF commented on PR #36266:
URL: https://github.com/apache/arrow/pull/36266#issuecomment-1818837257

   I have found out the cause for the random flakey failures in the CI.
   
   The code in the tests is generating a numpy array with random strings of 
length 4. They can also include the string `"NULL"` which currently gets 
converted to `None`.
   
   <details>
   <summary>Reproducible example</summary>
   
   ```python
   import pyarrow as pa
   import numpy as np
   import os
   from pyarrow.csv import (read_csv, write_csv,
                            ConvertOptions, ParseOptions,
                            ReadOptions, WriteOptions)
   
   file_name = "fixedsize_NULL"
   nparr = np.array([b'NULL'])
   fixed_arr = pa.array(nparr, pa.binary(4))
   fixed_table = pa.Table.from_arrays([fixed_arr], names=['fixedsize'])
   
   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)
   ```
   
   ```python
   >>> nparr
   array([b'NULL'], dtype='|S4')
   >>> fixed_table
   pyarrow.Table
   fixedsize: fixed_size_binary[4]
   ----
   fixedsize: [[4E554C4C]]
   >>> res_table
   pyarrow.Table
   fixedsize: fixed_size_binary[4]
   ----
   fixedsize: [[null]]
   ```
   </details>
   
   We should use `convert_options = ConvertOptions(column_types={"fixedsize": 
pa.binary(4)}, quoted_strings_can_be_null=False)` so that `"NULL"` is not 
converted to `None`.
   
   Will add the change via suggestions.


-- 
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