egolearner commented on code in PR #49858:
URL: https://github.com/apache/arrow/pull/49858#discussion_r3253803903
##########
python/pyarrow/tests/test_csv.py:
##########
@@ -2149,3 +2149,49 @@ def
test_write_csv_empty_batch_should_not_pollute_output(tables, expected):
result = buf.read()
assert result == expected
+
+
+def test_write_csv_custom_delimiter_from_parse_options():
+ import pyarrow.dataset as ds
+
+ table = pa.table({
+ "B": ["B1", "B2"],
+ "C": ["C1", "C2"],
+ })
+
+ # Verify that CsvFileFormat.make_write_options propagates the
+ # parse delimiter to write options when no explicit delimiter is given
+ for delimiter in [">", "|", "\t", ";"]:
+ csv_format = ds.CsvFileFormat(pa.csv.ParseOptions(delimiter=delimiter))
+ write_opts = csv_format.make_write_options()
+ assert write_opts.write_options.delimiter == delimiter
+
+ # Verify that an explicitly passed delimiter takes precedence
+ csv_format = ds.CsvFileFormat(pa.csv.ParseOptions(delimiter=">"))
+ write_opts = csv_format.make_write_options(delimiter="|")
+ assert write_opts.write_options.delimiter == "|"
+
+ # Verify the default delimiter is still "," when no parse options are given
+ csv_format = ds.CsvFileFormat()
+ write_opts = csv_format.make_write_options()
+ assert write_opts.write_options.delimiter == ","
+
+ # Verify end-to-end: write_dataset with custom delimiter produces
+ # output using that delimiter, not the default ","
+ with tempfile.TemporaryDirectory() as tmpdir:
Review Comment:
done
--
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]