-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Labels
enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomers
Description
Is your feature request related to a problem or challenge?
While reviewing #18971. I noticed many examples like this over the codbase
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:
- It is verbose (most of the fields are the defaults)
- 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
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
let cmd = CreateExternalTable::builder(name, location, "parquet", schema)
.build()?Additional context
No response
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomers