Rich-T-kid commented on code in PR #10675:
URL: https://github.com/apache/arrow-rs/pull/10675#discussion_r3789829321


##########
arrow-data/src/transform/mod.rs:
##########
@@ -418,12 +432,30 @@ impl<'a> MutableArrayData<'a> {
     /// # Panics
     ///
     /// This function panics if the given `capacities` don't match the data 
type
-    /// of `arrays`. Or when a [Capacities] variant is not yet supported.
+    /// of `arrays`. Or when a [Capacities] variant is not yet supported. Or 
when
+    /// merging dictionary arrays whose combined values overflow the 
dictionary key
+    /// type — see [MutableArrayData::try_with_capacities] for a fallible 
variant.
     pub fn with_capacities(
         arrays: Vec<&'a ArrayData>,
         use_nulls: bool,
         capacities: Capacities,
     ) -> Self {
+        Self::try_with_capacities(arrays, use_nulls, capacities)
+            .expect("MutableArrayData::new is infallible")
+    }
+
+    /// Fallible variant of [MutableArrayData::with_capacities].
+    ///
+    /// Returns `Err(ArrowError::DictionaryKeyOverflowError)` instead of 
panicking when
+    /// merging dictionary arrays whose combined values would overflow the 
dictionary
+    /// key type. Still panics for other unsupported combinations 
(inconsistent input
+    /// types, unsupported `Capacities` variants) as documented on
+    /// [MutableArrayData::with_capacities].

Review Comment:
   is `ArrowError::DictionaryKeyOverflowError` the only type of error this 
function can produce? if not this comment might be a bit too specific 



##########
arrow-data/src/transform/mod.rs:
##########
@@ -410,6 +410,20 @@ impl<'a> MutableArrayData<'a> {
         Self::with_capacities(arrays, use_nulls, Capacities::Array(capacity))
     }
 
+    /// Fallible variant of [MutableArrayData::new].
+    ///
+    /// Unlike [MutableArrayData::new], this does not panic when merging 
dictionary
+    /// arrays whose combined values would overflow the dictionary key type. 
Instead,
+    /// it returns `Err(ArrowError::DictionaryKeyOverflowError)`, letting 
callers
+    /// (e.g. [`interleave`](crate) / `concat`) surface it as a normal error.

Review Comment:
   similar point to before



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

Reply via email to