Skip to main content

Module case_when

Module case_when 

Source
Expand description

SQL-style CASE WHEN: evaluates (condition, value) pairs in order and returns the value from the first matching condition (first-match-wins). NULL conditions are treated as false. If no ELSE clause is provided, unmatched rows produce NULL; otherwise they get the ELSE value.

Unlike SQL which coerces all branches to a common supertype, all THEN/ELSE branches must share the same base dtype (ignoring nullability). The result nullability is the union of all branches (forced nullable if no ELSE).

Structsยง

CaseWhen
An n-ary CASE WHEN expression.
CaseWhenOptions
Options for the n-ary CaseWhen expression.