albertlockett commented on code in PR #7611:
URL: https://github.com/apache/arrow-rs/pull/7611#discussion_r2143695610
##########
arrow-array/src/builder/generic_bytes_dictionary_builder.rs:
##########
@@ -152,6 +155,65 @@ where
values_builder,
})
}
+
+ /// Creates a new `GenericByteDictionaryBuilder` from the existing builder
with the same
+ /// keys and values, but with a new data type for the keys.
+ ///
+ /// # example
+ /// ```
+ /// # use arrow_array::builder::StringDictionaryBuilder;
+ /// # use arrow_array::types::{UInt8Type, UInt16Type};
+ /// # use arrow_array::UInt16Array;;
+ ///
+ /// let mut u8_keyed_builder = StringDictionaryBuilder::<UInt8Type>::new();
+ /// u8_keyed_builder.append("def").unwrap();
+ /// u8_keyed_builder.append_null();
+ /// u8_keyed_builder.append("abc").unwrap();
+ ///
+ /// // for some reason, we decide we need to upgrade the key type
Review Comment:
Yes I can absolutely clarify the example a bit.
It's true that there's not really a way to know a-priori that calling append
would overflow using the dictionary.
Currently, the way to know that there's a need to upgrade the keys is to try
to append the value, and then check if the return value is
`Err(ArrowError::DictionaryKeyOverflowError{})`. For my own purposes, I'm
actually OK with this
--
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]