Skip to content

Commit b4f6196

Browse files
committed
plan works
1 parent 3c67aac commit b4f6196

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+886
-341
lines changed

rust/cubesqlplanner/cubesqlplanner/src/logical_plan/aggregate_multiplied_subquery.rs

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,24 @@ use super::pretty_print::*;
22
use super::LogicalFilter;
33
use super::LogicalJoin;
44
use super::*;
5-
use crate::plan::{Expr, Filter, FilterItem, MemberExpression};
6-
use crate::planner::sql_evaluator::MemberSymbol;
75
use crate::planner::query_properties::OrderByItem;
6+
use crate::planner::BaseCube;
87
use std::rc::Rc;
98

109
pub enum AggregateMultipliedSubquerySouce {
11-
Cube(Rc<Cube>)
10+
Cube,
11+
MeasureSubquery(Rc<MeasureSubquery>),
1212
}
1313

14-
impl PrettyPrint for AggregateMultipliedSubquerySouce {
15-
fn pretty_print(&self, result: &mut PrettyPrintResult, state: &PrettyPrintState) {
16-
match self {
17-
AggregateMultipliedSubquerySouce::Cube(cube) => {
18-
result.println(&format!("Cube: {}", cube.cube.name()), state);
19-
}
20-
}
21-
}
22-
}
23-
24-
25-
2614
pub struct AggregateMultipliedSubquery {
2715
pub schema: Rc<LogicalSchema>,
2816
pub dimension_subqueries: Vec<Rc<DimensionSubQuery>>,
2917
pub keys_subquery: Rc<KeysSubQuery>,
18+
pub pk_cube: Rc<BaseCube>, //FIXME may be duplication with information in keys_subquery
3019
pub source: Rc<AggregateMultipliedSubquerySouce>,
31-
3220
}
3321

34-
impl PrettyPrint for AggregateMultipliedSubquery {
22+
impl PrettyPrint for AggregateMultipliedSubquery {
3523
fn pretty_print(&self, result: &mut PrettyPrintResult, state: &PrettyPrintState) {
3624
result.println("AggregateMultipliedSubquery: ", state);
3725
let state = state.new_level();
@@ -47,8 +35,17 @@ impl PrettyPrint for AggregateMultipliedSubquery {
4735
result.println("keys_subquery:", &state);
4836
self.keys_subquery.pretty_print(result, &details_state);
4937
result.println("source:", &state);
50-
self.source.pretty_print(result, &details_state);
51-
38+
match self.source.as_ref() {
39+
AggregateMultipliedSubquerySouce::Cube => {
40+
result.println(&format!("Cube: {}", self.pk_cube.name()), &details_state);
41+
}
42+
AggregateMultipliedSubquerySouce::MeasureSubquery(measure_subquery) => {
43+
result.println(
44+
&format!("MeasureSubquery: {}", measure_subquery.measures.len()),
45+
&details_state,
46+
);
47+
measure_subquery.pretty_print(result, &details_state);
48+
}
49+
}
5250
}
5351
}
54-
Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use super::pretty_print::*;
2-
use super::*;
32
use super::LogicalSchema;
3+
use super::*;
44
use crate::plan::{Expr, Filter, FilterItem, MemberExpression};
55
use crate::planner::sql_evaluator::MemberSymbol;
66
use std::rc::Rc;
@@ -10,7 +10,7 @@ pub struct DimensionSubQuery {
1010
pub primary_keys_dimensions: Vec<Rc<MemberSymbol>>,
1111
pub subquery_dimension: Rc<MemberSymbol>,
1212
pub measure_for_subquery_dimension: Rc<MemberSymbol>,
13-
}
13+
}
1414

1515
impl PrettyPrint for DimensionSubQuery {
1616
fn pretty_print(&self, result: &mut PrettyPrintResult, state: &PrettyPrintState) {
@@ -20,10 +20,25 @@ impl PrettyPrint for DimensionSubQuery {
2020
result.println(&format!("query: "), &state);
2121
self.query.pretty_print(result, &details_state);
2222
result.println(
23-
&format!("-primary_keys_dimensions: {}", print_symbols(&self.primary_keys_dimensions)),
23+
&format!(
24+
"-primary_keys_dimensions: {}",
25+
print_symbols(&self.primary_keys_dimensions)
26+
),
27+
&state,
28+
);
29+
result.println(
30+
&format!(
31+
"-subquery_dimension: {}",
32+
self.subquery_dimension.full_name()
33+
),
34+
&state,
35+
);
36+
result.println(
37+
&format!(
38+
"-measure_for_subquery_dimension: {}",
39+
self.measure_for_subquery_dimension.full_name()
40+
),
2441
&state,
2542
);
26-
result.println(&format!("-subquery_dimension: {}", self.subquery_dimension.full_name()), &state);
27-
result.println(&format!("-measure_for_subquery_dimension: {}", self.measure_for_subquery_dimension.full_name()), &state);
2843
}
29-
}
44+
}

rust/cubesqlplanner/cubesqlplanner/src/logical_plan/filter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use super::pretty_print::*;
22
use crate::plan::{Expr, Filter, FilterItem, MemberExpression};
33
use crate::planner::sql_evaluator::MemberSymbol;
4-
use std::rc::Rc;
54
use itertools::Itertools;
5+
use std::rc::Rc;
66

77
pub struct LogicalFilter {
88
pub dimensions_filters: Vec<FilterItem>,

rust/cubesqlplanner/cubesqlplanner/src/logical_plan/full_key_aggregate.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
use super::*;
22
use crate::plan::{Expr, Filter, FilterItem, MemberExpression};
3-
use crate::planner::sql_evaluator::MemberSymbol;
43
use crate::planner::query_properties::OrderByItem;
4+
use crate::planner::sql_evaluator::MemberSymbol;
55
use std::rc::Rc;
66

77
pub struct MultiStageSubqueryRef {
8-
pub name: String
8+
pub name: String,
99
}
1010

1111
impl PrettyPrint for MultiStageSubqueryRef {
@@ -14,10 +14,9 @@ impl PrettyPrint for MultiStageSubqueryRef {
1414
}
1515
}
1616

17-
1817
pub enum FullKeyAggregateSource {
1918
ResolveMultipliedMeasures(Rc<ResolveMultipliedMeasures>),
20-
MultiStageSubqueryRef(Rc<MultiStageSubqueryRef>)
19+
MultiStageSubqueryRef(Rc<MultiStageSubqueryRef>),
2120
}
2221

2322
impl PrettyPrint for FullKeyAggregateSource {
@@ -35,7 +34,8 @@ impl PrettyPrint for FullKeyAggregateSource {
3534

3635
pub struct FullKeyAggregate {
3736
pub join_dimensions: Vec<Rc<MemberSymbol>>,
38-
pub sources: Vec<FullKeyAggregateSource>
37+
pub use_full_join_and_coalesce: bool,
38+
pub sources: Vec<FullKeyAggregateSource>,
3939
}
4040

4141
impl PrettyPrint for FullKeyAggregate {
@@ -47,10 +47,16 @@ impl PrettyPrint for FullKeyAggregate {
4747
&format!("join_dimensions: {}", print_symbols(&self.join_dimensions)),
4848
&state,
4949
);
50+
result.println(
51+
&format!(
52+
"use_full_join_and_coalesce: {}",
53+
self.use_full_join_and_coalesce
54+
),
55+
&state,
56+
);
5057
result.println("sources:", &state);
5158
for source in self.sources.iter() {
5259
source.pretty_print(result, &details_state);
5360
}
5461
}
5562
}
56-

rust/cubesqlplanner/cubesqlplanner/src/logical_plan/full_key_aggregate_query.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use super::*;
2-
use std::rc::Rc;
32
use crate::planner::query_properties::OrderByItem;
3+
use std::rc::Rc;
44

55
pub struct FullKeyAggregateQuery {
66
pub multistage_members: Vec<Rc<LogicalMultiStageMember>>,
@@ -14,7 +14,7 @@ pub struct FullKeyAggregateQuery {
1414
}
1515

1616
impl PrettyPrint for FullKeyAggregateQuery {
17-
fn pretty_print(&self, result: &mut PrettyPrintResult, state: &PrettyPrintState) {
17+
fn pretty_print(&self, result: &mut PrettyPrintResult, state: &PrettyPrintState) {
1818
result.println("FullKeyAggregateQuery: ", state);
1919
let state = state.new_level();
2020
let details_state = state.new_level();
@@ -39,11 +39,17 @@ impl PrettyPrint for FullKeyAggregateQuery {
3939
if !self.order_by.is_empty() {
4040
result.println("order_by:", &state);
4141
for order_by in self.order_by.iter() {
42-
result.println(&format!("{} {}", order_by.name(), if order_by.desc() { "desc" } else { "asc" }), &details_state);
42+
result.println(
43+
&format!(
44+
"{} {}",
45+
order_by.name(),
46+
if order_by.desc() { "desc" } else { "asc" }
47+
),
48+
&details_state,
49+
);
4350
}
4451
}
4552
result.println("source:", &state);
4653
self.source.pretty_print(result, &details_state);
4754
}
4855
}
49-

rust/cubesqlplanner/cubesqlplanner/src/logical_plan/keys_subquery.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ pub struct KeysSubQuery {
77
pub key_cube_name: String,
88
pub time_dimensions: Vec<Rc<MemberSymbol>>,
99
pub dimensions: Vec<Rc<MemberSymbol>>,
10-
pub dimension_subqueries: Vec<Rc<DimensionSubQuery>>,
10+
pub dimension_subqueries: Vec<Rc<DimensionSubQuery>>,
1111
pub primary_keys_dimensions: Vec<Rc<MemberSymbol>>,
1212
pub filter: Rc<LogicalFilter>,
1313
pub source: Rc<LogicalJoin>,
@@ -18,7 +18,7 @@ impl PrettyPrint for KeysSubQuery {
1818
result.println("KeysSubQuery: ", state);
1919
let state = state.new_level();
2020
let details_state = state.new_level();
21-
result.println(&format!("-key_cube_name: {}", self.key_cube_name), &state);
21+
result.println(&format!("-key_cube_name: {}", self.key_cube_name), &state);
2222
result.println(
2323
&format!("-time_dimensions: {}", print_symbols(&self.time_dimensions)),
2424
&state,
@@ -27,14 +27,17 @@ impl PrettyPrint for KeysSubQuery {
2727
&format!("-dimensions: {}", print_symbols(&self.dimensions)),
2828
&state,
2929
);
30-
/* if !self.dimension_subqueries.is_empty() {
30+
/* if !self.dimension_subqueries.is_empty() {
3131
result.println("dimension_subqueries:", &state);
3232
for subquery in self.dimension_subqueries.iter() {
3333
subquery.pretty_print(result, &details_state);
3434
}
3535
} */
3636
result.println(
37-
&format!("-primary_keys_dimensions: {}", print_symbols(&self.primary_keys_dimensions)),
37+
&format!(
38+
"-primary_keys_dimensions: {}",
39+
print_symbols(&self.primary_keys_dimensions)
40+
),
3841
&state,
3942
);
4043
result.println("filters:", &state);
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
use super::*;
2+
use crate::planner::query_properties::OrderByItem;
3+
use crate::planner::sql_evaluator::MemberSymbol;
4+
use std::rc::Rc;
5+
6+
pub struct MeasureSubquery {
7+
pub primary_keys_dimensions: Vec<Rc<MemberSymbol>>,
8+
pub measures: Vec<Rc<MemberSymbol>>,
9+
pub dimension_subqueries: Vec<Rc<DimensionSubQuery>>,
10+
pub source: Rc<LogicalJoin>,
11+
}
12+
13+
impl PrettyPrint for MeasureSubquery {
14+
fn pretty_print(&self, result: &mut PrettyPrintResult, state: &PrettyPrintState) {
15+
let details_state = state.new_level();
16+
result.println(
17+
&format!(
18+
"primary_key_dimensions: {}",
19+
print_symbols(&self.primary_keys_dimensions)
20+
),
21+
state,
22+
);
23+
result.println(
24+
&format!("measures: {}", print_symbols(&self.measures)),
25+
state,
26+
);
27+
result.println("dimension_subqueries:", state);
28+
if !self.dimension_subqueries.is_empty() {
29+
for subquery in self.dimension_subqueries.iter() {
30+
subquery.pretty_print(result, &details_state);
31+
}
32+
}
33+
result.println("source:", state);
34+
self.source.pretty_print(result, &details_state);
35+
}
36+
}
Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,33 @@
1+
mod aggregate_multiplied_subquery;
12
mod cube;
3+
mod dimension_subquery;
24
mod filter;
5+
mod full_key_aggregate;
6+
mod full_key_aggregate_query;
37
mod join;
8+
mod keys_subquery;
9+
mod measure_subquery;
10+
mod multistage;
411
mod pretty_print;
5-
mod simple_query;
6-
mod schema;
12+
mod query;
713
mod regular_measures_query;
8-
mod keys_subquery;
9-
mod aggregate_multiplied_subquery;
1014
mod resolve_multiplied_measures;
11-
mod full_key_aggregate;
12-
mod full_key_aggregate_query;
13-
mod query;
14-
mod dimension_subquery;
15-
mod multistage;
15+
mod schema;
16+
mod simple_query;
1617

18+
pub use aggregate_multiplied_subquery::*;
1719
pub use cube::*;
20+
pub use dimension_subquery::*;
1821
pub use filter::*;
22+
pub use full_key_aggregate::*;
23+
pub use full_key_aggregate_query::*;
1924
pub use join::*;
25+
pub use keys_subquery::*;
26+
pub use measure_subquery::*;
27+
pub use multistage::*;
2028
pub use pretty_print::*;
21-
pub use simple_query::*;
22-
pub use dimension_subquery::*;
23-
pub use schema::*;
24-
pub use aggregate_multiplied_subquery::*;
29+
pub use query::*;
2530
pub use regular_measures_query::*;
26-
pub use keys_subquery::*;
2731
pub use resolve_multiplied_measures::*;
28-
pub use full_key_aggregate::*;
29-
pub use full_key_aggregate_query::*;
30-
pub use query::*;
31-
pub use multistage::*;
32+
pub use schema::*;
33+
pub use simple_query::*;

0 commit comments

Comments
 (0)