diff --git a/src/ffi/array.rs b/src/ffi/array.rs index 76df63ceb5a..5ebdf5d7fcd 100644 --- a/src/ffi/array.rs +++ b/src/ffi/array.rs @@ -243,6 +243,13 @@ fn buffer_offset(array: &ArrowArray, data_type: &DataType, i: usize) -> usize { use PhysicalType::*; match (data_type.to_physical_type(), i) { (LargeUtf8, 2) | (LargeBinary, 2) | (Utf8, 2) | (Binary, 2) => 0, + (FixedSizeBinary, 1) => { + if let DataType::FixedSizeBinary(size) = data_type.to_logical_type() { + (array.offset as usize) * *size + } else { + unreachable!() + } + } _ => array.offset as usize, } } diff --git a/src/ffi/schema.rs b/src/ffi/schema.rs index 3ab3b9edcf8..e06ab4184cf 100644 --- a/src/ffi/schema.rs +++ b/src/ffi/schema.rs @@ -306,6 +306,7 @@ unsafe fn to_data_type(schema: &ArrowSchema) -> Result { let size = size_raw .parse::() .map_err(|_| Error::OutOfSpec("size is not a valid integer".to_string()))?; + println!("schema: {}", size); DataType::FixedSizeBinary(size) } ["+w", size_raw] => { diff --git a/tests/it/ffi/data.rs b/tests/it/ffi/data.rs index 63a4489a0df..39c94001143 100644 --- a/tests/it/ffi/data.rs +++ b/tests/it/ffi/data.rs @@ -81,6 +81,18 @@ fn u32() -> Result<()> { test_round_trip(data) } +#[test] +fn decimal() -> Result<()> { + let data = Int128Array::from_slice(&[1, 0, 2, 0]); + test_round_trip(data) +} + +#[test] +fn decimal_nullable() -> Result<()> { + let data = Int128Array::from(&[Some(1), None, Some(2), None]); + test_round_trip(data) +} + #[test] fn timestamp_tz() -> Result<()> { let data = Int64Array::from(&vec![Some(2), None, None]).to(DataType::Timestamp( @@ -128,6 +140,26 @@ fn large_binary() -> Result<()> { test_round_trip(data) } +#[test] +fn fixed_size_binary() -> Result<()> { + let data = FixedSizeBinaryArray::new( + DataType::FixedSizeBinary(2), + vec![1, 2, 3, 4, 5, 6].into(), + None, + ); + test_round_trip(data) +} + +#[test] +fn fixed_size_binary_nullable() -> Result<()> { + let data = FixedSizeBinaryArray::new( + DataType::FixedSizeBinary(2), + vec![1, 2, 3, 4, 5, 6].into(), + Some([true, true, false].into()), + ); + test_round_trip(data) +} + #[test] fn list() -> Result<()> { let data = vec![ @@ -144,6 +176,22 @@ fn list() -> Result<()> { test_round_trip(array) } +#[test] +fn large_list() -> Result<()> { + let data = vec![ + Some(vec![Some(1i32), Some(2), Some(3)]), + None, + Some(vec![Some(4), None, Some(6)]), + ]; + + let mut array = MutableListArray::>::new(); + array.try_extend(data)?; + + let array: ListArray = array.into(); + + test_round_trip(array) +} + #[test] fn fixed_list() -> Result<()> { let data = vec![ @@ -231,7 +279,11 @@ fn schema() -> Result<()> { fn extension() -> Result<()> { let field = Field::new( "a", - DataType::Extension("a".to_string(), Box::new(DataType::Int32), None), + DataType::Extension( + "a".to_string(), + Box::new(DataType::Int32), + Some("bla".to_string()), + ), true, ); test_round_trip_schema(field)