pitrou commented on code in PR #47524:
URL: https://github.com/apache/arrow/pull/47524#discussion_r2349212122


##########
cpp/src/arrow/csv/writer.cc:
##########
@@ -578,26 +588,59 @@ class CSVWriterImpl : public ipc::RecordBatchWriter {
     return Status::OK();
   }
 
-  int64_t CalculateHeaderSize() const {
+  int64_t CalculateHeaderSize(QuotingStyle quoting_style) const {
     int64_t header_length = 0;
     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 += CountQuotes(col_name);
+      switch (quoting_style) {
+        case QuotingStyle::None:
+          break;
+        case QuotingStyle::Needed:
+        case QuotingStyle::AllValid:
+          header_length += CountQuotes(col_name);

Review Comment:
   Oops, that makes sense, thank you.



##########
cpp/src/arrow/csv/writer.cc:
##########
@@ -578,26 +588,59 @@ class CSVWriterImpl : public ipc::RecordBatchWriter {
     return Status::OK();
   }
 
-  int64_t CalculateHeaderSize() const {
+  int64_t CalculateHeaderSize(QuotingStyle quoting_style) const {
     int64_t header_length = 0;
     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 += CountQuotes(col_name);
+      switch (quoting_style) {
+        case QuotingStyle::None:
+          break;
+        case QuotingStyle::Needed:
+        case QuotingStyle::AllValid:
+          header_length += CountQuotes(col_name);

Review Comment:
   Perhaps add a comment for the future reader?



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