friendlymatthew commented on code in PR #7801:
URL: https://github.com/apache/arrow-rs/pull/7801#discussion_r2173768062


##########
parquet-variant/src/builder.rs:
##########
@@ -605,17 +627,30 @@ impl<'a, 'b> ObjectBuilder<'a, 'b> {
         let field_id = self.metadata_builder.upsert_field_name(key);
         let field_start = self.buffer.offset();
 
-        self.fields.insert(field_id, field_start);
+        if self.fields.insert(field_id, field_start).is_some() && 
self.validate_duplicates {
+            self.duplicate_fields.insert(field_id);
+        }
+
         self.buffer.append_non_nested_value(value);
     }
 
+    /// Enables validation for duplicate field keys when inserting into this 
object.
+    /// 
+    /// When this is enabled, calling [`ObjectBuilder::finish`] will return an 
error
+    /// if any duplicate field keys were added using [`ObjectBuilder::insert`].
+    pub fn with_validate_unique_fields(mut self) -> Self {

Review Comment:
   Could we have this function take in a boolean parameter? 
   
   So something like: 
   ```rs
   pub fn with_validate_unique_fields(mut self, validate_unique_fields: bool) 
-> Self
   ```
   
   I see similar patterns in other parts of the codebase: 
   
   
https://github.com/apache/arrow-rs/blob/19a14dcf506953c14e0e380c557a4db8c75bf43e/arrow-json/src/writer/encoder.rs#L43-L47



-- 
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: github-unsubscr...@arrow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to