You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/07/12 06:16:54 UTC

[GitHub] [arrow-rs] sunchao commented on a diff in pull request #2042: Support MapType in FFI

sunchao commented on code in PR #2042:
URL: https://github.com/apache/arrow-rs/pull/2042#discussion_r918585030


##########
arrow/src/datatypes/ffi.rs:
##########
@@ -404,4 +411,26 @@ mod tests {
         assert!(result.is_err());
         Ok(())
     }
+
+    #[test]
+    fn test_map_keys_sorted() {
+        let keys = Field::new("keys", DataType::Int32, false);
+        let values = Field::new("values", DataType::UInt32, false);
+        let entry_struct = DataType::Struct(vec![keys, values]);
+
+        // Construct a map array from the above two
+        let map_data_type =
+            DataType::Map(Box::new(Field::new("entries", entry_struct, true)), false);
+
+        let flags = Flags::MAP_KEYS_SORTED;
+
+        let arrow_schema = FFI_ArrowSchema::try_from(map_data_type)
+            .unwrap()
+            .with_name("map")
+            .unwrap()
+            .with_flags(flags)
+            .unwrap();

Review Comment:
   use `?` instead



##########
arrow/src/datatypes/ffi.rs:
##########
@@ -404,4 +411,26 @@ mod tests {
         assert!(result.is_err());
         Ok(())
     }
+
+    #[test]
+    fn test_map_keys_sorted() {
+        let keys = Field::new("keys", DataType::Int32, false);
+        let values = Field::new("values", DataType::UInt32, false);
+        let entry_struct = DataType::Struct(vec![keys, values]);
+
+        // Construct a map array from the above two
+        let map_data_type =
+            DataType::Map(Box::new(Field::new("entries", entry_struct, true)), false);
+
+        let flags = Flags::MAP_KEYS_SORTED;
+
+        let arrow_schema = FFI_ArrowSchema::try_from(map_data_type)
+            .unwrap()
+            .with_name("map")
+            .unwrap()
+            .with_flags(flags)

Review Comment:
   why we have to set flags here? shouldn't `try_from` already set it from the input type?



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

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org