gruuya commented on code in PR #13468: URL: https://github.com/apache/datafusion/pull/13468#discussion_r1849676627
########## datafusion/common/src/utils/mod.rs: ########## @@ -324,18 +324,29 @@ pub fn longest_consecutive_prefix<T: Borrow<usize>>( /// Wrap an array into a single element `ListArray`. /// For example `[1, 2, 3]` would be converted into `[[1, 2, 3]]` /// The field in the list array is nullable. -pub fn array_into_list_array_nullable(arr: ArrayRef) -> ListArray { - array_into_list_array(arr, true) +pub fn array_into_list_array_nullable( + arr: ArrayRef, + field_name: Option<&str>, +) -> ListArray { + array_into_list_array(arr, true, field_name) } /// Array Utils /// Wrap an array into a single element `ListArray`. /// For example `[1, 2, 3]` would be converted into `[[1, 2, 3]]` -pub fn array_into_list_array(arr: ArrayRef, nullable: bool) -> ListArray { +pub fn array_into_list_array( + arr: ArrayRef, + nullable: bool, + field_name: Option<&str>, +) -> ListArray { let offsets = OffsetBuffer::from_lengths([arr.len()]); ListArray::new( - Arc::new(Field::new_list_field(arr.data_type().to_owned(), nullable)), + Arc::new(Field::new( + field_name.unwrap_or("item"), Review Comment: > I think it should be done in arrow-rs Yeah, makes senseāI can pick that up if there's no objection, maybe something like this ```diff impl Field { + /// Default list member field name + pub const LIST_FIELD_DEFAULT_NAME: &'static str = "item"; + /// Creates a new field with the given name, type, and nullability pub fn new(name: impl Into<String>, data_type: DataType, nullable: bool) -> Self { Field { @@ -144,7 +147,7 @@ impl Field { /// ); /// ``` pub fn new_list_field(data_type: DataType, nullable: bool) -> Self { - Self::new("item", data_type, nullable) + Self::new(Self::LIST_FIELD_DEFAULT_NAME, data_type, nullable) } ``` > could add some comments I think [`new_list_field`](https://docs.rs/arrow/latest/arrow/datatypes/struct.Field.html#method.new_list_field) already has an adequate comment (`Field::new_list` probably doesn't need one since the name is explicitly passed there). -- 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...@datafusion.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For additional commands, e-mail: github-h...@datafusion.apache.org