Create a new [`StructArray`] from the provided parts, returning an error on failure The length will be inferred from the length of the child arrays. Returns an error if there are no child arrays. Consider using [`Self::try_new_with_length`] if the length is known to avoid this. # Errors Errors if `fields.len() == 0` Any reason that [`Self::try_new_with_length`] would error
(
fields: Fields,
arrays: Vec<ArrayRef>,
nulls: Option<NullBuffer>,
)
| 104 | /// * `fields.len() == 0` |
| 105 | /// * Any reason that [`Self::try_new_with_length`] would error |
| 106 | pub fn try_new( |
| 107 | fields: Fields, |
| 108 | arrays: Vec<ArrayRef>, |
| 109 | nulls: Option<NullBuffer>, |
| 110 | ) -> Result<Self, ArrowError> { |
| 111 | let len = arrays.first().map(|x| x.len()).ok_or_else(||ArrowError::InvalidArgumentError("use StructArray::try_new_with_length or StructArray::new_empty_fields to create a struct array with no fields so that the length can be set correctly".to_string()))?; |
| 112 | |
| 113 | Self::try_new_with_length(fields, arrays, nulls, len) |
| 114 | } |
| 115 | |
| 116 | /// Create a new [`StructArray`] from the provided parts, returning an error on failure |
| 117 | /// |