add as_ref test for listarray and binaryarray
//
// SPDX-License-Identifier: Apache-2.0.
-use common_exception::Result;
-use common_arrow::arrow::array::PrimitiveArray;
use common_arrow::arrow::array::BooleanArray;
+use common_arrow::arrow::array::PrimitiveArray;
+use common_arrow::arrow::buffer::Buffer;
+use common_exception::Result;
+
use crate::prelude::*;
-use crate::DFUInt16Array;
use crate::DFBooleanArray;
+use crate::DFUInt16Array;
use crate::UInt16Type;
use crate::UInt8Type;
-use common_arrow::arrow::buffer::Buffer;
#[test]
fn test_array_as_ref() -> Result<()> {
@@ -36,7 +37,27 @@ fn test_array_as_ref() -> Result<()> {
utf8_builder.append_value("3c");
let df_utf8_array = utf8_builder.finish();
let arrow_string_array = df_utf8_array.as_ref();
- assert_eq!(&"1a2b3c".as_bytes(), &arrow_string_array.value_data().as_slice());
+ assert_eq!(
+ &"1a2b3c".as_bytes(),
+ &arrow_string_array.value_data().as_slice()
+ );
+
+ // Test DFListArray
+ let mut list_value_builder = ArrowPrimitiveArrayBuilder::<UInt16Type>::new(3);
+ list_value_builder.append_slice(&[1u16, 2u16, 3u16]);
+ let mut list_builder = ListPrimitiveArrayBuilder::<UInt16Type>::new(list_value_builder, 3);
+ let df_list = list_builder.finish();
+ let arrow_list = df_list.as_ref();
+ println!("value-{:?}", arrow_list.values());
+
+ // Test DFBinaryArray
+ let mut binary_builder = BinaryArrayBuilder::new(8);
+ binary_builder.append_value(&[1u8, 2u8, 3u8]);
+ let mut df_binary_array = binary_builder.finish();
+ let arrow_binary_array = df_binary_array.as_ref();
+ assert_eq!(&[5], &arrow_binary_array.values().as_slice());
+
+ // TODO: Test DFStructArray
Ok(())
}
