Skip to content

Define and test missing-group semantics for split ratio metrics #15

Description

@vara-bonthu

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:

  1. Add tests for groups present only in the numerator.
  2. Add tests for groups present only in the denominator.
  3. Define how the authoritative group universe is selected.
  4. Preserve groups using an appropriate anchor, LEFT JOIN, or FULL OUTER JOIN.
  5. Apply COALESCE only when the metric explicitly defines a missing value as zero.
  6. 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

  • Tests cover numerator-only groups.
  • Tests cover denominator-only groups.
  • Tests cover null dimension values.
  • Missing groups are not silently dropped unless the metric semantics require it.
  • Zero and unknown values are distinguished.
  • StarRocks and Trino produce equivalent results.
  • Existing fan-out-safe ratio behavior remains deterministic.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions