alamb commented on code in PR #7720:
URL: https://github.com/apache/arrow-rs/pull/7720#discussion_r2160334082


##########
parquet-variant/src/builder.rs:
##########
@@ -484,13 +486,33 @@ impl<'a> ObjectBuilder<'a> {
         }
     }
 
+    fn check_duplicate_field_name(&self, key: &str) -> Result<(), ArrowError> {
+        if let Some(field_name_id) = self.parent.dict.get(key) {
+            if self.fields.contains_key(field_name_id) {
+                return Err(ArrowError::InvalidArgumentError(
+                    "field name must be unique and already exists in this 
object".to_string(),
+                ));
+            }
+        }
+
+        Ok(())
+    }
+
     /// Add a field with key and value to the object
-    pub fn append_value<'m, 'd, T: Into<Variant<'m, 'd>>>(&mut self, key: 
&str, value: T) {
-        let id = self.parent.add_key(key);
+    pub fn append_value<'m, 'd, T: Into<Variant<'m, 'd>>>(

Review Comment:
   The other alternate to erroring on adding a new field would be to just 
overwrite the existing value, which I think is more inline with other Rust 
collection apis such as 
https://doc.rust-lang.org/std/collections/struct.HashMap.html#method.insert
   
   



##########
parquet-variant/src/builder.rs:
##########
@@ -484,13 +486,33 @@ impl<'a> ObjectBuilder<'a> {
         }
     }
 
+    fn check_duplicate_field_name(&self, key: &str) -> Result<(), ArrowError> {
+        if let Some(field_name_id) = self.parent.dict.get(key) {
+            if self.fields.contains_key(field_name_id) {
+                return Err(ArrowError::InvalidArgumentError(

Review Comment:
   If we are going to make this an error, I think we should at least return the 
name of the field in the message to make it easier to debug



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