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


##########
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:
   You can see the comments above 
https://github.com/apache/arrow/pull/47524#discussion_r2332462200. Due to the 
misunderstanding usage of `QuotingStyle::Needed` in csv data, 
`QuotingStyle::Needed` doesn't means that quoting is only applied when needed, 
but means that quote when data type is binary and not to quote when data type 
is integer, decimal or some other types.



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