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

Method to_array

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

Convert any [`Self::Scalar`] into an Arrow [`ArrayRef`] with the specified number of rows by repeating the same scalar multiple times, which is not as efficient as handling the scalar directly. [`Self::Array`] will just be returned as is. See [`Self::to_array_of_size`] if you need to validate the length of the output array. See [`Self::values_to_arrays`] to convert multiple columnar values into

(&self, num_rows: usize)

Source from the content-addressed store, hash-verified

184 ///
185 /// Errors if `self` is a Scalar that fails to be converted into an array of size
186 pub fn to_array(&self, num_rows: usize) -> Result<ArrayRef> {
187 Ok(match self {
188 ColumnarValue::Array(array) => Arc::clone(array),
189 ColumnarValue::Scalar(scalar) => scalar.to_array_of_size(num_rows)?,
190 })
191 }
192
193 /// Convert a columnar value into an Arrow [`ArrayRef`] with the specified
194 /// number of rows. [`Self::Scalar`] is converted by repeating the same

Callers 3

cast_scalar_valueFunction · 0.45
values_to_arraysMethod · 0.45
fmtMethod · 0.45

Calls 1

to_array_of_sizeMethod · 0.45

Tested by

no test coverage detected