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



##########
File path: cpp/src/arrow/csv/writer.cc
##########
@@ -390,7 +407,7 @@ class CSVWriterImpl : public ipc::RecordBatchWriter {
     for (int col = 0; col < schema_->num_fields(); col++) {
       const std::string& col_name = schema_->field(col)->name();
       header_length += col_name.size();
-      header_length += CountEscapes(col_name);
+      header_length += options_.escaping ? CountEscapes(col_name) : 0;

Review comment:
       The same goes here, if escaping is disabled, we should ensure that no 
escaping is actually required.

##########
File path: cpp/src/arrow/csv/writer.cc
##########
@@ -390,7 +407,7 @@ class CSVWriterImpl : public ipc::RecordBatchWriter {
     for (int col = 0; col < schema_->num_fields(); col++) {
       const std::string& col_name = schema_->field(col)->name();
       header_length += col_name.size();
-      header_length += CountEscapes(col_name);
+      header_length += options_.escaping ? CountEscapes(col_name) : 0;

Review comment:
       (We should also cover these with tests.)

##########
File path: cpp/src/arrow/csv/writer.cc
##########
@@ -195,11 +199,17 @@ class QuotedColumnPopulator : public ColumnPopulator {
     VisitArrayDataInline<StringType>(
         *input.data(),
         [&](arrow::util::string_view s) {
-          int64_t escaped_count = CountEscapes(s);
-          // TODO: Maybe use 64 bit row lengths or safe cast?
-          row_needs_escaping_[row_number] = escaped_count > 0;
-          row_lengths[row_number] += static_cast<int32_t>(s.length()) +
-                                     static_cast<int32_t>(escaped_count + 
kQuoteCount);
+          if (escaping_) {
+            int64_t escaped_count = CountEscapes(s);

Review comment:
       If escaping is disabled, perhaps we should still count escapes and error 
if the number is non-zero?




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