jayzhan211 commented on code in PR #8552:
URL: https://github.com/apache/arrow-datafusion/pull/8552#discussion_r1430061750


##########
datafusion/common/src/hash_utils.rs:
##########
@@ -207,6 +208,36 @@ fn hash_dictionary<K: ArrowDictionaryKeyType>(
     Ok(())
 }
 
+fn hash_struct_array(
+    array: &StructArray,
+    random_state: &RandomState,
+    hashes_buffer: &mut [u64],
+) -> Result<()> {
+    let values = array.columns();
+    let nulls = array.nulls();
+    let num_columns = values.len();
+
+    // Skip null columns
+    let valid_indices: Vec<usize> = if let Some(nulls) = nulls {
+        nulls.valid_indices().collect()
+    } else {
+        (0..num_columns).collect()
+    };
+
+    for i in valid_indices {
+        let mut values_hashes = vec![0u64; array.len()];
+        let column_values = values[i].clone();
+        // create hashes for each column
+        create_hashes(&[column_values], random_state, &mut values_hashes)?;
+        let hash = &mut hashes_buffer[i];

Review Comment:
   @Dandandan. Not fully got your point. I do consider each column as one value 
(iterate each row in one column with get one final hash `hashes_buffer[i]`).
   
   `i` is the column index in the struct array and is also the hashes_buffer 
index.
   For example, column1, null, column3, column4. We iterate 0, 2, and 3. And 
hash each of them to hashes_buffer[0], hashes_buffer[2], and hashes_buffer[3] 
respectively. A column-wise hashes.



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