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


##########
datafusion/datasource/src/table_schema.rs:
##########
@@ -140,7 +140,18 @@ impl TableSchema {
     /// into [`TableSchema::with_table_partition_cols`] if you have partition 
columns at construction time
     /// since it avoids re-computing the table schema.
     pub fn with_table_partition_cols(mut self, partition_cols: Vec<FieldRef>) 
-> Self {

Review Comment:
   if you used `Fields` you could also pass in `impl Into<Fields>` 



##########
datafusion/datasource/src/table_schema.rs:
##########
@@ -140,7 +140,18 @@ impl TableSchema {
     /// into [`TableSchema::with_table_partition_cols`] if you have partition 
columns at construction time
     /// since it avoids re-computing the table schema.
     pub fn with_table_partition_cols(mut self, partition_cols: Vec<FieldRef>) 
-> Self {
-        self.table_partition_cols = partition_cols;
+        if self.table_partition_cols.is_empty() {
+            self.table_partition_cols = Arc::new(partition_cols);
+        } else {
+            // Append to existing partition columns
+            self.table_partition_cols = Arc::new(

Review Comment:
   I recommend `Arc::make_mut` here to avoid the allocation if possible



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