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

Function make_array_inner

datafusion/spark/src/function/array/spark_array.rs:112–137  ·  view source on GitHub ↗

`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])

Source from the content-addressed store, hash-verified

110/// Constructs an array using the input `data` as `ArrayRef`.
111/// Returns a reference-counted `Array` instance result.
112pub fn make_array_inner(arrays: &[ArrayRef]) -> Result<ArrayRef> {
113 let mut data_type = DataType::Null;
114 for arg in arrays {
115 let arg_data_type = arg.data_type();
116 if !arg_data_type.equals_datatype(&DataType::Null) {
117 data_type = arg_data_type.clone();
118 break;
119 }
120 }
121
122 match data_type {
123 // Either an empty array or all nulls:
124 DataType::Null => {
125 let length = arrays.iter().map(|a| a.len()).sum();
126 // By default Int32
127 let array = new_null_array(&DataType::Null, length);
128 Ok(Arc::new(
129 SingleRowListArrayBuilder::new(array)
130 .with_nullable(true)
131 .with_field_name(Some(ARRAY_FIELD_DEFAULT_NAME.to_string()))
132 .build_list_array(),
133 ))
134 }
135 _ => array_array::<i32>(arrays, data_type, ARRAY_FIELD_DEFAULT_NAME),
136 }
137}

Callers

nothing calls this directly

Calls 11

newFunction · 0.85
sumMethod · 0.80
build_list_arrayMethod · 0.80
with_field_nameMethod · 0.80
data_typeMethod · 0.45
cloneMethod · 0.45
mapMethod · 0.45
iterMethod · 0.45
lenMethod · 0.45
with_nullableMethod · 0.45
to_stringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…