Skip to content

Commit c1538de

Browse files
authored
support fixedbinary(n) (#2348)
## Which issue does this PR close? - Closes #2347 . ## What changes are included in this PR? This change performs datum conversion for FixedSizedBinaryArray types from fixed binary primitive types. It closely follows the previously added support for Uuid types. ## Are these changes tested? Yes
1 parent 02496d3 commit c1538de

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

crates/iceberg/src/arrow/schema.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -762,6 +762,11 @@ pub(crate) fn get_arrow_datum(datum: &Datum) -> Result<Arc<dyn ArrowDatum + Send
762762
let array = FixedSizeBinaryArray::try_from_iter(vec![bytes].into_iter()).unwrap();
763763
Ok(Arc::new(Scalar::new(array)))
764764
}
765+
(PrimitiveType::Fixed(_), PrimitiveLiteral::Binary(value)) => {
766+
let array = FixedSizeBinaryArray::try_from_iter(std::iter::once(value.as_slice()))
767+
.map_err(|e| Error::new(ErrorKind::DataInvalid, e.to_string()))?;
768+
Ok(Arc::new(Scalar::new(array)))
769+
}
765770

766771
(primitive_type, _) => Err(Error::new(
767772
ErrorKind::FeatureUnsupported,
@@ -2154,6 +2159,18 @@ mod tests {
21542159
assert!(is_scalar);
21552160
assert_eq!(array.value(0), [66u8; 16]);
21562161
}
2162+
{
2163+
let datum = Datum::fixed(vec![1u8, 2, 3, 4, 5, 6, 7, 8]);
2164+
let arrow_datum = get_arrow_datum(&datum).unwrap();
2165+
let (array, is_scalar) = arrow_datum.get();
2166+
let array = array
2167+
.as_any()
2168+
.downcast_ref::<FixedSizeBinaryArray>()
2169+
.unwrap();
2170+
assert!(is_scalar);
2171+
assert_eq!(array.value_length(), 8);
2172+
assert_eq!(array.value(0), &[1u8, 2, 3, 4, 5, 6, 7, 8]);
2173+
}
21572174
}
21582175

21592176
#[test]

0 commit comments

Comments
 (0)