Jackie-Jiang commented on code in PR #11307:
URL: https://github.com/apache/pinot/pull/11307#discussion_r1290569887


##########
pinot-broker/src/main/java/org/apache/pinot/broker/requesthandler/BaseBrokerRequestHandler.java:
##########
@@ -1075,6 +1107,48 @@ private static void 
handleDistinctCountBitmapOverride(PinotQuery pinotQuery) {
     }
   }
 
+  /**
+   * Rewrites selected 'Distinct' prefixed function to 'Distinct----MV' 
function for the field of multivalued type.
+   */
+  @VisibleForTesting
+  static void handleDistinctMultiValuedOverride(PinotQuery pinotQuery, 
Set<String> multiValuedDimColumns) {
+    for (Expression expression : pinotQuery.getSelectList()) {
+      handleDistinctMultiValuedOverride(expression, multiValuedDimColumns);
+    }
+    List<Expression> orderByExpressions = pinotQuery.getOrderByList();
+    if (orderByExpressions != null) {
+      for (Expression expression : orderByExpressions) {
+        // NOTE: Order-by is always a Function with the ordering of the 
Expression
+        
handleDistinctMultiValuedOverride(expression.getFunctionCall().getOperands().get(0),
 multiValuedDimColumns);
+      }
+    }
+    Expression havingExpression = pinotQuery.getHavingExpression();
+    if (havingExpression != null) {
+      handleDistinctMultiValuedOverride(havingExpression, 
multiValuedDimColumns);
+    }
+  }
+
+  /**
+   * Rewrites selected 'Distinct' prefixed function to 'Distinct----MV' 
function for the field of multivalued type.
+   */
+  private static void handleDistinctMultiValuedOverride(Expression expression, 
Set<String> multiValuedDimColumns) {
+    Function function = expression.getFunctionCall();
+    if (function == null) {
+      return;
+    }
+    if (function.getOperator() != null && 
DISTINCT_MV_COL_FUNCTION_OVERRIDE_MAP.containsKey(function.getOperator())) {

Review Comment:
   (nit) operator can never be null



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