alamb commented on a change in pull request #1435:
URL: https://github.com/apache/arrow-rs/pull/1435#discussion_r827940618



##########
File path: arrow/src/array/array_dictionary.rs
##########
@@ -112,7 +112,11 @@ impl<'a, K: ArrowPrimitiveType> DictionaryArray<K> {
             _ => data = data.null_count(0),
         }
 
-        Ok(data.build()?.into())
+        let array = unsafe { data.build_unchecked() };
+
+        array.validate_dictionary_offest()?;

Review comment:
       That is an excellent point @viirya  -- perhaps we can add a test case 
that tries to do something crazy like use `Float64` keys to verify. 
   
   Perhaps the test could look like this (untested):
   
   
   ```rust
       #[test]
       #[should_panic(
           expected = "Type is not valid dictionary type"
       )]
       fn test_try_new_index_too_large() {
           let values: StringArray = [Some("foo"), 
Some("bar")].into_iter().collect();
           let keys: Float32Array = [Some(0), None, 
Some(3)].into_iter().collect();
           DictionaryArray::<Float32Type>::try_new(&keys, &values).unwrap();
       }
   ```
   
   

##########
File path: arrow/src/array/array_dictionary.rs
##########
@@ -112,7 +112,11 @@ impl<'a, K: ArrowPrimitiveType> DictionaryArray<K> {
             _ => data = data.null_count(0),
         }
 
-        Ok(data.build()?.into())
+        let array = unsafe { data.build_unchecked() };
+
+        array.validate_dictionary_offest()?;

Review comment:
       @viirya  are you suggesting we call `array.validate()` in addition to 
`array.validate_dictionary_offest()`? If so that makes sense to me




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