`make_array_inner` is the implementation of the `make_array` function. Constructs an array using the input `data` as `ArrayRef`. Returns a reference-counted `Array` instance result.
(arrays: &[ArrayRef])
| 130 | /// Constructs an array using the input `data` as `ArrayRef`. |
| 131 | /// Returns a reference-counted `Array` instance result. |
| 132 | pub(crate) fn make_array_inner(arrays: &[ArrayRef]) -> Result<ArrayRef> { |
| 133 | let data_type = arrays.iter().find_map(|arg| { |
| 134 | let arg_type = arg.data_type(); |
| 135 | (!arg_type.is_null()).then_some(arg_type) |
| 136 | }); |
| 137 | |
| 138 | let data_type = data_type.unwrap_or(&Null); |
| 139 | if data_type.is_null() { |
| 140 | // Either an empty array or all nulls: |
| 141 | let length = arrays.iter().map(|a| a.len()).sum(); |
| 142 | let array = new_null_array(&Null, length); |
| 143 | Ok(Arc::new( |
| 144 | SingleRowListArrayBuilder::new(array).build_list_array(), |
| 145 | )) |
| 146 | } else { |
| 147 | array_array::<i32>(arrays, data_type.clone(), Field::LIST_FIELD_DEFAULT_NAME) |
| 148 | } |
| 149 | } |
| 150 | |
| 151 | /// Convert one or more [`ArrayRef`] of the same type into a |
| 152 | /// `ListArray` or 'LargeListArray' depending on the offset size. |