Interface ScalarFunction
- All Known Subinterfaces:
LazyScalarFunction,StrictScalarFunction
The hierarchy is sealed over exactly two ways of receiving arguments, so the engine dispatches on a switch the compiler can check for completeness:
StrictScalarFunction— every argument is evaluated before the call. This is what a function wants unless it has a reason not to.LazyScalarFunction— arguments arrive as deferredArguments, and one that is never asked for is never evaluated. This is what makes a conditional usable as a guard: the branch not taken may be an expression that would fail on this row.
Both are non-sealed, so implementing either is open to any library; it
is the choice between them that is closed.
The engine checks the declared Arity before invoking, so an
implementation may read the arguments its signature allows without counting them
first.
-
Method Summary
Modifier and TypeMethodDescriptiondefault Stringname()default PushdownSpellingpushdown()How this function is spelled in a backend that could evaluate it itself.default ScalarTypereturnTypeFor(List<ScalarType> argumentTypes) The result type of a call with these argument types.The form of this function — name, parameters, arity, return type, properties.
-
Method Details
-
signature
FunctionSignature signature()The form of this function — name, parameters, arity, return type, properties.- Returns:
- the signature; never
null
-
name
- Returns:
- the canonical spelling of this function's name
-
returnTypeFor
The result type of a call with these argument types.Defaults to the declared return type, which is the answer whenever the result type is fixed. Override it for a function whose result follows its arguments — a conditional returning whichever branch it selects, a
Coalesceover a homogeneous list — and the engine's schema inference uses the narrower type.- Parameters:
argumentTypes- the argument types at the call site, in order- Returns:
- the result type of that call
-
pushdown
How this function is spelled in a backend that could evaluate it itself.Defaults to
PushdownSpelling.NONE— no backend spelling, so the engine evaluates every call. Supplying one is how a library's own function folds into a pushed query alongside the built-ins.- Returns:
- the pushdown spelling; never
null
-