martin-g commented on code in PR #18448:
URL: https://github.com/apache/datafusion/pull/18448#discussion_r2499146163


##########
datafusion/common/src/scalar/mod.rs:
##########
@@ -878,10 +878,10 @@ impl Hash for ScalarValue {
 
 fn hash_nested_array<H: Hasher>(arr: ArrayRef, state: &mut H) {
     let len = arr.len();
-    let arrays = vec![arr];
     let hashes_buffer = &mut vec![0; len];
     let random_state = ahash::RandomState::with_seeds(0, 0, 0, 0);
-    let hashes = create_hashes(&arrays, &random_state, hashes_buffer).unwrap();
+    let hashes =
+        create_hashes_from_arrays(&[arr.as_ref()], &random_state, 
hashes_buffer).unwrap();

Review Comment:
   ```suggestion
           create_hashes_from_arrays(&[arr.as_ref()], &random_state, 
hashes_buffer).expect("hash_nested_array: failed to create row hashes");
   ```



##########
datafusion/common/src/hash_utils.rs:
##########
@@ -896,4 +922,20 @@ mod tests {
 
         assert_ne!(one_col_hashes, two_col_hashes);
     }
+
+    #[test]
+    fn test_create_hashes_from_arrays() {
+        let int_array = Arc::new(Int32Array::from(vec![1, 2, 3, 4]));
+        let float_array = Arc::new(Float64Array::from(vec![1.0, 2.0, 3.0, 
4.0]));
+
+        let random_state = RandomState::with_seeds(0, 0, 0, 0);
+        let hashes_buff = &mut vec![0; int_array.len()];
+        let hashes = create_hashes_from_arrays(
+            &[int_array.as_ref(), float_array.as_ref()],
+            &random_state,
+            hashes_buff,
+        )
+        .unwrap();
+        assert_eq!(hashes.len(), 4,);
+    }

Review Comment:
   ```suggestion
       }
       
       #[test]
       fn test_create_hashes_equivalence() {
           let array = Arc::new(Int32Array::from(vec![1, 2, 3, 4]));
           let random_state = RandomState::with_seeds(0, 0, 0, 0);
           
           let mut hashes1 = vec![0; array.len()];
           create_hashes(&[Arc::clone(&array)], &random_state, &mut 
hashes1).unwrap();
           
           let mut hashes2 = vec![0; array.len()];
           create_hashes_from_arrays(&[array.as_ref()], &random_state, &mut 
hashes2).unwrap();
           
           assert_eq!(hashes1, hashes2);
       }
   ```



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to