Ted-Jiang commented on code in PR #2097:
URL: https://github.com/apache/arrow-rs/pull/2097#discussion_r924003572


##########
parquet/src/arrow/array_reader/byte_array_dictionary.rs:
##########
@@ -459,7 +481,75 @@ mod tests {
                 None,
                 Some("1"),
                 Some("2"),
-                None
+                None,
+            ]
+        )
+    }
+
+    #[test]
+    fn test_dictionary_preservation_skip() {
+        let data_type = utf8_dictionary();
+
+        let data: Vec<_> = vec!["0", "1", "0", "1", "2", "1", "2"]
+            .into_iter()
+            .map(ByteArray::from)
+            .collect();
+        let (dict, encoded) = encode_dictionary(&data);
+
+        let column_desc = utf8_column();
+        let mut decoder = DictionaryDecoder::<i32, i32>::new(&column_desc);
+
+        decoder
+            .set_dict(dict, 3, Encoding::RLE_DICTIONARY, false)
+            .unwrap();
+
+        decoder
+            .set_data(Encoding::RLE_DICTIONARY, encoded, 14, Some(data.len()))
+            .unwrap();
+
+        let mut output = DictionaryBuffer::<i32, i32>::default();
+        assert_eq!(decoder.skip_values(1).unwrap(), 1);
+        assert_eq!(decoder.read(&mut output, 0..2).unwrap(), 2);
+
+        let mut valid = vec![false, false, false, true, false, true];
+        let valid_buffer = Buffer::from_iter(valid.iter().cloned());
+        output.pad_nulls(0, 2, valid.len(), valid_buffer.as_slice());
+
+        assert!(matches!(output, DictionaryBuffer::Dict { .. }));
+
+        assert_eq!(decoder.skip_values(1).unwrap(), 1);
+        assert_eq!(decoder.read(&mut output, 0..3).unwrap(), 3);

Review Comment:
   Yes it should be, but  like previous  test read two range  '0..3' and '0..4' 
   
https://github.com/apache/arrow-rs/blob/a7f6a6e9261f2320ed34500d6d649efc97617161/parquet/src/arrow/array_reader/byte_array_dictionary.rs#L444-L453
   
    it seems it total read 7 values 
   
https://github.com/apache/arrow-rs/blob/a7f6a6e9261f2320ed34500d6d649efc97617161/parquet/src/arrow/array_reader/byte_array_dictionary.rs#L468-L486



-- 
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: github-unsubscr...@arrow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to