Skip to content

Commit df59cdd

Browse files
authored
Support StringView and BinaryView in CDataInterface (#6171)
* fix round-trip for view schema in CFFI * add
1 parent 01407f4 commit df59cdd

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

arrow-schema/src/ffi.rs

+8
Original file line numberDiff line numberDiff line change
@@ -390,8 +390,10 @@ impl TryFrom<&FFI_ArrowSchema> for DataType {
390390
"e" => DataType::Float16,
391391
"f" => DataType::Float32,
392392
"g" => DataType::Float64,
393+
"vz" => DataType::BinaryView,
393394
"z" => DataType::Binary,
394395
"Z" => DataType::LargeBinary,
396+
"vu" => DataType::Utf8View,
395397
"u" => DataType::Utf8,
396398
"U" => DataType::LargeUtf8,
397399
"tdD" => DataType::Date32,
@@ -660,8 +662,10 @@ fn get_format_string(dtype: &DataType) -> Result<String, ArrowError> {
660662
DataType::Float16 => Ok("e".to_string()),
661663
DataType::Float32 => Ok("f".to_string()),
662664
DataType::Float64 => Ok("g".to_string()),
665+
DataType::BinaryView => Ok("vz".to_string()),
663666
DataType::Binary => Ok("z".to_string()),
664667
DataType::LargeBinary => Ok("Z".to_string()),
668+
DataType::Utf8View => Ok("vu".to_string()),
665669
DataType::Utf8 => Ok("u".to_string()),
666670
DataType::LargeUtf8 => Ok("U".to_string()),
667671
DataType::FixedSizeBinary(num_bytes) => Ok(format!("w:{num_bytes}")),
@@ -810,6 +814,10 @@ mod tests {
810814
5,
811815
));
812816
round_trip_type(DataType::Utf8);
817+
round_trip_type(DataType::Utf8View);
818+
round_trip_type(DataType::BinaryView);
819+
round_trip_type(DataType::Binary);
820+
round_trip_type(DataType::LargeBinary);
813821
round_trip_type(DataType::List(Arc::new(Field::new(
814822
"a",
815823
DataType::Int16,

0 commit comments

Comments
 (0)