Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support StringView and BinaryView in CDataInterface #6171

Merged
merged 2 commits into from
Aug 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions arrow-schema/src/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -390,8 +390,10 @@ impl TryFrom<&FFI_ArrowSchema> for DataType {
"e" => DataType::Float16,
"f" => DataType::Float32,
"g" => DataType::Float64,
"vz" => DataType::BinaryView,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouble checked that vz and vu are the correct format strings: https://arrow.apache.org/docs/format/CDataInterface.html#data-type-description-format-strings

"z" => DataType::Binary,
"Z" => DataType::LargeBinary,
"vu" => DataType::Utf8View,
"u" => DataType::Utf8,
"U" => DataType::LargeUtf8,
"tdD" => DataType::Date32,
Expand Down Expand Up @@ -660,8 +662,10 @@ fn get_format_string(dtype: &DataType) -> Result<String, ArrowError> {
DataType::Float16 => Ok("e".to_string()),
DataType::Float32 => Ok("f".to_string()),
DataType::Float64 => Ok("g".to_string()),
DataType::BinaryView => Ok("vz".to_string()),
DataType::Binary => Ok("z".to_string()),
DataType::LargeBinary => Ok("Z".to_string()),
DataType::Utf8View => Ok("vu".to_string()),
DataType::Utf8 => Ok("u".to_string()),
DataType::LargeUtf8 => Ok("U".to_string()),
DataType::FixedSizeBinary(num_bytes) => Ok(format!("w:{num_bytes}")),
Expand Down Expand Up @@ -810,6 +814,10 @@ mod tests {
5,
));
round_trip_type(DataType::Utf8);
round_trip_type(DataType::Utf8View);
round_trip_type(DataType::BinaryView);
round_trip_type(DataType::Binary);
round_trip_type(DataType::LargeBinary);
round_trip_type(DataType::List(Arc::new(Field::new(
"a",
DataType::Int16,
Expand Down
Loading