siddharthteotia commented on a change in pull request #7830: URL: https://github.com/apache/pinot/pull/7830#discussion_r764475919
########## File path: pinot-core/src/main/java/org/apache/pinot/core/query/request/context/QueryContext.java ########## @@ -441,34 +442,40 @@ public QueryContext build() { */ private void generateAggregationFunctions(QueryContext queryContext) { List<AggregationFunction> aggregationFunctions = new ArrayList<>(); - List<Pair<AggregationFunction, FilterContext>> filteredAggregationFunctions = new ArrayList<>(); + List<FilterContext> filteredAggregationFunctions = new ArrayList<>(); Map<FunctionContext, Integer> aggregationFunctionIndexMap = new HashMap<>(); // Add aggregation functions in the SELECT clause // NOTE: DO NOT deduplicate the aggregation functions in the SELECT clause because that involves protocol change. - List<FunctionContext> aggregationsInSelect = new ArrayList<>(); - List<Pair<FunctionContext, FilterContext>> filteredAggregations = new ArrayList<>(); + List<Pair<Boolean, FunctionContext>> aggregationsInSelect = new ArrayList<>(); + List<FilterContext> filteredAggregationContexts = new ArrayList<>(); for (ExpressionContext selectExpression : queryContext._selectExpressions) { - getAggregations(selectExpression, aggregationsInSelect, filteredAggregations); + getAggregations(selectExpression, aggregationsInSelect, + filteredAggregationContexts); } - for (FunctionContext function : aggregationsInSelect) { + for (Pair<Boolean, FunctionContext> pair : aggregationsInSelect) { + FunctionContext function = pair.getRight(); int functionIndex = aggregationFunctions.size(); AggregationFunction aggregationFunction = AggregationFunctionFactory.getAggregationFunction(function, queryContext); + + + aggregationFunction.setFilteredAggregation(pair.getLeft()); + aggregationFunctions.add(aggregationFunction); + aggregationFunctionIndexMap.put(function, functionIndex); } - for (Pair<FunctionContext, FilterContext> pair : filteredAggregations) { - AggregationFunction aggregationFunction = - aggregationFunctions.get(aggregationFunctionIndexMap.get(pair.getLeft())); - filteredAggregationFunctions.add(Pair.of(aggregationFunction, pair.getRight())); + for (FilterContext filterContext : filteredAggregationContexts) { Review comment: Why do we need to create two lists for filtered aggregations ? -- 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