diff --git a/rust/cubeorchestrator/Cargo.lock b/rust/cubeorchestrator/Cargo.lock index 35a40dd365fed..736239ae6a952 100644 --- a/rust/cubeorchestrator/Cargo.lock +++ b/rust/cubeorchestrator/Cargo.lock @@ -111,6 +111,7 @@ dependencies = [ "anyhow", "chrono", "cubeshared", + "indexmap", "itertools", "neon", "serde", @@ -130,6 +131,12 @@ version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" +[[package]] +name = "equivalent" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" + [[package]] name = "flatbuffers" version = "23.5.26" @@ -146,6 +153,12 @@ version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f0a01e0497841a3b2db4f8afa483cce65f7e96a3498bd6c541734792aeac8fe7" +[[package]] +name = "hashbrown" +version = "0.15.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1" + [[package]] name = "iana-time-zone" version = "0.1.61" @@ -169,6 +182,17 @@ dependencies = [ "cc", ] +[[package]] +name = "indexmap" +version = "2.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "206a8042aec68fa4a62e8d3f7aa4ceb508177d9324faf261e1959e495b7a1921" +dependencies = [ + "equivalent", + "hashbrown", + "serde", +] + [[package]] name = "itertools" version = "0.13.0" diff --git a/rust/cubesqlplanner/cubesqlplanner/src/logical_plan/optimizers/pre_aggregation/dimension_matcher.rs b/rust/cubesqlplanner/cubesqlplanner/src/logical_plan/optimizers/pre_aggregation/dimension_matcher.rs index ee533be3e93c7..4e41ca335c43b 100644 --- a/rust/cubesqlplanner/cubesqlplanner/src/logical_plan/optimizers/pre_aggregation/dimension_matcher.rs +++ b/rust/cubesqlplanner/cubesqlplanner/src/logical_plan/optimizers/pre_aggregation/dimension_matcher.rs @@ -185,7 +185,11 @@ impl<'a> DimensionMatcher<'a> { add_to_matched_dimension: bool, ) -> Result { let granularity = if self.pre_aggregation.allow_non_strict_date_range_match { - time_dimension.granularity().clone() + if let Some(granularity) = time_dimension.granularity_obj() { + granularity.min_granularity()? + } else { + time_dimension.granularity().clone() + } } else { time_dimension.rollup_granularity(self.query_tools.clone())? }; diff --git a/rust/cubesqlplanner/cubesqlplanner/src/planner/time_dimension/granularity_helper.rs b/rust/cubesqlplanner/cubesqlplanner/src/planner/time_dimension/granularity_helper.rs index 10bd055b21741..79032f1a02013 100644 --- a/rust/cubesqlplanner/cubesqlplanner/src/planner/time_dimension/granularity_helper.rs +++ b/rust/cubesqlplanner/cubesqlplanner/src/planner/time_dimension/granularity_helper.rs @@ -80,16 +80,22 @@ impl GranularityHelper { pub fn granularity_from_interval(interval: &Option) -> Option { if let Some(interval) = interval { - if interval.contains("day") { + if interval.contains("second") { + Some("second".to_string()) + } else if interval.contains("minute") { + Some("minute".to_string()) + } else if interval.contains("hour") { + Some("hour".to_string()) + } else if interval.contains("day") { + Some("day".to_string()) + } else if interval.contains("week") { Some("day".to_string()) } else if interval.contains("month") { Some("month".to_string()) + } else if interval.contains("quarter") { + Some("month".to_string()) } else if interval.contains("year") { Some("year".to_string()) - } else if interval.contains("week") { - Some("week".to_string()) - } else if interval.contains("hour") { - Some("hour".to_string()) } else { None }