Interface LazyScalarFunction

All Superinterfaces:
ScalarFunction

public non-sealed interface LazyScalarFunction extends ScalarFunction
A scalar function that decides which of its arguments to evaluate — a special form.

Arguments arrive as deferred Arguments; one whose Argument.value() is never called is never evaluated. That is what separates a conditional from an ordinary three-argument function: in

IIf(IsNumeric(raw), CDbl(raw), 0)
the CDbl(raw) branch would fail on a row where raw is not numeric, and on those rows it is not evaluated at all. A short-circuiting Coalesce stops at its first non-NULL argument for the same reason.

Choose this only when skipping an argument is part of the function's meaning. A function that always reads every argument gains nothing and pays a call through the deferred wrapper for each one.

  • Method Details

    • invoke

      Value invoke(FunctionContext context, List<Argument> arguments)
      Computes the result for one row, evaluating only the arguments it needs.
      Parameters:
      context - the ambient state this call may read
      arguments - the deferred arguments, in call order; never null and of a length the declared arity accepts
      Returns:
      the result value; never null