You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by al...@apache.org on 2022/03/22 11:07:13 UTC

[arrow-rs] branch master updated: Fix generate_map_case (#1457)

This is an automated email from the ASF dual-hosted git repository.

alamb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow-rs.git


The following commit(s) were added to refs/heads/master by this push:
     new 8453b2d  Fix generate_map_case (#1457)
8453b2d is described below

commit 8453b2d3b5aece54815d439f4828cb0a1f9eb439
Author: Liang-Chi Hsieh <vi...@gmail.com>
AuthorDate: Tue Mar 22 04:07:08 2022 -0700

    Fix generate_map_case (#1457)
---
 integration-testing/src/lib.rs | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/integration-testing/src/lib.rs b/integration-testing/src/lib.rs
index 3a6ee4c..901c1f4 100644
--- a/integration-testing/src/lib.rs
+++ b/integration-testing/src/lib.rs
@@ -602,6 +602,31 @@ fn array_from_json(
             }
             Ok(Arc::new(b.finish()))
         }
+        DataType::Map(child_field, _) => {
+            let null_buf = create_null_buf(&json_col);
+            let children = json_col.children.clone().unwrap();
+            let child_array = array_from_json(
+                child_field,
+                children.get(0).unwrap().clone(),
+                dictionaries,
+            )?;
+            let offsets: Vec<i32> = json_col
+                .offset
+                .unwrap()
+                .iter()
+                .map(|v| v.as_i64().unwrap() as i32)
+                .collect();
+            let array_data = ArrayData::builder(field.data_type().clone())
+                .len(json_col.count)
+                .add_buffer(Buffer::from(&offsets.to_byte_slice()))
+                .add_child_data(child_array.data().clone())
+                .null_bit_buffer(null_buf)
+                .build()
+                .unwrap();
+
+            let array = MapArray::from(array_data);
+            Ok(Arc::new(array))
+        }
         t => Err(ArrowError::JsonError(format!(
             "data type {:?} not supported",
             t