alamb opened a new issue, #19039:
URL: https://github.com/apache/datafusion/issues/19039

   ### Is your feature request related to a problem or challenge?
   
   While reviewing https://github.com/apache/datafusion/pull/18971. I noticed 
many examples like this over the codbase
   
   ```rust
             let cmd = CreateExternalTable {
                 name,
                 location,
                 file_type: "parquet".to_string(),
                 schema: Arc::new(DFSchema::empty()),
                 table_partition_cols: vec![],
                 if_not_exists: false,
                 or_replace: false,
                 temporary: false,
                 definition: None,
                 order_exprs: vec![],
                 unbounded: false,
                 options: HashMap::new(),
                 constraints: Constraints::default(),
                 column_defaults: HashMap::new(),
             };
   ```
   
   This is non ideal for several reasons: 
   1. It is verbose (most of the fields are the defaults)
   2. It makes it hard to see what fields are actually overridden vs which are 
the defaults
   
   
   
   
   ### Describe the solution you'd like
   
   instead of having to provide values for all fields, most of which are the 
default values, I think it would be nice to have a well commented builder API
   
   
   ### Describe alternatives you've considered
   
   I suggest adding a `CrateExternalTableBuilder` and replace the above code it 
with something like this
   
   ```rust
     let cmd = CreateExternalTable::builder()
       .with_name(name)
       .with_location(location)
       .with_file_type("parquet")
       .with_schema(schema)
       .build()?
   ```
   
   It may make sense to have required parameters be verified by the compiler 
like this
   
   ```rust
     let cmd = CreateExternalTable::builder(name, location, "parquet", schema)
       .build()?
   ```
   
   ### Additional context
   
   _No response_


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