Attach `grouping_sets` to an existing `SqlPlan::Aggregate` node, or wrap it in a new one when the engine rules returned a non-Aggregate plan.
(
base_plan: SqlPlan,
group_by: Vec<SqlExpr>,
aggregates: Vec<AggregateExpr>,
having: Vec<Filter>,
grouping_sets: Vec<Vec<usize>>,
)
| 82 | /// Attach `grouping_sets` to an existing `SqlPlan::Aggregate` node, or wrap it |
| 83 | /// in a new one when the engine rules returned a non-Aggregate plan. |
| 84 | fn attach_grouping_sets( |
| 85 | base_plan: SqlPlan, |
| 86 | group_by: Vec<SqlExpr>, |
| 87 | aggregates: Vec<AggregateExpr>, |
| 88 | having: Vec<Filter>, |
| 89 | grouping_sets: Vec<Vec<usize>>, |
| 90 | ) -> SqlPlan { |
| 91 | match base_plan { |
| 92 | SqlPlan::Aggregate { |
| 93 | input, |
| 94 | limit, |
| 95 | grouping_sets: _, |
| 96 | sort_keys, |
| 97 | .. |
| 98 | } => SqlPlan::Aggregate { |
| 99 | input, |
| 100 | group_by, |
| 101 | aggregates, |
| 102 | having, |
| 103 | limit, |
| 104 | grouping_sets: Some(grouping_sets), |
| 105 | sort_keys, |
| 106 | }, |
| 107 | other => { |
| 108 | // Engine returned something other than Aggregate (e.g. TimeseriesIngest). |
| 109 | // Wrap it so grouping sets are not silently dropped. |
| 110 | SqlPlan::Aggregate { |
| 111 | input: Box::new(other), |
| 112 | group_by, |
| 113 | aggregates, |
| 114 | having, |
| 115 | limit: 10000, |
| 116 | grouping_sets: Some(grouping_sets), |
| 117 | sort_keys: Vec::new(), |
| 118 | } |
| 119 | } |
| 120 | } |
| 121 | } |
| 122 | |
| 123 | /// Extract timeseries-specific parameters from GROUP BY (bucket interval, group columns). |
| 124 | /// |