@@ -250,10 +250,30 @@ pub fn get_cleanup_param(
250250 Ok ( result)
251251}
252252
253+ pub fn set_subpopulation_labels (
254+ statistic : Statistic ,
255+ aggregation_type : & str ,
256+ subpopulation_labels : & KeyByLabelNames ,
257+ rollup_labels : & mut KeyByLabelNames ,
258+ grouping_labels : & mut KeyByLabelNames ,
259+ aggregated_labels : & mut KeyByLabelNames ,
260+ ) {
261+ // rollup is set by caller before calling this function
262+ let _ = rollup_labels; // not modified here
263+ if does_precompute_operator_support_subpopulations ( statistic, aggregation_type) {
264+ * grouping_labels = KeyByLabelNames :: empty ( ) ;
265+ * aggregated_labels = subpopulation_labels. clone ( ) ;
266+ } else {
267+ * grouping_labels = subpopulation_labels. clone ( ) ;
268+ * aggregated_labels = KeyByLabelNames :: empty ( ) ;
269+ }
270+ }
271+
253272#[ cfg( test) ]
254273mod tests {
255274 use super :: * ;
256275 use crate :: planner:: patterns:: build_patterns;
276+
257277 use promql_utilities:: ast_matching:: PromQLMatchResult ;
258278 use promql_utilities:: query_logics:: enums:: QueryPatternType ;
259279
@@ -381,22 +401,3 @@ mod tests {
381401 assert ! ( result. is_err( ) ) ;
382402 }
383403}
384-
385- pub fn set_subpopulation_labels (
386- statistic : Statistic ,
387- aggregation_type : & str ,
388- subpopulation_labels : & KeyByLabelNames ,
389- rollup_labels : & mut KeyByLabelNames ,
390- grouping_labels : & mut KeyByLabelNames ,
391- aggregated_labels : & mut KeyByLabelNames ,
392- ) {
393- // rollup is set by caller before calling this function
394- let _ = rollup_labels; // not modified here
395- if does_precompute_operator_support_subpopulations ( statistic, aggregation_type) {
396- * grouping_labels = KeyByLabelNames :: empty ( ) ;
397- * aggregated_labels = subpopulation_labels. clone ( ) ;
398- } else {
399- * grouping_labels = subpopulation_labels. clone ( ) ;
400- * aggregated_labels = KeyByLabelNames :: empty ( ) ;
401- }
402- }
0 commit comments