houqp commented on a change in pull request #1715:
URL: https://github.com/apache/arrow-datafusion/pull/1715#discussion_r799968936



##########
File path: datafusion/src/datasource/listing/table.rs
##########
@@ -40,7 +44,70 @@ use crate::datasource::{
 
 use super::helpers::{expr_applicable_for_cols, pruned_partition_list, 
split_files};
 
+/// Configuration for creating a 'ListingTable'  
+pub struct ListingTableConfig {
+    pub object_store: Arc<dyn ObjectStore>,
+    pub table_path: String,
+    pub file_schema: Option<SchemaRef>,
+    pub options: Option<ListingOptions>,
+}
+
+impl ListingTableConfig {
+    /// Creates new `ListingTableConfig`.  The `SchemaRef` and 
`ListingOptions` are inferred based on the suffix of the provided `table_path`.
+    pub async fn new(
+        object_store: Arc<dyn ObjectStore>,
+        table_path: impl Into<String>,
+    ) -> Self {
+        Self {
+            object_store,
+            table_path: table_path.into(),
+            file_schema: None,
+            options: None,
+        }
+    }
+    pub fn with_schema(mut self, schema: SchemaRef) {

Review comment:
       If you consume self and return Self, in these APIs, then you will be 
able to chain them together for a better UX:
   
   ```suggestion
       pub fn with_schema(mut self, schema: SchemaRef) -> Self {
   ```
   
   Something like this:
   
   ```rust
   let cfg = ListingTableConfig::new().with_listing_options().with_scheame();
   ```




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