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>>,
)
| 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 | |
| 354 | fn merge_captures_with_variables( |
no test coverage detected