Jackie-Jiang commented on a change in pull request #7566:
URL: https://github.com/apache/pinot/pull/7566#discussion_r731384102
##########
File path:
pinot-common/src/main/java/org/apache/pinot/common/request/context/RequestContextUtils.java
##########
@@ -161,6 +161,97 @@ public static FunctionContext
getFunction(FunctionCallAstNode astNode) {
}
}
+ /**
+ * Converts the given {@link ExpressionContext} into a {@link FilterContext}.
+ * <p>NOTE: Currently the query engine only accepts string literals as the
right-hand side of the predicate, so we
+ * always convert the right-hand side expressions into strings.
+ */
+ public static FilterContext getFilter(ExpressionContext expressionContext) {
Review comment:
We should always convert the filter from the `Expression`. The
`ExpressionContext` should not contain filters.
##########
File path:
pinot-core/src/main/java/org/apache/pinot/core/query/request/context/QueryContext.java
##########
@@ -384,25 +408,54 @@ private static void getAggregations(ExpressionContext
expression, List<FunctionC
} else {
// Transform
for (ExpressionContext argument : function.getArguments()) {
- getAggregations(argument, aggregations);
+ if (function.getFunctionName().equalsIgnoreCase("filter")) {
+ getFilteredAggregationExpressions(expression,
filteredAggregations, queryContext);
+ }
+
+ getAggregations(argument, aggregations, filteredAggregations,
queryContext);
}
}
}
/**
* Helper method to extract AGGREGATION FunctionContexts from the given
filter.
*/
- private static void getAggregations(FilterContext filter,
List<FunctionContext> aggregations) {
+ private static void getAggregations(FilterContext filter,
List<FunctionContext> aggregations,
+ Map<FunctionContext, FilterContext> filterContextMap, QueryContext
queryContext) {
List<FilterContext> children = filter.getChildren();
if (children != null) {
for (FilterContext child : children) {
- getAggregations(child, aggregations);
+ getAggregations(child, aggregations, filterContextMap, queryContext);
}
} else {
- getAggregations(filter.getPredicate().getLhs(), aggregations);
+ getAggregations(filter.getPredicate().getLhs(), aggregations,
filterContextMap, queryContext);
}
}
+ /**
+ * Helper method to extract aggregation FunctionContexts with filter from
the given expression
+ */
+ private static void getFilteredAggregationExpressions(ExpressionContext
expression,
+ Map<FunctionContext, FilterContext> filterContextMap, QueryContext
queryContext) {
Review comment:
This should be `List<Pair<FunctionContext, FilterContext>>` because
there might be multiple same aggregations with different filters
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]