Class DisplayLabels
Relix has two tree views: the IR report (:tree), which shows the
logical RelNode tree, and the physical plan printer
(:explain), which shows the PhysicalNode plan. They are
deliberately different at the node level — only :explain
names a join algorithm, a build side, or a pushed-down native query — but the
structural detail inside a label is the same thing in both, and used
to be written out twice by hand. The copies drifted: the same window operator
printed WINDOW … SORT … PER … in one view and
Window … sort … per … in the other, and the same solver constraint
differed in spacing, separator, and even → versus ->.
These renderers are the shared answer, in the language's own spelling — uppercase keywords, glyph arrows, bracketed key lists — so that a construct reads identically wherever it is shown. They take node components rather than nodes, because the logical and physical hierarchies are separate sealed types that happen to embed the same parts.
Physical annotations are not this class's business: a caller appends its
own /HASH build=LEFT or streaming on top.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic Stringbound(double bound) Formats a solver constraint's numeric bound: a finite whole number renders without a fractional part, so100.0reads as100.static Stringoptimize(ObjectiveSense sense, Operand objective, List<OptimizeConstraint> constraints, List<String> groupingKeys, Optional<AllocationSpec> allocation) Renders a complete solver label, e.g.static StringproduceBound(ProduceBound produceBound) Renders a generator production bound ascolumn ≤ limit.static StringsortKey(SortSpecification spec) Renders a sort key asexpr↑(ascending) orexpr↓(descending).static Stringwindow(WindowFunction fn, WindowFrame frame, List<SortSpecification> sortSpecs, List<String> partitionKeys, String outputColumn) Renders a complete window operator label, e.g.static StringwindowFrame(WindowFrame frame) Renders a window frame as a leading-space suffix —" OVER 3 ROWS"," OVER ALL ROWS", or empty for a whole-partition frame.static StringRenders a window function call, e.g.
-
Method Details
-
bound
Formats a solver constraint's numeric bound: a finite whole number renders without a fractional part, so100.0reads as100.- Parameters:
bound- the constraint bound- Returns:
- the display text
-
sortKey
Renders a sort key asexpr↑(ascending) orexpr↓(descending).- Parameters:
spec- the sort specification; must not be null- Returns:
- the rendered sort key
-
produceBound
Renders a generator production bound ascolumn ≤ limit.- Parameters:
produceBound- the bound; must not be null- Returns:
- the rendered bound
-
windowFunction
Renders a window function call, e.g.SUM(amount),ROW_NUMBER(), orLAG(price, 1).- Parameters:
fn- the window function; must not be null- Returns:
- the rendered call
-
windowFrame
Renders a window frame as a leading-space suffix —" OVER 3 ROWS"," OVER ALL ROWS", or empty for a whole-partition frame.- Parameters:
frame- the frame; must not be null- Returns:
- the rendered frame, or an empty string
-
window
public static String window(WindowFunction fn, WindowFrame frame, List<SortSpecification> sortSpecs, List<String> partitionKeys, String outputColumn) Renders a complete window operator label, e.g.ROLLING SUM(amount) OVER 3 ROWS SORT ts↑ PER region AS running.The keyword is
ROLLINGfor an aggregate window andWINDOWfor a ranking or offset function, matching the surface syntax that produces each.- Parameters:
fn- the window function; must not be nullframe- the frame; must not be nullsortSpecs- the ordering within a partition; must not be nullpartitionKeys- the partition keys, possibly empty; must not be nulloutputColumn- the column the result is written to; must not be null- Returns:
- the rendered label
-
optimize
public static String optimize(ObjectiveSense sense, Operand objective, List<OptimizeConstraint> constraints, List<String> groupingKeys, Optional<AllocationSpec> allocation) Renders a complete solver label, e.g.OPTIMIZE max SUM(value) s.t. SUM(weight)≤100 [region].- Parameters:
sense- maximise or minimise; must not be nullobjective- the objective expression; must not be nullconstraints- the constraints, possibly empty; must not be nullgroupingKeys- the per-group keys, possibly empty; must not be nullallocation- the continuous-allocation spec, if any; must not be null- Returns:
- the rendered label
-