Skip to content

Commit 76dc8f6

Browse files
committed
in work
1 parent 9e24128 commit 76dc8f6

File tree

4 files changed

+38
-40
lines changed

4 files changed

+38
-40
lines changed

rust/cubesqlplanner/cubesqlplanner/src/physical_plan_builder/processors/query.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ pub struct QueryProcessor<'a> {
1313

1414
impl QueryProcessor<'_> {
1515
fn is_over_full_aggregated_source(&self, logical_plan: &Query) -> bool {
16-
match logical_plan.source {
16+
match logical_plan.source() {
1717
QuerySource::FullKeyAggregate(_) => true,
1818
QuerySource::PreAggregation(_) => false,
1919
QuerySource::LogicalJoin(_) => false,
@@ -38,7 +38,7 @@ impl<'a> LogicalNodeProcessor<'a, Query> for QueryProcessor<'a> {
3838
let mut context = context.clone();
3939
let mut ctes = vec![];
4040

41-
for multi_stage_member in logical_plan.multistage_members.iter() {
41+
for multi_stage_member in logical_plan.multistage_members().iter() {
4242
let query = self
4343
.builder
4444
.process_node(&multi_stage_member.member_type, &context)?;
@@ -47,7 +47,7 @@ impl<'a> LogicalNodeProcessor<'a, Query> for QueryProcessor<'a> {
4747
ctes.push(Rc::new(Cte::new(Rc::new(query), alias)));
4848
}
4949

50-
let (from, is_pre_aggregation) = match &logical_plan.source {
50+
let (from, is_pre_aggregation) = match logical_plan.source() {
5151
QuerySource::LogicalJoin(join) => {
5252
let from = self.builder.process_node(join.as_ref(), &context)?;
5353
let references_builder = ReferencesBuilder::new(from.clone());
@@ -68,7 +68,7 @@ impl<'a> LogicalNodeProcessor<'a, Query> for QueryProcessor<'a> {
6868
let res = self
6969
.builder
7070
.process_node(pre_aggregation.as_ref(), &context)?;
71-
for member in logical_plan.schema.time_dimensions.iter() {
71+
for member in logical_plan.schema().time_dimensions.iter() {
7272
context_factory.add_dimensions_with_ignored_timezone(member.full_name());
7373
}
7474
context_factory.set_use_local_tz_in_date_range(true);
@@ -86,12 +86,12 @@ impl<'a> LogicalNodeProcessor<'a, Query> for QueryProcessor<'a> {
8686

8787
let mut select_builder = SelectBuilder::new(from);
8888
select_builder.set_ctes(ctes);
89-
context_factory.set_ungrouped(logical_plan.modifers.ungrouped);
89+
context_factory.set_ungrouped(logical_plan.modifers().ungrouped);
9090

91-
let filter = logical_plan.filter.all_filters();
92-
let having = logical_plan.filter.measures_filter();
91+
let filter = logical_plan.filter().all_filters();
92+
let having = logical_plan.filter().measures_filter();
9393

94-
for member in logical_plan.schema.all_dimensions() {
94+
for member in logical_plan.schema().all_dimensions() {
9595
references_builder.resolve_references_for_member(
9696
member.clone(),
9797
&None,
@@ -108,7 +108,7 @@ impl<'a> LogicalNodeProcessor<'a, Query> for QueryProcessor<'a> {
108108

109109
for (measure, exists) in self
110110
.builder
111-
.measures_for_query(&logical_plan.schema.measures, &context)
111+
.measures_for_query(&logical_plan.schema().measures, &context)
112112
{
113113
if exists {
114114
references_builder.resolve_references_for_member(
@@ -126,9 +126,9 @@ impl<'a> LogicalNodeProcessor<'a, Query> for QueryProcessor<'a> {
126126
references_builder.resolve_references_for_filter(&having, &mut render_references)?;
127127
select_builder.set_filter(having);
128128
} else {
129-
if !logical_plan.modifers.ungrouped {
129+
if !logical_plan.modifers().ungrouped {
130130
let group_by = logical_plan
131-
.schema
131+
.schema()
132132
.all_dimensions()
133133
.map(|symbol| -> Result<_, CubeError> {
134134
Ok(Expr::Member(MemberExpression::new(symbol.clone())))
@@ -140,21 +140,21 @@ impl<'a> LogicalNodeProcessor<'a, Query> for QueryProcessor<'a> {
140140
select_builder.set_filter(filter);
141141
}
142142

143-
select_builder.set_limit(logical_plan.modifers.limit);
144-
select_builder.set_offset(logical_plan.modifers.offset);
143+
select_builder.set_limit(logical_plan.modifers().limit);
144+
select_builder.set_offset(logical_plan.modifers().offset);
145145

146146
context_factory
147-
.set_rendered_as_multiplied_measures(logical_plan.schema.multiplied_measures.clone());
147+
.set_rendered_as_multiplied_measures(logical_plan.schema().multiplied_measures.clone());
148148
if !is_pre_aggregation {
149149
context_factory.set_render_references(render_references);
150150
}
151-
if logical_plan.modifers.ungrouped {
151+
if logical_plan.modifers().ungrouped {
152152
context_factory.set_ungrouped(true);
153153
}
154154

155155
select_builder.set_order_by(
156156
self.builder
157-
.make_order_by(&logical_plan.schema, &logical_plan.modifers.order_by)?,
157+
.make_order_by(logical_plan.schema(), &logical_plan.modifers().order_by)?,
158158
);
159159

160160
let res = Rc::new(select_builder.build(query_tools.clone(), context_factory));

rust/cubesqlplanner/cubesqlplanner/src/planner/planners/full_key_query_aggregate_planner.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -74,18 +74,18 @@ impl FullKeyAggregateQueryPlanner {
7474
measures_filter: self.query_properties.measures_filters().clone(),
7575
segments: self.query_properties.segments().clone(),
7676
});
77-
let result = Query {
78-
schema,
79-
multistage_members: all_multistage_members,
80-
filter: logical_filter,
81-
modifers: Rc::new(LogicalQueryModifiers {
77+
let result = Query::builder()
78+
.schema(schema)
79+
.multistage_members(all_multistage_members)
80+
.filter(logical_filter)
81+
.modifers(Rc::new(LogicalQueryModifiers {
8282
offset: self.query_properties.offset(),
8383
limit: self.query_properties.row_limit(),
8484
ungrouped: self.query_properties.ungrouped(),
8585
order_by: self.query_properties.order_by().clone(),
86-
}),
87-
source,
88-
};
86+
}))
87+
.source(source)
88+
.build();
8989
Ok(Rc::new(result))
9090
}
9191
}

rust/cubesqlplanner/cubesqlplanner/src/planner/planners/multiplied_measures_query_planner.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -286,18 +286,17 @@ impl MultipliedMeasuresQueryPlanner {
286286
segments: self.query_properties.segments().clone(),
287287
});
288288

289-
let query = Query {
290-
schema,
291-
filter: logical_filter,
292-
modifers: Rc::new(LogicalQueryModifiers {
289+
let query = Query::builder()
290+
.schema(schema)
291+
.filter(logical_filter)
292+
.modifers(Rc::new(LogicalQueryModifiers {
293293
offset: None,
294294
limit: None,
295295
ungrouped: self.query_properties.ungrouped(),
296296
order_by: vec![],
297-
}),
298-
source: source.into(),
299-
multistage_members: vec![],
300-
};
297+
}))
298+
.source(source.into())
299+
.build();
301300
Ok(Rc::new(query))
302301
}
303302

rust/cubesqlplanner/cubesqlplanner/src/planner/planners/simple_query_planer.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,18 +40,17 @@ impl SimpleQueryPlanner {
4040
measures_filter: self.query_properties.measures_filters().clone(),
4141
segments: self.query_properties.segments().clone(),
4242
});
43-
let result = Query {
44-
multistage_members: vec![],
45-
schema,
46-
filter: logical_filter,
47-
modifers: Rc::new(LogicalQueryModifiers {
43+
let result = Query::builder()
44+
.schema(schema)
45+
.filter(logical_filter)
46+
.modifers(Rc::new(LogicalQueryModifiers {
4847
offset: self.query_properties.offset(),
4948
limit: self.query_properties.row_limit(),
5049
ungrouped: self.query_properties.ungrouped(),
5150
order_by: self.query_properties.order_by().clone(),
52-
}),
53-
source: source.into(),
54-
};
51+
}))
52+
.source(source.into())
53+
.build();
5554
Ok(Rc::new(result))
5655
}
5756

0 commit comments

Comments
 (0)