Latu.CaseWhen (latu v0.1.1)

Copy Markdown View Source

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.

Summary

Types

t()

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

Functions

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

Types

t()

@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.

Functions

arguments(case_when)

@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.