{"record":{"id":"3f138ab72aa95bb0","repo":"cube-js/cube","slug":"querytimedimension-should-be-specified-for-the-com","errorCode":null,"errorMessage":"QueryTimeDimension should be specified for the compare date range query.","messagePattern":"QueryTimeDimension should be specified for the compare date range query\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"rust/cube/cubeorchestrator/src/query_result_transform.rs","lineNumber":231,"sourceCode":"                        Utc.from_utc_datetime(&dt)\n                            .format(\"%Y-%m-%dT%H:%M:%S%.3f\")\n                            .to_string()\n                    })\n                })\n                .unwrap_or_else(|_| s.clone());\n            DBResponsePrimitive::String(formatted)\n        }\n        other => other,\n    }\n}\n\n/// Parse date range value from time dimension.\npub fn get_date_range_value(\n    time_dimensions: Option<&Vec<QueryTimeDimension>>,\n) -> Result<DBResponsePrimitive> {\n    let time_dimensions = match time_dimensions {\n        Some(time_dimensions) => time_dimensions,\n        None => bail!(\"QueryTimeDimension should be specified for the compare date range query.\"),\n    };\n\n    let dim = match time_dimensions.first() {\n        Some(dim) => dim,\n        None => bail!(\"No time dimension provided.\"),\n    };\n\n    let date_range: &Vec<String> = match &dim.date_range {\n        Some(date_range) => date_range,\n        None => bail!(\"Inconsistent QueryTimeDimension configuration: dateRange required.\"),\n    };\n\n    if date_range.len() == 1 {\n        bail!(\n            \"Inconsistent dateRange configuration for the compare date range query: {}\",\n            date_range[0]\n        );\n    }","sourceCodeStart":213,"sourceCodeEnd":249,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/rust/cube/cubeorchestrator/src/query_result_transform.rs#L213-L249","documentation":"get_date_range_value extracts the date range from a query's time dimensions when building a compare-date-range query (period-over-period comparison). A compare query is meaningless without at least one QueryTimeDimension, so the function bails when the time_dimensions parameter is None. Callers include build_compact_plan, VanillaTail::CompareDateRange, and ColumnarColumnPlan in the Rust query orchestrator.","triggerScenarios":"Building a compact plan / columnar plan for a compareDateRange query where the query's time_dimensions field is absent (None) — e.g. a query with a compareDateRange flag but no time dimension defined.","commonSituations":"Client sends compareDateRange without any timeDimensions entry; a query transform drops time dimensions before the compare step; hand-constructed query JSON missing timeDimensions.","solutions":["Add a timeDimensions entry with a dateRange to the query when using compareDateRange","Verify the client SDK serializes timeDimensions for the compare query (not stripped by a transform)","Check the query JSON reaching the orchestrator — compareDateRange requires timeDimensions[0] with dateRange"],"exampleFix":"// before: compare without a time dimension\n{\"compareDateRange\": {\"compares\": [...]}}\n\n// after\n{\"timeDimensions\": [{\"dimension\": \"Events.timestamp\", \"dateRange\": [\"2024-01-01\", \"2024-01-31\"]}], \"compareDateRange\": {\"compares\": [...]}}","handlingStrategy":"validation","validationCode":"fn has_time_dimensions(q: &Query) -> bool {\n    q.time_dimensions.as_ref().map_or(false, |t| !t.is_empty())\n}\n// call before issuing a compareDateRange query\nassert!(has_time_dimensions(&query), \"compareDateRange requires timeDimensions\");","typeGuard":"fn has_time_dimensions(q: &Query) -> bool {\n    q.time_dimensions.as_ref().map_or(false, |t| !t.is_empty())\n}","tryCatchPattern":"match build_compact_plan(&query) {\n    Err(e) if e.to_string().contains(\"QueryTimeDimension should be specified\") => {\n        eprintln!(\"Add a timeDimensions entry with dateRange for compareDateRange queries\");\n    }\n    other => other?,\n}","preventionTips":["Always define timeDimensions with a dateRange when using compareDateRange","Validate query payloads client-side before sending","Check that query transforms do not strip timeDimensions"],"tags":["query-orchestrator","compare-date-range","missing-parameter","rust"],"backgroundTag":"missing-query-time-dimension","analyzedSha":"7d981676b36392fec34088b9afab6bdcad40207c","analyzedAt":"2026-09-02T03:45:10.400Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}