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

Method evaluate

datafusion/functions-aggregate/src/string_agg.rs:256–294  ·  view source on GitHub ↗
(&mut self)

Source from the content-addressed store, hash-verified

254 }
255
256 fn evaluate(&mut self) -> Result<ScalarValue> {
257 let scalar = self.array_agg_acc.evaluate()?;
258
259 let ScalarValue::List(list) = scalar else {
260 return internal_err!(
261 "Expected a DataType::List while evaluating underlying ArrayAggAccumulator, but got {}",
262 scalar.data_type()
263 );
264 };
265
266 let string_arr: Vec<_> = match list.value_type() {
267 DataType::LargeUtf8 => as_generic_string_array::<i64>(list.values())?
268 .iter()
269 .flatten()
270 .collect(),
271 DataType::Utf8 => as_generic_string_array::<i32>(list.values())?
272 .iter()
273 .flatten()
274 .collect(),
275 DataType::Utf8View => as_string_view_array(list.values())?
276 .iter()
277 .flatten()
278 .collect(),
279 _ => {
280 return internal_err!(
281 "Expected elements to of type Utf8 or LargeUtf8, but got {}",
282 list.value_type()
283 );
284 }
285 };
286
287 if string_arr.is_empty() {
288 return Ok(ScalarValue::LargeUtf8(None));
289 }
290
291 Ok(ScalarValue::LargeUtf8(Some(
292 string_arr.join(&self.delimiter),
293 )))
294 }
295
296 fn size(&self) -> usize {
297 size_of_val(self) - size_of_val(&self.array_agg_acc)

Callers 10

stateMethod · 0.45
no_duplicates_distinctFunction · 0.45
duplicates_no_distinctFunction · 0.45
duplicates_distinctFunction · 0.45
evaluate_groupsFunction · 0.45

Calls 15

as_string_view_arrayFunction · 0.85
newFunction · 0.85
value_typeMethod · 0.80
collectMethod · 0.80
flattenMethod · 0.80
take_neededMethod · 0.80
sumMethod · 0.80
iterMethod · 0.45
valuesMethod · 0.45
is_emptyMethod · 0.45
joinMethod · 0.45
mapMethod · 0.45

Tested by 8

no_duplicates_distinctFunction · 0.36
duplicates_no_distinctFunction · 0.36
duplicates_distinctFunction · 0.36