Skip to content

dbt: complex-expression fallback metric double-aggregates on round-trip #430

Description

@christianeu-db

Summary

On ossie-to-msi, an Ossie metric whose expression matches no recognized pattern is stored as a SIMPLE metric that applies agg=SUM to an expression that is itself already SUM(...). The emitted MSI therefore encodes a double aggregation, and a round-trip (Ossie->MSI->Ossie) renders it as SUM(SUM(CASE WHEN ...)): silently, with no ConverterIssue.

The README already documents that unrecognized expressions are "stored verbatim" as best-effort. That is fine on its own; the defect is that the verbatim expression is paired with agg=SUM without stripping its outer aggregate, unlike the recognized path.

Repro (real converters, HEAD 3c94d16 - EXECUTED)

Forward pass: recognized vs. fallback, same agg, different handling of the outer aggregate:

RECOGNIZED  SUM(orders.amount)                              -> expr='amount'                    agg=SUM
FALLBACK    SUM(CASE WHEN orders.status = 'paid'            -> expr='SUM(CASE WHEN ...           agg=SUM
            THEN amount ELSE 0 END)                                 THEN amount ELSE 0 END)'

Full round-trip of the fallback metric:

INPUT  Ossie expr:  SUM(CASE WHEN orders.status = 'paid' THEN amount ELSE 0 END)
MSI type_params.expr: SUM(CASE WHEN orders.status = 'paid' THEN amount ELSE 0 END)   (agg=SUM)
OUTPUT Ossie expr:  SUM(SUM(CASE WHEN orders.status = 'paid' THEN amount ELSE 0 END))
issues (both directions): []

No ConverterIssue is raised in either direction.

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