dbt-labs/dbt-core · error
new-style cumulative metric should compile without error
Error message
new-style cumulative metric should compile without error
What it means
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.
Source
Thrown at crates/dbt-metricflow/src/lib.rs:11626
let spec = SemanticQuerySpec {
metrics: vec!["base_l7d".into()],
group_by: vec![GroupBySpec::TimeDimension {
name: "metric_time".into(),
granularity: "day".into(),
date_part: None,
}],
where_filters: vec![],
order_by: vec![],
limit: None,
time_constraint: None,
apply_group_by: true,
};
// Pre-fix: fails with "cumulative metric base_l7d has no aggregation params".
// Post-fix: compiles and the SQL contains a rolling window condition.
let sql = compile(&mut store, &spec, Dialect::DuckDB)
.expect("new-style cumulative metric should compile without error");
assert!(
sql.contains("INTERVAL"),
"rolling-window cumulative SQL must contain an INTERVAL for the 7-day window\n SQL:\n{sql}"
);
}
}
View on GitHub (pinned to 0267ce9170)
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
Example fix
null
Defensive patterns
Strategy: try-catch
Validate before calling
// check cumulative metric has aggregation params before compile
assert!(!metric.type_params.measures.is_empty() || metric.type_params.window.is_some(),
"cumulative metric needs measures and window"); Try / catch
let sql = compile(&mut store, &spec, Dialect::DuckDB)
.unwrap_or_else(|e| panic!("cumulative compile failed: {e:?}")); Prevention
- 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
When it happens
Trigger: 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).
Common situations: Mixing old/new cumulative syntax; metric defined without `type_params.window`/`gravity` handled; compiler refactor dropping the rolling-window conversion for cumulative base metrics.
Understand the failure class
Background: "query failed", "%w: SQL error" — wrapped database query errors in Go libraries explained — this error's family across 3 libraries.
Related errors
- yoy_growth should compile without error
- events_last_year should compile without error
- Compilation Error for {} from {}: {}
- configure
- Failed to create temp file
AI-assisted analysis of dbt-labs/dbt-core@0267ce9170 (2026-09-07).
Data as JSON: /api/errors/54e2677145462b79.
Report an issue: GitHub.