Skip to main content

when

Function when 

Source
pub fn when(condition: &Column) -> WhenBuilder
Expand description

PySpark-style conditional expression builder.

ยงExample

use robin_sparkless_expr::functions::{col, lit_i64, lit_str, when};

// when(condition).then(value).otherwise(fallback)
let expr = when(&col("age").gt(lit_i64(18).into_expr()))
    .then(&lit_str("adult"))
    .otherwise(&lit_str("minor"));