alamb commented on code in PR #11633:
URL: https://github.com/apache/datafusion/pull/11633#discussion_r1689915368


##########
datafusion/core/src/datasource/physical_plan/csv.rs:
##########
@@ -101,6 +218,39 @@ impl CsvExec {
             comment,
         }
     }
+}
+
+impl CsvExec {
+    /// Create a new CSV reader execution plan provided base and specific 
configurations
+    #[deprecated(since = "41.0.0", note = "use `CsvExec::builder` or 
`CsvExecBuilder`")]

Review Comment:
   💯  for keeping (and deprecating the old API) to make migration / upgrade 
easier. 



##########
datafusion/core/src/datasource/physical_plan/csv.rs:
##########
@@ -597,16 +747,15 @@ mod tests {
         let mut config = partitioned_csv_config(file_schema, file_groups);
         config.projection = Some(vec![0, 2, 4]);
 
-        let csv = CsvExec::new(
-            config,
-            true,
-            b',',
-            b'"',
-            None,
-            None,
-            false,
-            file_compression_type.to_owned(),
-        );
+        let csv = CsvExec::builder(config)

Review Comment:
   😍 that is so much nicer 👍 



##########
datafusion/core/src/datasource/physical_plan/csv.rs:
##########
@@ -67,27 +87,124 @@ pub struct CsvExec {
     cache: PlanProperties,
 }
 
-impl CsvExec {
-    /// Create a new CSV reader execution plan provided base and specific 
configurations
-    #[allow(clippy::too_many_arguments)]
-    pub fn new(
-        base_config: FileScanConfig,
-        has_header: bool,
-        delimiter: u8,
-        quote: u8,
-        escape: Option<u8>,
-        comment: Option<u8>,
-        newlines_in_values: bool,
+/// Builder for [`CsvExec`].
+///
+/// See example on [`CsvExec`].
+#[derive(Debug, Clone)]
+pub struct CsvExecBuilder {
+    file_scan_config: FileScanConfig,
+    file_compression_type: FileCompressionType,
+    // TODO: it seems like these format options could be reused across all the 
various CSV config
+    has_header: bool,
+    delimiter: u8,
+    quote: u8,
+    escape: Option<u8>,
+    comment: Option<u8>,
+    newlines_in_values: bool,
+}
+
+impl CsvExecBuilder {
+    /// Create a new builder to read the provided file scan configuration.
+    pub fn new(file_scan_config: FileScanConfig) -> Self {
+        Self {
+            file_scan_config,
+            // TODO: these defaults are duplicated from `CsvOptions` - should 
they be computed?

Review Comment:
   The other thing we could do is to add a test that ensures the options are 
the same rather than having to compute them each time



##########
datafusion/core/src/datasource/physical_plan/csv.rs:
##########
@@ -49,7 +49,27 @@ use object_store::{GetOptions, GetResultPayload, 
ObjectStore};
 use tokio::io::AsyncWriteExt;
 use tokio::task::JoinSet;
 
-/// Execution plan for scanning a CSV file
+/// Execution plan for scanning a CSV file.

Review Comment:
   ❤️ 



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