alamb commented on a change in pull request #1507: URL: https://github.com/apache/arrow-rs/pull/1507#discussion_r839904906
########## File path: arrow/src/array/array_map.rs ########## @@ -152,6 +155,44 @@ impl MapArray { value_offsets, }) } + + /// Creates map array from provided keys, values and entry_offsets. + pub fn new_from_strings<'a>( + keys: impl Iterator<Item = &'a str>, + values: ArrayData, Review comment: What would you think about using a `values: &dyn Array` here? I think that might be more natural Also while reviewing this PR, it seems like keys and entry_offsets are connected to be matched -- I wonder if it would make more sense to have a function like ```rust pub fn new_keys_and_offsets<'a>( keys_and_offsets: impl Iterator<Item = (&'a str, usize)>, values: &dyn Array, ) ... ``` So that the user would provide some way to provide the key names and offsets into values directly 🤔 ########## File path: arrow/src/array/array_map.rs ########## @@ -152,6 +155,44 @@ impl MapArray { value_offsets, }) } + + /// Creates map array from provided keys, values and entry_offsets. + pub fn new_from_strings<'a>( + keys: impl Iterator<Item = &'a str>, + values: ArrayData, + entry_offsets: &[u32], + ) -> Result<Self, ArrowError> { + let entry_offsets_buffer = Buffer::from(entry_offsets.to_byte_slice()); + let keys_data = StringArray::from_iter_values(keys); + + let keys_field = Field::new("keys", DataType::Utf8, false); + let values_feild = Field::new( Review comment: ```suggestion let values_field = Field::new( ``` ########## File path: arrow/src/array/array_map.rs ########## @@ -152,6 +155,44 @@ impl MapArray { value_offsets, }) } + + /// Creates map array from provided keys, values and entry_offsets. + pub fn new_from_strings<'a>( + keys: impl Iterator<Item = &'a str>, + values: ArrayData, + entry_offsets: &[u32], + ) -> Result<Self, ArrowError> { + let entry_offsets_buffer = Buffer::from(entry_offsets.to_byte_slice()); + let keys_data = StringArray::from_iter_values(keys); + + let keys_field = Field::new("keys", DataType::Utf8, false); + let values_feild = Field::new( Review comment: minor typo -- 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-unsubscr...@arrow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org