{"record":{"id":"b73fbee3c5759051","repo":"dbt-labs/dbt-core","slug":"events-last-year-should-compile-without-error","errorCode":null,"errorMessage":"events_last_year should compile without error","messagePattern":"events_last_year should compile without error","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/dbt-metricflow/src/lib.rs","lineNumber":11294,"sourceCode":"            }],\n        ));\n\n        let spec = SemanticQuerySpec {\n            metrics: vec![\"events_last_year\".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(\"events_last_year should compile without error\");\n\n        assert!(\n            sql.contains(\"INTERVAL\"),\n            \"SQL must contain an INTERVAL expression for the 1-year offset\\n  SQL:\\n{sql}\"\n        );\n        assert!(\n            sql.contains(\"INNER JOIN\"),\n            \"offset CTE must use an INNER JOIN to apply the time shift\\n  SQL:\\n{sql}\"\n        );\n    }\n\n    #[test]\n    fn test_filter_on_outer_derived_metric_propagates_to_inputs() {\n        let mut store = MockStore::new();\n\n        store.metrics.push(RawMetricRow {\n            name: \"count_nps\".into(),\n            metric_type: \"simple\".into(),","sourceCodeStart":11276,"sourceCodeEnd":11312,"githubUrl":"https://github.com/dbt-labs/dbt-core/blob/0267ce9170576975b76b64ce856b2e5848e96617/crates/dbt-metricflow/src/lib.rs#L11276-L11312","documentation":"Test-only panic: compiling an `events_last_year` time-offset metric spec for DuckDB failed, tripping `.expect(\"events_last_year should compile without error\")`. The test additionally requires the generated SQL to contain an INTERVAL expression, so this specific case guards 1-year offset SQL generation.","triggerScenarios":"`compile` returns Err for the events_last_year spec (missing metric aggregation params, unsupported time offset, or grain/time-spine issues), or the compiled SQL lacks INTERVAL which a later assert catches.","commonSituations":"Regressions in time-offset metric compilation; DuckDB dialect losing INTERVAL rendering for year offsets; metric store missing required time dimension or time spine config.","solutions":["Read the underlying compile Err / assert message for the missing piece","Ensure the metric has a valid primary time dimension and the offset (1 year) is supported","Check the DuckDB SQL renderer for INTERVAL emission on time offsets","Update the compiler change that regressed offset metric SQL"],"exampleFix":"null","handlingStrategy":"try-catch","validationCode":"// ensure required time params before compile\nassert!(spec.metric.is_some(), \"spec must target events_last_year metric\");\nassert!(spec.apply_group_by, \"group_by required for offset metrics\");","typeGuard":null,"tryCatchPattern":"let sql = compile(&mut store, &spec, Dialect::DuckDB)\n    .unwrap_or_else(|e| panic!(\"events_last_year compile failed: {e:?}\"));","preventionTips":["Provide a primary time dimension for offset metrics","Verify DuckDB dialect renders INTERVAL for year offsets","Add assert coverage for offset SQL after refactors"],"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"}