jorgecarleitao commented on a change in pull request #8561:
URL: https://github.com/apache/arrow/pull/8561#discussion_r517119905
##########
File path: rust/arrow/src/array/array.rs
##########
@@ -2319,13 +2221,24 @@ impl<T: ArrowPrimitiveType> From<ArrayDataRef> for
DictionaryArray<T> {
"DictionaryArray should contain a single child array (values)."
);
- let raw_values = data.buffers()[0].raw_data();
- let dtype: &DataType = data.data_type();
- let values = make_array(data.child_data()[0].clone());
- if let DataType::Dictionary(_, _) = dtype {
+ if let DataType::Dictionary(key_data_type, _) = data.data_type() {
+ if key_data_type.as_ref() != &T::DATA_TYPE {
+ panic!("DictionaryArray's data type must match.")
Review comment:
Thanks for the suggestions.
Isn't `unreachable` used when the program arrives at an inconsistent state?
IMO, in this case, we are checking user input (this function is public) and
ensure that we will not reach an inconsistent state (in the same way
`assert_eq` does). `assert_eq` calls `panic!`, which is why I also used
`panic!` here.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]