Skip to content

Commit 4b85872

Browse files
committed
feat(cubesql): Penalize any join in cost more than wrappers
1 parent 81df2c1 commit 4b85872

File tree

1 file changed

+9
-0
lines changed
  • rust/cubesql/cubesql/src/compile/rewrite

1 file changed

+9
-0
lines changed

rust/cubesql/cubesql/src/compile/rewrite/cost.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ impl BestCubePlan {
5858
_ => 0,
5959
};
6060

61+
let joins = match enode {
62+
LogicalPlanLanguage::Join(_) => 1,
63+
_ => 0,
64+
};
65+
6166
let wrapper_nodes = match enode {
6267
LogicalPlanLanguage::CubeScanWrapper(_) => 1,
6368
_ => 0,
@@ -209,6 +214,7 @@ impl BestCubePlan {
209214
structure_points,
210215
ungrouped_aggregates: 0,
211216
wrapper_nodes,
217+
joins,
212218
wrapped_select_ungrouped_scan,
213219
empty_wrappers: 0,
214220
ast_size_outside_wrapper: 0,
@@ -247,6 +253,7 @@ pub struct CubePlanCost {
247253
non_pushed_down_window: i64,
248254
non_pushed_down_grouping_sets: i64,
249255
non_pushed_down_limit_sort: i64,
256+
joins: usize,
250257
wrapper_nodes: i64,
251258
wrapped_select_ungrouped_scan: usize,
252259
ast_size_outside_wrapper: usize,
@@ -369,6 +376,7 @@ impl CubePlanCost {
369376
cube_members: self.cube_members + other.cube_members,
370377
errors: self.errors + other.errors,
371378
structure_points: self.structure_points + other.structure_points,
379+
joins: self.joins + other.joins,
372380
empty_wrappers: self.empty_wrappers + other.empty_wrappers,
373381
ast_size_outside_wrapper: self.ast_size_outside_wrapper
374382
+ other.ast_size_outside_wrapper,
@@ -424,6 +432,7 @@ impl CubePlanCost {
424432
cube_members: self.cube_members,
425433
errors: self.errors,
426434
structure_points: self.structure_points,
435+
joins: self.joins,
427436
ast_size_outside_wrapper: match state {
428437
CubePlanState::Wrapped => 0,
429438
CubePlanState::Unwrapped(size) => *size,

0 commit comments

Comments
 (0)