MCPcopy Create free account
hub / github.com/apache/datafusion / to_array_of_size

Method to_array_of_size

datafusion/expr-common/src/columnar_value.rs:206–221  ·  view source on GitHub ↗

Convert a columnar value into an Arrow [`ArrayRef`] with the specified number of rows. [`Self::Scalar`] is converted by repeating the same scalar multiple times which is not as efficient as handling the scalar directly. This validates that if this is [`Self::Array`], it has the expected length. See [`Self::values_to_arrays`] to convert multiple columnar values into arrays of the same length. # E

(&self, num_rows: usize)

Source from the content-addressed store, hash-verified

204 /// Errors if `self` is a Scalar that fails to be converted into an array of size or
205 /// if the array length does not match the expected length
206 pub fn to_array_of_size(&self, num_rows: usize) -> Result<ArrayRef> {
207 match self {
208 ColumnarValue::Array(array) => {
209 if array.len() == num_rows {
210 Ok(Arc::clone(array))
211 } else {
212 internal_err!(
213 "Array length {} does not match expected length {}",
214 array.len(),
215 num_rows
216 )
217 }
218 }
219 ColumnarValue::Scalar(scalar) => scalar.to_array_of_size(num_rows),
220 }
221 }
222
223 /// Null columnar values are implemented as a null array in order to pass batch
224 /// num_rows

Callers 5

newMethod · 0.45
into_arrayMethod · 0.45
into_array_of_sizeMethod · 0.45
to_arrayMethod · 0.45
expect_castFunction · 0.45

Calls 1

lenMethod · 0.45

Tested by

no test coverage detected