# `Latu.CaseWhen`
[🔗](https://github.com/zero-one-group/latu/blob/v0.4.0/lib/latu/case_when.ex#L1)

A `CASE WHEN` chain, waiting for `otherwise/2`.

Spark has no case-when node. The wire carries a single `when` function call whose arguments
are the branches in order — condition, value, condition, value — followed by the else value if
there is one; the `case_when` fixture is the proof. So the chain is a client-side fiction, the
same way `group_by` is (`Latu.GroupedData`), and this struct is where Latu keeps it. Inert
data, coerced by `Latu.Plan.to_expr/1` wherever an expression is accepted.

Build it through `Latu.Functions.when_/2` rather than here.

With no `otherwise/2` the else branch is `NULL`, as in SQL and PySpark. `otherwise(nil)` is
different: it sends an explicit NULL literal.

# `t`

```elixir
@type t() :: %Latu.CaseWhen{
  branches: [{term(), term()}],
  otherwise: :none | {:value, term()}
}
```

`otherwise` is `:none` until set, so an absent else differs from an explicit NULL.

# `arguments`

```elixir
@spec arguments(t()) :: [term()]
```

The arguments of the one `when` call this chain becomes, in wire order.

`Latu.Plan.to_expr/1` coerces each one; nothing here touches a proto.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
