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

Method evaluate

datafusion/expr/src/higher_order_function.rs:328–351  ·  view source on GitHub ↗

Evaluate this lambda `args` should evaluate to the value of each parameter of the correspondent lambda returned in [HigherOrderUDFImpl::lambda_parameters]. `spread_captures` is responsible for transforming the captured column arrays so they align with the evaluation batch. Captures are snapshotted from the outer batch at construction time, giving one value per outer row, but the function may eval

(
        &self,
        args: &[&dyn Fn() -> Result<ArrayRef>],
        spread_captures: impl FnOnce(&[ArrayRef]) -> Result<Vec<ArrayRef>>,
    )

Source from the content-addressed store, hash-verified

326 ///
327 /// If the lambda has no captures, `spread_captures` is never called.
328 pub fn evaluate(
329 &self,
330 args: &[&dyn Fn() -> Result<ArrayRef>],
331 spread_captures: impl FnOnce(&[ArrayRef]) -> Result<Vec<ArrayRef>>,
332 ) -> Result<ColumnarValue> {
333 let spread_captures = self
334 .captures
335 .as_ref()
336 .map(|captures| {
337 let spread_columns = spread_captures(captures.columns())?;
338
339 RecordBatch::try_new(captures.schema(), spread_columns)
340 })
341 .transpose()?;
342
343 let merged = merge_captures_with_variables(
344 spread_captures.as_ref(),
345 Arc::clone(&self.schema),
346 &self.params,
347 args,
348 )?;
349
350 self.body.evaluate(&merged)
351 }
352}
353
354fn merge_captures_with_variables(

Callers 2

evaluate_to_scalarMethod · 0.45

Calls 5

columnsMethod · 0.80
mapMethod · 0.45
as_refMethod · 0.45
schemaMethod · 0.45

Tested by

no test coverage detected