Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions rust/cubesql/cubesql/src/compile/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2274,7 +2274,7 @@ from
logical_plan.find_cube_scan().request,
V1LoadRequestQuery {
measures: Some(vec![]),
dimensions: Some(vec![]),
dimensions: Some(vec!["KibanaSampleDataEcommerce.order_date".to_string()]),
segments: Some(vec![]),
order: Some(vec![]),
ungrouped: Some(true),
Expand Down Expand Up @@ -7323,7 +7323,10 @@ ORDER BY "source"."str0" ASC
query_plan.as_logical_plan().find_cube_scan().request,
V1LoadRequestQuery {
measures: Some(vec![]),
dimensions: Some(vec![]),
dimensions: Some(vec![
"WideCube.dim1".to_string(),
"WideCube.dim2".to_string(),
]),
segments: Some(vec![]),
order: Some(vec![]),
ungrouped: Some(true),
Expand Down
18 changes: 18 additions & 0 deletions rust/cubesql/cubesql/src/compile/rewrite/cost.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ impl BestCubePlan {
_ => 0,
};

let zero_members_wrapper = match enode {
LogicalPlanLanguage::WrappedSelect(_) => 1,
_ => 0,
};

let cube_members = match enode {
LogicalPlanLanguage::Measure(_) => 1,
LogicalPlanLanguage::Dimension(_) => 1,
Expand Down Expand Up @@ -196,6 +201,7 @@ impl BestCubePlan {
non_pushed_down_window,
non_pushed_down_grouping_sets,
non_pushed_down_limit_sort,
zero_members_wrapper,
cube_members,
errors: this_errors,
time_dimensions_used_as_dimensions,
Expand Down Expand Up @@ -247,6 +253,11 @@ pub struct CubePlanCost {
filters: i64,
structure_points: i64,
filter_members: i64,
// This is separate from both non_detected_cube_scans and cube_members
// Because it's ok to use all members inside wrapper (so non_detected_cube_scans would be zero)
// And we want to select representation with less members
// But only when members are present!
zero_members_wrapper: i64,
cube_members: i64,
errors: i64,
time_dimensions_used_as_dimensions: i64,
Expand Down Expand Up @@ -350,6 +361,11 @@ impl CubePlanCost {
non_pushed_down_limit_sort: self.non_pushed_down_limit_sort
+ other.non_pushed_down_limit_sort,
member_errors: self.member_errors + other.member_errors,
zero_members_wrapper: (if other.cube_members == 0 {
self.zero_members_wrapper
} else {
0
}) + other.zero_members_wrapper,
cube_members: self.cube_members + other.cube_members,
errors: self.errors + other.errors,
structure_points: self.structure_points + other.structure_points,
Expand Down Expand Up @@ -403,6 +419,8 @@ impl CubePlanCost {
SortState::Current if top_down => self.non_pushed_down_limit_sort,
_ => 0,
},
// Don't track state here: we want representation that have fewer wrappers with zero members _in total_
zero_members_wrapper: self.zero_members_wrapper,
cube_members: self.cube_members,
errors: self.errors,
structure_points: self.structure_points,
Expand Down
Loading