alippai commented on a change in pull request #453:
URL: https://github.com/apache/arrow-rs/pull/453#discussion_r654796610
##########
File path: arrow/src/ffi.rs
##########
@@ -271,12 +271,54 @@ fn to_field(schema: &FFI_ArrowSchema) -> Result<Field> {
.collect::<Result<Vec<_>>>()?;
DataType::Struct(children)
}
- other => {
- return Err(ArrowError::CDataInterface(format!(
- "The datatype \"{:?}\" is still not supported in Rust
implementation",
- other
- )))
- }
+ other => match other
+ .split(|c| c == ':' || c == ',')
+ .collect::<Vec<&str>>()
+ .as_slice()
+ {
+ ["d", precision, scale] => {
+ let parsed_precision = precision.parse::<usize>().map_err(|_| {
+ ArrowError::CDataInterface(format!(
+ "The decimal \"{:?}\" is not supported in Rust
implementation",
+ other
+ ))
+ })?;
+ let parsed_scale = scale.parse::<usize>().map_err(|_| {
+ ArrowError::CDataInterface(format!(
+ "The decimal \"{:?}\" is not supported in Rust
implementation",
+ other
+ ))
+ })?;
+ DataType::Decimal(parsed_precision, parsed_scale)
+ }
+ ["d", precision, scale, bits] => {
+ if *bits != "128" {
+ return Err(ArrowError::CDataInterface(format!(
+ "The decimal \"{:?}\" is still not supported in Rust
implementation",
+ other
+ )));
+ }
+ let parsed_precision = precision.parse::<usize>().map_err(|_| {
+ ArrowError::CDataInterface(format!(
+ "The decimal \"{:?}\" is not supported in Rust
implementation",
Review comment:
Updated
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]