You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Grouped CASE over a frequency-L2 statistic is sized as absolute error; the ungrouped one as relative #739
Take two projections of a frequency-L2 statistic, both written as a CASE that guards the empty input:
Ungrouped: one output column, CASE WHEN n = 0 THEN NULL ELSE l2 END.
Grouped: the same CASE, plus the group key column src_ip beside it.
Today, default_metric_for_root (crates/types/src/types.rs, node_metric) assigns them different sizing metrics:
Query shape
node_metric
Sizing metric
ungrouped CASE over the L2 column
the one column's column_metric, i.e. the L2 measure's intent_metric
Relative
grouped: key column + CASE over the L2 column
the key column is ABSOLUTE and the CASE column is Relative; the metrics differ, so the result falls back to ABSOLUTE
Absolute
So the same statistic, with the same target, is sized as a relative error in one query and an absolute error in the other. The only difference is that the projection also carries the group key.
Expected: the group key is not a value the target talks about. The grouped query should take the metric of its value column(s) and get Relative too. Alternatively, a mixed result should be decided explicitly rather than by falling back to ABSOLUTE.
Cause
node_metric's general Project arm collects column_metric for every output column, keys included. It returns ABSOLUTE whenever they differ. The column-only Project arm and the Aggregate arm only look at measures.
Proposal (to decide)
Ignore group-key and label columns in the Project arm. Take the metric of the value columns, which are those that resolve to an aggregate measure.
Or keep the current behaviour and document that a key column beside a value forces an absolute sizing.
Option 1 changes the sizing metric of grouped queries of this shape, and so their sketch parameters. It needs a check of which examples or tests have that shape.
Scope / acceptance
A unit test of default_metric_for_root on the grouped and ungrouped shapes, asserting the chosen behaviour.
Examples 1–4: any change in selected plans or costs is listed and explained.
Status / related
Deferred by decision on 2026-10-16. Found in the #707 review and listed as row 67 of #737's nit table. Related: #690 / #718 (metric defaults used only for sizing and display).
Activity