scovich commented on code in PR #8167:
URL: https://github.com/apache/arrow-rs/pull/8167#discussion_r2287903042


##########
parquet-variant/src/builder.rs:
##########
@@ -1428,54 +1415,61 @@ impl<'a> ObjectBuilder<'a> {
     }
 
     // Returns validate_unique_fields because we can no longer reference self 
once this method returns.
-    fn parent_state<'b>(&'b mut self, key: &'b str) -> (ParentState<'b>, bool) 
{
+    fn parent_state<'b>(
+        &'b mut self,
+        field_name: &'b str,
+    ) -> Result<(ParentState<'b>, bool), ArrowError> {
+        let saved_parent_buffer_offset = 
self.parent_state.saved_buffer_offset();
         let validate_unique_fields = self.validate_unique_fields;
-
         let (buffer, metadata_builder) = 
self.parent_state.buffer_and_metadata_builder();
-
-        let state = ParentState::Object {
+        let state = ParentState::object(
             buffer,
             metadata_builder,
-            fields: &mut self.fields,
-            field_name: key,
-            parent_value_offset_base: self.parent_value_offset_base,
-        };
-        (state, validate_unique_fields)
+            &mut self.fields,
+            saved_parent_buffer_offset,
+            field_name,
+            validate_unique_fields,
+        )?;
+        Ok((state, validate_unique_fields))
     }
 
     /// Returns an object builder that can be used to append a new (nested) 
object to this object.
     ///
+    /// Panics if the requested key cannot be inserted (e.g. because it is a 
duplicate).

Review Comment:
   The top-level builder was, and remains infallible in both its `new_object` 
and `finish` methods?
   
   Here we're dealing with the object builder's (nested) `new_object`, which 
takes a field name and so _could_ fail due to duplicates.



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