lidavidm commented on a change in pull request #12426:
URL: https://github.com/apache/arrow/pull/12426#discussion_r809022015



##########
File path: cpp/src/arrow/csv/options.cc
##########
@@ -73,6 +73,9 @@ Status ReadOptions::Validate() const {
 WriteOptions WriteOptions::Defaults() { return WriteOptions(); }
 
 Status WriteOptions::Validate() const {
+  if (ARROW_PREDICT_FALSE(delimiter == '\n' || delimiter == '\r' || delimiter 
== '"')) {
+    return Status::Invalid("WriteOptions: delimiter cannot be \\r or \\n");

Review comment:
       The error message should be updated as well.
   
   Actually, we should check delimiter against `eol` too right?

##########
File path: cpp/src/arrow/csv/writer_test.cc
##########
@@ -233,7 +241,16 @@ std::vector<WriterTestParams> GenerateTestCases() {
       reject_structural_params({"0123456789", nullptr, "abcde,", nullptr}, 
"abcde,"),
       reject_structural_params({"0123456789", nullptr, "abcdef,", nullptr}, 
"abcdef,"),
       reject_structural_params({nullptr, nullptr, ",0123456789", "abcde"}, 
",0123456789"),
-      reject_structural_params({"0123456", nullptr, "7\\\"89", ",abcdef"}, 
"7\"89")};
+      reject_structural_params({"0123456", nullptr, "7\\\"89", ",abcdef"}, 
"7\"89"),
+      // exercise custom delimiter
+      {schema_custom_delimiter, batch_custom_delimiter,
+       DefaultTestOptions(/*include_header=*/false, /*null_string=*/"",
+                          QuotingStyle::Needed, "\n", /*delimiter=*/'\t'),
+       expected_output_delimiter_tabs},
+      {schema_custom_delimiter, batch_custom_delimiter,
+       DefaultTestOptions(/*include_header=*/false, /*null_string=*/"",
+                          QuotingStyle::Needed, "\n", /*delimiter=*/'|'),
+       expected_output_delimiter_pipe}};

Review comment:
       Can we add a couple cases with invalid parameters to make sure they're 
properly rejected? See how reject_structural_params sets things up.

##########
File path: python/pyarrow/tests/test_csv.py
##########
@@ -326,7 +326,7 @@ def test_write_options():
     opts = cls()
 
     check_options_class(
-        cls, include_header=[True, False])
+        cls, include_header=[True, False], delimiter=[",", "\t", "|"])

Review comment:
       Can we add a case to 
https://github.com/apache/arrow/blob/db2401c53f63643b06cab4c683cc086b915ec5c4/python/pyarrow/tests/test_csv.py#L1875-L1880
 ?




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