{"record":{"id":"8506dde2b83098ff","repo":"dbt-labs/dbt-core","slug":"yoy-growth-should-compile-without-error","errorCode":null,"errorMessage":"yoy_growth should compile without error","messagePattern":"yoy_growth should compile without error","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/dbt-metricflow/src/lib.rs","lineNumber":11212,"sourceCode":"            }],\n        ));\n\n        let spec = SemanticQuerySpec {\n            metrics: vec![\"yoy_growth\".into()],\n            group_by: vec![GroupBySpec::TimeDimension {\n                name: \"metric_time\".into(),\n                granularity: \"month\".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        let sql = compile(&mut store, &spec, Dialect::DuckDB)\n            .expect(\"yoy_growth should compile without error\");\n\n        let cte_defs = sql.matches(\"base_last_year AS (\").count();\n        assert_eq!(\n            cte_defs, 1,\n            \"CTE 'base_last_year' must be defined exactly once\\n  SQL:\\n{sql}\"\n        );\n    }\n\n    #[test]\n    fn test_offset_window_object_format_is_applied() {\n        let mut store = MockStore::new();\n\n        store.metrics.push(RawMetricRow {\n            name: \"events\".into(),\n            metric_type: \"simple\".into(),\n            description: String::new(),\n            type_params: r#\"{\n                \"metric_aggregation_params\": {","sourceCodeStart":11194,"sourceCodeEnd":11230,"githubUrl":"https://github.com/dbt-labs/dbt-core/blob/0267ce9170576975b76b64ce856b2e5848e96617/crates/dbt-metricflow/src/lib.rs#L11194-L11230","documentation":"A test-only panic in dbt-metricflow's test-suite: `compile(&mut store, &spec, Dialect::DuckDB)` failed to compile a year-over-year growth metric spec, so `.expect(\"yoy_growth should compile without error\")` panics. It indicates the semantic layer compiler rejected a metric the test considers valid — a regression in cumulative/growth metric compilation.","triggerScenarios":"Building a `MetricInput`-driven query spec with `apply_group_by: true` against a metric store where the yoy_growth metric's calc/offset parameters are missing or misparsed, so the DuckDB compile returns Err.","commonSituations":"Changes to cumulative/derived metric aggregation-param handling breaking time-offset metrics; DuckDB-specific SQL generation regressions; metric definitions missing `time_offset`/growth params.","solutions":["Inspect the Err from `compile` (it names the missing aggregation params or spec field)","Verify the metric spec includes the required time-offset/growth parameters","Update or revert the metricflow change that altered cumulative metric base construction","Re-run the test after fixing the compiler to confirm CTE base_last_year appears exactly once"],"exampleFix":"// before\nlet sql = compile(&mut store, &spec, Dialect::DuckDB).expect(\"yoy_growth should compile without error\");\n// after\nlet sql = compile(&mut store, &spec, Dialect::DuckDB).unwrap_or_else(|e| panic!(\"yoy_growth compile failed: {e:?}\"));","handlingStrategy":"try-catch","validationCode":"// validate spec before compiling\nassert!(spec.metric.is_some(), \"spec must reference a metric\");\nassert!(spec.apply_group_by, \"group_by must be applied for growth metrics\");","typeGuard":null,"tryCatchPattern":"let sql = compile(&mut store, &spec, Dialect::DuckDB)\n    .unwrap_or_else(|e| panic!(\"yoy_growth compile failed: {e:?}\"));","preventionTips":["Define time-offset growth metrics with explicit offset parameters","Keep metric definitions tied to a valid time spine/dimension","Run the metricflow test suite after compiler changes"],"tags":["tests","metricflow","compilation","sql"],"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-14T16:17:12.679Z"}