This is an automated email from the ASF dual-hosted git repository.

tustvold pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow-rs.git


The following commit(s) were added to refs/heads/master by this push:
     new 00be18dda5 fix: compute_dictionary_mapping use wrong offsetSize (#4625)
00be18dda5 is described below

commit 00be18dda519599536678069d02ce1bd8dc246ec
Author: jakevin <[email protected]>
AuthorDate: Thu Aug 3 18:15:13 2023 +0800

    fix: compute_dictionary_mapping use wrong offsetSize (#4625)
    
    * fix: compute_dictionary_mapping use wrong offsetSize
    
    * add a unit test to check type
---
 arrow-row/src/dictionary.rs |  2 +-
 arrow-row/src/lib.rs        | 28 ++++++++++++++++++++++++++++
 2 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/arrow-row/src/dictionary.rs b/arrow-row/src/dictionary.rs
index 6c3ee9e18c..740b2e205c 100644
--- a/arrow-row/src/dictionary.rs
+++ b/arrow-row/src/dictionary.rs
@@ -37,7 +37,7 @@ pub fn compute_dictionary_mapping(
         values => interner
             .intern(values.iter().map(|x| x.map(|x| x.encode()))),
         DataType::Binary => {
-            let iter = as_generic_binary_array::<i64>(values).iter();
+            let iter = as_generic_binary_array::<i32>(values).iter();
             interner.intern(iter)
         }
         DataType::LargeBinary => {
diff --git a/arrow-row/src/lib.rs b/arrow-row/src/lib.rs
index 83ed812df5..396f09380a 100644
--- a/arrow-row/src/lib.rs
+++ b/arrow-row/src/lib.rs
@@ -2442,4 +2442,32 @@ mod tests {
             assert_eq!(&back[0], &array);
         }
     }
+
+    #[test]
+    fn test_append_codec_dictionary_binary() {
+        use DataType::*;
+        // Dictionary RowConverter
+        let mut converter = RowConverter::new(vec![SortField::new(Dictionary(
+            Box::new(Int32),
+            Box::new(Binary),
+        ))])
+        .unwrap();
+        let mut rows = converter.empty_rows(4, 128);
+
+        let keys = Int32Array::from_iter_values([0, 1, 2, 3]);
+        let values = BinaryArray::from(vec![
+            Some("a".as_bytes()),
+            Some(b"b"),
+            Some(b"c"),
+            Some(b"d"),
+        ]);
+        let dict_array = DictionaryArray::new(keys, Arc::new(values));
+
+        rows.clear();
+        let array = Arc::new(dict_array) as ArrayRef;
+        converter.append(&mut rows, &[array.clone()]).unwrap();
+        let back = converter.convert_rows(&rows).unwrap();
+
+        assert_eq!(&back[0], &array);
+    }
 }

Reply via email to