raghavyadav01 commented on issue #26514:
URL: https://github.com/apache/datafusion/issues/26514#issuecomment-6695956169

   Found where this comes from. arrow-csv hands writing to the `csv-core` 
crate, and its `quote()` only escapes the quote character, never the escape 
character itself. So with `double_quote = false`, a `\` in a value is written 
as-is and the reader treats it as an escape. DataFusion can't fix the round 
trip just by choosing writer options.
   
   Suggested fix, in two steps:
   
   1. **Now, in DataFusion:** reject `format.escape` when writing, unless 
`double_quote` is `false` or the escape is the quote character. The issue's 
repro then gives a clear error instead of a file that can't be read back. I 
have this ready with sqllogictest cases. The trade-off: a write with `escape` 
set and no backslashes in the data would now error too, even though it works 
today.
   2. **Upstream:** open an issue in rust-csv so the writer also escapes the 
escape character when `double_quote` is false. Once that's in, DataFusion can 
apply `escape` on write properly and drop the error from step 1.
   
   Does that sound right? If so, I'll open the PR for step 1 and file the 
rust-csv issue.
   


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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to