richardstartin commented on a change in pull request #8343:
URL: https://github.com/apache/pinot/pull/8343#discussion_r830592193



##########
File path: 
pinot-core/src/main/java/org/apache/pinot/core/query/selection/SelectionOperatorUtils.java
##########
@@ -129,16 +139,55 @@ private SelectionOperatorUtils() {
       }
     } else {
       for (ExpressionContext selectExpression : selectExpressions) {
-        if (expressionSet.add(selectExpression)) {
-          expressions.add(selectExpression);
+        ExpressionContext expression = selectExpression;
+        ExpressionContext newExpression = 
overrideWithFunctionIndex(indexSegment, pushdownExpressionsMap, expression);
+        if (newExpression != null) {
+          expression = newExpression;
+        }
+        if (expressionSet.add(expression)) {
+          expressions.add(expression);
         }
       }
     }
 
     return expressions;
   }
 
-  /**
+  private static ExpressionContext overrideWithFunctionIndex(IndexSegment 
indexSegment,
+      Map<Integer, String> pushdownExpressions, ExpressionContext expression) {
+    if (expression.getType() != ExpressionContext.Type.FUNCTION) {
+      return null;
+    }
+    String pushdownExpression = pushdownExpressions.get(expression.hashCode());
+    if (pushdownExpression != null && 
indexSegment.getDataSource(pushdownExpression) != null) {
+      return ExpressionContext.forIdentifier(pushdownExpression);
+    }
+    List<ExpressionContext> arguments = 
expression.getFunction().getArguments();
+    for (int i = 0; i < arguments.size(); i++) {
+      ExpressionContext argument = arguments.get(i);
+      ExpressionContext newExpression = 
overrideWithFunctionIndex(indexSegment, pushdownExpressions, argument);
+      if (newExpression != null) {
+        arguments.set(i, newExpression);
+      }
+    }
+    return null;
+  }
+
+  public static Map<Integer, String> getPushdownExpressionsMap(QueryContext 
queryContext) {
+    Map<String, String> pushdownExpressions = ImmutableMap.of();
+    try {
+      String pushdownExpressionsOption = 
queryContext.getQueryOptions().get("pushdown.timestamp.index.expression");
+      if (pushdownExpressionsOption != null) {
+        pushdownExpressions = new 
ObjectMapper().readValue(pushdownExpressionsOption, Map.class);

Review comment:
       Here also, need to avoid constructing ObjectMapper anywhere but one off 
initialisation code paths.




-- 
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