{"record":{"id":"54e2677145462b79","repo":"dbt-labs/dbt-core","slug":"new-style-cumulative-metric-should-compile-without","errorCode":null,"errorMessage":"new-style cumulative metric should compile without error","messagePattern":"new-style cumulative metric should compile without error","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/dbt-metricflow/src/lib.rs","lineNumber":11626,"sourceCode":"\n        let spec = SemanticQuerySpec {\n            metrics: vec![\"base_l7d\".into()],\n            group_by: vec![GroupBySpec::TimeDimension {\n                name: \"metric_time\".into(),\n                granularity: \"day\".into(),\n                date_part: None,\n            }],\n            where_filters: vec![],\n            order_by: vec![],\n            limit: None,\n            time_constraint: None,\n            apply_group_by: true,\n        };\n\n        // Pre-fix: fails with \"cumulative metric base_l7d has no aggregation params\".\n        // Post-fix: compiles and the SQL contains a rolling window condition.\n        let sql = compile(&mut store, &spec, Dialect::DuckDB)\n            .expect(\"new-style cumulative metric should compile without error\");\n\n        assert!(\n            sql.contains(\"INTERVAL\"),\n            \"rolling-window cumulative SQL must contain an INTERVAL for the 7-day window\\n  SQL:\\n{sql}\"\n        );\n    }\n}\n","sourceCodeStart":11608,"sourceCodeEnd":11634,"githubUrl":"https://github.com/dbt-labs/dbt-core/blob/0267ce9170576975b76b64ce856b2e5848e96617/crates/dbt-metricflow/src/lib.rs#L11608-L11634","documentation":"Test-only panic: a new-style cumulative metric (7-day rolling, `base_l7d`) failed to compile for DuckDB, panicking at `.expect(\"new-style cumulative metric should compile without error\")`. The comment notes the pre-fix failure was 'cumulative metric base_l7d has no aggregation params', so this guards against regressing cumulative metrics defined with the new syntax lacking proper aggregation parameter materialization.","triggerScenarios":"Compiling a cumulative metric spec where the compiler cannot derive aggregation params for the base window metric — the new-style cumulative definition's `window: 7 days` wasn't converted into rolling aggregation params, so `compile` returns Err (or the SQL lacks the INTERVAL rolling condition).","commonSituations":"Mixing old/new cumulative syntax; metric defined without `type_params.window`/`gravity` handled; compiler refactor dropping the rolling-window conversion for cumulative base metrics.","solutions":["Ensure the cumulative metric has valid window/aggregation type params (e.g. measure + window: 7 days)","Check the compiler path that materializes cumulative base_l7d rolling window params","Verify generated SQL contains the INTERVAL rolling condition for the 7-day window","Update the regression fix referenced in the test comment"],"exampleFix":"null","handlingStrategy":"try-catch","validationCode":"// check cumulative metric has aggregation params before compile\nassert!(!metric.type_params.measures.is_empty() || metric.type_params.window.is_some(),\n        \"cumulative metric needs measures and window\");","typeGuard":null,"tryCatchPattern":"let sql = compile(&mut store, &spec, Dialect::DuckDB)\n    .unwrap_or_else(|e| panic!(\"cumulative compile failed: {e:?}\"));","preventionTips":["Use the new cumulative syntax consistently (avoid mixing old/new forms)","Always specify window/gravity for rolling cumulative metrics","Keep the rolling-window -> aggregation params conversion covered by tests"],"tags":["tests","metricflow","compilation","cumulative-metrics"],"backgroundTag":"sql-query-failed","analyzedSha":"0267ce9170576975b76b64ce856b2e5848e96617","analyzedAt":"2026-09-07T21:53:39.732Z","contentChangedAt":"2026-09-07T21:53:39.732Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}