cube-js/cube · error
No time dimension provided.
Error message
No time dimension provided.
What it means
get_date_range_value requires at least one QueryTimeDimension to extract a date range for compare-date-range queries. When the provided vector is present but empty (no first element), this error is raised — distinct from 678, where the whole parameter was None. The compare logic reads time_dimensions.first() and needs a concrete dimension to pull dateRange from.
Source
Thrown at rust/cube/cubeorchestrator/src/query_result_transform.rs:236
.unwrap_or_else(|_| s.clone());
DBResponsePrimitive::String(formatted)
}
other => other,
}
}
/// Parse date range value from time dimension.
pub fn get_date_range_value(
time_dimensions: Option<&Vec<QueryTimeDimension>>,
) -> Result<DBResponsePrimitive> {
let time_dimensions = match time_dimensions {
Some(time_dimensions) => time_dimensions,
None => bail!("QueryTimeDimension should be specified for the compare date range query."),
};
let dim = match time_dimensions.first() {
Some(dim) => dim,
None => bail!("No time dimension provided."),
};
let date_range: &Vec<String> = match &dim.date_range {
Some(date_range) => date_range,
None => bail!("Inconsistent QueryTimeDimension configuration: dateRange required."),
};
if date_range.len() == 1 {
bail!(
"Inconsistent dateRange configuration for the compare date range query: {}",
date_range[0]
);
}
Ok(DBResponsePrimitive::String(
date_range.join(COMPARE_DATE_RANGE_SEPARATOR),
))
}View on GitHub (pinned to 7d981676b3)
Solutions
- Include at least one timeDimensions entry with dimension and dateRange when using compareDateRange
- If no time dimension applies, remove the compareDateRange option from the query
- Check client-side transforms/filters that may empty the timeDimensions array
Example fix
// before: empty time dimensions
{"timeDimensions": [], "compareDateRange": {"compares": [...]}}
// after
{"timeDimensions": [{"dimension": "Orders.createdAt", "dateRange": ["2024-01-01", "2024-03-31"]}], "compareDateRange": {"compares": [...]}} Defensive patterns
Strategy: validation
Validate before calling
fn has_time_dimensions(q: &Query) -> bool {
q.time_dimensions.as_ref().map_or(false, |t| !t.is_empty())
}
// empty arrays must also be rejected, not just None
assert!(has_time_dimensions(&query), "timeDimensions must contain at least one entry"); Type guard
fn first_time_dimension(q: &Query) -> Option<&QueryTimeDimension> {
q.time_dimensions.as_ref().and_then(|t| t.first())
} Try / catch
match get_date_range_value(query.time_dimensions.as_ref()) {
Err(e) if e.to_string().contains("No time dimension provided") => {
eprintln!("timeDimensions was empty — supply a dimension with dateRange");
}
other => other?,
} Prevention
- Omit compareDateRange rather than sending an empty timeDimensions array
- Guard client code that filters time dimensions so it cannot reduce the list to zero while compare is enabled
- Validate that serialized queries keep at least one timeDimensions entry for compare queries
When it happens
Trigger: Passing Some(vec![]) (an empty timeDimensions array) to get_date_range_value — e.g. a compareDateRange query whose timeDimensions list serializes as empty, exercised by test_get_date_range_value_empty_time_dimensions.
Common situations: Client filters time dimensions down to nothing before sending; SDK emits an empty array instead of omitting the field; generated queries where the user unset all time dimensions but left compareDateRange enabled.
Related errors
- QueryTimeDimension should be specified for the compare date
- compareDateRange drillDown query is not currently supported
- Method is not supported for a '${this.queryType}' query type
- externalDriverFactory is not provided. Please use CUBEJS_DEV
- Pre-aggregation tables are undefined.
AI-assisted analysis of cube-js/cube@7d981676b3 (2026-09-02).
Data as JSON: /api/errors/36cc1a325e6195f0.
Report an issue: GitHub.