Smotrov commented on code in PR #18954:
URL: https://github.com/apache/datafusion/pull/18954#discussion_r2567626930


##########
datafusion/common/src/file_options/csv_writer.rs:
##########
@@ -41,6 +43,20 @@ impl CsvWriterOptions {
         Self {
             writer_options,
             compression,
+            compression_level: None,
+        }
+    }
+
+    /// Create a new `CsvWriterOptions` with the specified compression level.
+    pub fn new_with_level(
+        writer_options: WriterBuilder,
+        compression: CompressionTypeVariant,
+        compression_level: Option<u32>,

Review Comment:
   Looking at `flate2::Compression`, it uses `new(level: u32)` + `default()` 
rather than `Option`.
   
   My rationale was config system integration. `CsvOptions.compression_level` 
is `Option<u32>` because users may or may not specify it in config. The 
`new_with_level(..., Option<u32>)` signature makes the `TryFrom<&CsvOptions>` 
impl straightforward.
   
   But I agree the public API could be cleaner. I could:
   1. Keep `new_with_level(..., compression_level: u32)` as you suggest 
(non-optional)
   2. Let `TryFrom` internally call `new()` when `compression_level` is `None`, 
or `new_with_level()` when `Some`
   
   Would you prefer that approach?
   



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