Skip to content

Commit bddbec3

Browse files
committed
Fix join key doesn't respect root
1 parent 4e198a8 commit bddbec3

File tree

3 files changed

+21
-6
lines changed

3 files changed

+21
-6
lines changed

rust/cubesqlplanner/cubesqlplanner/src/planner/base_measure.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use crate::cube_bridge::measure_definition::{
77
use cubenativeutils::CubeError;
88
use lazy_static::lazy_static;
99
use regex::Regex;
10+
use std::fmt::{Debug, Formatter};
1011
use std::rc::Rc;
1112

1213
#[derive(Clone, Debug)]
@@ -71,6 +72,15 @@ pub struct BaseMeasure {
7172
name: String,
7273
}
7374

75+
impl Debug for BaseMeasure {
76+
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
77+
f.debug_struct("BaseMeasure")
78+
.field("measure", &self.measure)
79+
.field("time_shifts", &self.time_shifts)
80+
.finish()
81+
}
82+
}
83+
7484
impl BaseMember for BaseMeasure {
7585
fn to_sql(&self, context: Rc<VisitorContext>) -> Result<String, CubeError> {
7686
evaluate_with_context(&self.member_evaluator, self.query_tools.clone(), context)

rust/cubesqlplanner/cubesqlplanner/src/planner/query_properties.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ impl OrderByItem {
3232
}
3333
}
3434

35-
#[derive(Default, Clone)]
35+
#[derive(Default, Clone, Debug)]
3636
pub struct FullKeyAggregateMeasures {
3737
pub multiplied_measures: Vec<Rc<BaseMeasure>>,
3838
pub regular_measures: Vec<Rc<BaseMeasure>>,

rust/cubesqlplanner/cubesqlplanner/src/planner/query_tools.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,11 @@ pub struct QueryToolsCachedData {
2424
join_key_to_join: HashMap<Rc<JoinKey>, Rc<dyn JoinDefinition>>,
2525
}
2626

27-
#[derive(Hash, PartialEq, Eq)]
28-
pub struct JoinKey(Vec<JoinItemStatic>);
27+
#[derive(Debug, Hash, PartialEq, Eq)]
28+
pub struct JoinKey {
29+
root: String,
30+
joins: Vec<JoinItemStatic>,
31+
}
2932

3033
impl QueryToolsCachedData {
3134
pub fn new() -> Self {
@@ -96,13 +99,15 @@ impl QueryToolsCachedData {
9699
.flat_map(|h| h.as_ref().iter().cloned())
97100
.collect(),
98101
)?;
99-
let join_key = Rc::new(JoinKey(
100-
join.joins()?
102+
let join_key = Rc::new(JoinKey {
103+
root: join.static_data().root.to_string(),
104+
joins: join
105+
.joins()?
101106
.items()
102107
.iter()
103108
.map(|i| i.static_data().clone())
104109
.collect(),
105-
));
110+
});
106111
self.join_hints_to_join_key.insert(hints, join_key.clone());
107112
self.join_key_to_join.insert(join_key.clone(), join.clone());
108113
Ok((join_key, join))

0 commit comments

Comments
 (0)