jorgecarleitao commented on a change in pull request #453:
URL: https://github.com/apache/arrow-rs/pull/453#discussion_r654790603



##########
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:
       This happens when the type is incorrect, right? Shouldn't we return a 
different message here? Something like "The decimal type requires an integer 
precision"? Same for the scale.

##########
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 == ',')

Review comment:
       It is a cool ideal, but I believe that this also accepts something like 
`d:1:2`, which is not in spec.




-- 
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]


Reply via email to