Skip to main content

Module case_literal

Module case_literal 

Source
Expand description

A lookup-based evaluation of CASE expr WHEN lit1 THEN res1 ... ELSE els END.

CaseLiteral replaces chains of If(Eq(expr, literal), result, If(...)) with a single BTreeMap lookup, turning O(n) evaluation into O(log n).

Represented as a CallVariadic { func: CaseLiteral { lookup, return_type }, exprs } where:

  • exprs[0] = input expression (the x in CASE x WHEN ...)
  • exprs[1..n] = case result expressions
  • exprs[last] = els (fallback)
  • lookup: BTreeMap<Row, usize> maps literal values to indices in exprs

Structsยง

CaseLiteral
Evaluates a CASE expression by looking up the input datum in a BTreeMap.