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

Method evaluate

datafusion/functions-window/src/nth_value.rs:445–465  ·  view source on GitHub ↗
(
        &mut self,
        values: &[ArrayRef],
        range: &Range<usize>,
    )

Source from the content-addressed store, hash-verified

443 }
444
445 fn evaluate(
446 &mut self,
447 values: &[ArrayRef],
448 range: &Range<usize>,
449 ) -> Result<ScalarValue> {
450 if let Some(ref result) = self.state.finalized_result {
451 Ok(result.clone())
452 } else {
453 // FIRST_VALUE, LAST_VALUE, NTH_VALUE window functions take a single column, values will have size 1.
454 let arr = &values[0];
455 let n_range = range.end - range.start;
456 if n_range == 0 {
457 // We produce None if the window is empty.
458 return ScalarValue::try_from(arr.data_type());
459 }
460 match self.valid_index(arr, range) {
461 Some(index) => ScalarValue::try_from_array(arr, index),
462 None => ScalarValue::try_from(arr.data_type()),
463 }
464 }
465 }
466
467 fn supports_bounded_execution(&self) -> bool {
468 true

Callers 1

test_i32_resultFunction · 0.45

Calls 3

valid_indexMethod · 0.80
cloneMethod · 0.45
data_typeMethod · 0.45

Tested by 1

test_i32_resultFunction · 0.36