Skip to main content

reduce_greatest_least

Function reduce_greatest_least 

Source
fn reduce_greatest_least(e: &mut MirScalarExpr, column_types: &[ReprColumnType])
Expand description

Simplifies a Greatest/Least call:

  1. Deduplicate structurally equal operands, keeping first occurrences. Scalar evaluation is deterministic (the And/Or and Coalesce reducers already rely on this when they deduplicate), so duplicates of an expression contribute the same value — over which greatest/least are idempotent — or the same error; keeping the first occurrence leaves unchanged which error surfaces.
  2. Drop literal null operands: both functions ignore null inputs (they return the max/min of the non-null inputs, and null only when every input is null).
  3. A call left with a single operand is the identity on it — the call evaluates the operand once and returns it, null or not — and a call left with none is null.