Interface PushdownSpelling
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
The engine keeps everything structural — walking the expression tree, resolving column references, quoting identifiers — and hands over the arguments already rendered as text. A spelling therefore does nothing but assemble a string:
(target, args) -> target.isFamily(PushdownTarget.SQL)
? Optional.of("upper(" + args.get(0) + ")")
: Optional.empty();
Returning empty declines, and declining is always safe: the engine evaluates the call itself instead. A spelling that cannot be written for one backend, or for one argument count, says so by returning empty for that case rather than emitting text the backend would misread.
The rendered arguments are already in the target's syntax, so a MongoDB spelling
composes JSON fragments and a SQL one composes SQL. A function whose spelling differs
per dialect branches on PushdownTarget.variant().
Conditions
An argument is normally a value. A spelling that writes one as a condition instead — the test of aCASE WHEN — says so through
isCondition(int, int), because the two are different syntax in SQL: a comparison is
a condition everywhere, and a value only where the backend has a boolean type. The
engine renders a condition argument as a predicate, and declines the whole call when
the argument is not one it can render as a predicate.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final PushdownSpellingA spelling that declines every backend — the default for a function with none. -
Method Summary
Modifier and TypeMethodDescriptiondefault booleanisCondition(int position, int arity) Whether this spelling writes the argument atpositionas a condition rather than a value — see Conditions above.render(PushdownTarget target, List<String> renderedArguments) Renders a call for one backend.
-
Field Details
-
NONE
A spelling that declines every backend — the default for a function with none.
-
-
Method Details
-
render
Renders a call for one backend.- Parameters:
target- the backend being rendered forrenderedArguments- the call's arguments, already rendered in that backend's syntax, in call order- Returns:
- the rendered call, or empty to decline — in which case the engine evaluates the call itself
-
isCondition
default boolean isCondition(int position, int arity) Whether this spelling writes the argument atpositionas a condition rather than a value — see Conditions above.No argument is a condition unless a spelling says so.
- Parameters:
position- the argument's zero-based position in the callarity- the call's argument count, since which positions are conditions can depend on it- Returns:
- whether that argument is rendered as a predicate
-