Problem
Fan-out-safe ratio metrics are calculated using separate numerator and denominator CTEs. The planner currently combines those CTEs with INNER JOIN.
A group that appears on only one side can therefore disappear from the final result.
For example, an account may have licensed seats in the denominator but no usage records in the numerator. The account may be omitted instead of returning zero, null, or another explicitly defined result.
The correct behavior depends on the certified metric. Missing activity may mean zero, unknown, or outside the metric population. The planner should not make that decision implicitly.
Proposed solution
Define explicit missing-group semantics for split ratio metrics.
The implementation should:
- Add tests for groups present only in the numerator.
- Add tests for groups present only in the denominator.
- Define how the authoritative group universe is selected.
- Preserve groups using an appropriate anchor,
LEFT JOIN, or FULL OUTER JOIN.
- Apply
COALESCE only when the metric explicitly defines a missing value as zero.
- Document the behavior for zero denominators and missing groups.
Do not replace every join with a full outer join without first defining the intended metric semantics.
Implementation areas
internal/planner/plan_sql.go
internal/planner/plan_test.go
internal/planner/plan_trino_test.go
- Planner documentation
Acceptance criteria
Problem
Fan-out-safe ratio metrics are calculated using separate numerator and denominator CTEs. The planner currently combines those CTEs with
INNER JOIN.A group that appears on only one side can therefore disappear from the final result.
For example, an account may have licensed seats in the denominator but no usage records in the numerator. The account may be omitted instead of returning zero, null, or another explicitly defined result.
The correct behavior depends on the certified metric. Missing activity may mean zero, unknown, or outside the metric population. The planner should not make that decision implicitly.
Proposed solution
Define explicit missing-group semantics for split ratio metrics.
The implementation should:
LEFT JOIN, orFULL OUTER JOIN.COALESCEonly when the metric explicitly defines a missing value as zero.Do not replace every join with a full outer join without first defining the intended metric semantics.
Implementation areas
internal/planner/plan_sql.gointernal/planner/plan_test.gointernal/planner/plan_trino_test.goAcceptance criteria