atris commented on a change in pull request #7916:
URL: https://github.com/apache/pinot/pull/7916#discussion_r787520413



##########
File path: 
pinot-core/src/main/java/org/apache/pinot/core/plan/AggregationPlanNode.java
##########
@@ -154,4 +129,168 @@ private static boolean 
isFitForDictionaryBasedPlan(AggregationFunction[] aggrega
     }
     return true;
   }
+
+  /**
+   * Build a FilteredAggregationOperator given the parameters.
+   * @param mainPredicateFilterOperator Filter operator corresponding to the 
main predicate
+   * @param mainTransformOperator Transform operator corresponding to the main 
predicate
+   * @param aggregationFunctions Aggregation functions in the query
+   * @param numTotalDocs Number of total docs
+   */
+  private BaseOperator<IntermediateResultsBlock> 
buildOperatorForFilteredAggregations(
+      BaseFilterOperator mainPredicateFilterOperator,
+      TransformOperator mainTransformOperator,
+      AggregationFunction[] aggregationFunctions, int numTotalDocs) {
+    Map<ExpressionContext, Pair<List<AggregationFunction>, TransformOperator>> 
expressionContextToAggFuncsMap =
+        new HashMap<>();
+    List<AggregationFunction> nonFilteredAggregationFunctions = new 
ArrayList<>();
+
+    // For each aggregation function, check if the aggregation function is a 
filtered agg.
+    // If it is, populate the corresponding filter operator and corresponding 
transform operator
+    for (AggregationFunction aggregationFunction : aggregationFunctions) {
+      if (aggregationFunction instanceof FilterableAggregationFunction) {
+        FilterableAggregationFunction filterableAggregationFunction =
+            (FilterableAggregationFunction) aggregationFunction;
+
+        ExpressionContext currentFilterExpression = 
filterableAggregationFunction
+            .getAssociatedExpressionContext();
+
+        if (expressionContextToAggFuncsMap.get(currentFilterExpression) != 
null) {
+          
expressionContextToAggFuncsMap.get(currentFilterExpression).getLeft().add(aggregationFunction);

Review comment:
       There are existing tests that test multiple aggregates for the same 
filter, and have added more. If we do not share TransformOperators, would that 
not mean a separate chain per aggregation operator, even if they had the exact 
same predicate?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org
For additional commands, e-mail: commits-h...@pinot.apache.org

Reply via email to