evaluate_first_value

Function evaluate_first_value 

Source
pub fn evaluate_first_value<F>(
    partition: &Partition,
    value_expr: &Expression,
    eval_fn: F,
) -> Result<SqlValue, String>
where F: Fn(&Expression, &Row) -> Result<SqlValue, String>,
Expand description

Evaluate FIRST_VALUE() value window function

Returns the value of the expression evaluated on the first row of the partition. Useful for getting the initial value in an ordered partition.

Signature: FIRST_VALUE(expr)

  • expr: Expression to evaluate on the first row

Example: FIRST_VALUE(price) OVER (PARTITION BY product ORDER BY date) Example: FIRST_VALUE(salary) OVER (PARTITION BY department ORDER BY hire_date)

Note: Typically used with ORDER BY to get the “earliest” value according to ordering.