Package dev.frostlake.executor
Class SiblingAliasSubstitution
java.lang.Object
dev.frostlake.executor.SiblingAliasSubstitution
An expression with every SIBLING SELECT ALIAS it mentions replaced by that alias's defining
expression. A select list may name its own output —
SELECT d AS dd, MEDIAN(dd) — and a name
used that way means the expression behind it, wherever in the expression it appears rather than only
when it IS the whole expression.
The substitution repeats, because an alias may be defined in terms of another
(SELECT d AS dd, dd AS ee, … ee …), and stops as soon as a pass changes nothing. It is
bounded at five passes: that is enough for any chain worth writing, and it means a definition that
mentions its own name cannot spin here.
The replacement is by IDENTIFIER TOKEN, so a name inside a string literal or forming part of a longer identifier is left alone. Whether an alias should be substituted at all is the CALLER's decision — a real column of the same name outranks the alias, and only the caller knows the relations in scope.
-
Method Summary
-
Method Details
-
applied
- Parameters:
text- the expression textnames- the alias names, canonicalexprs- their defining expressions, 1:1 withnames- Returns:
- the text with those aliases expanded
-