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


##########
pinot-broker/src/main/java/org/apache/pinot/broker/requesthandler/BaseBrokerRequestHandler.java:
##########
@@ -703,6 +705,49 @@ private BrokerResponseNative handleRequest(long requestId, 
String query,
     }
   }
 
+  private void handleBigInClause(PinotQuery serverPinotQuery) {
+    int inPredicateSortThreshold = 
Integer.parseInt(serverPinotQuery.getQueryOptions()
+        
.getOrDefault(Broker.Request.QueryOptionKey.IN_PREDICATE_SORT_THRESHOLD,
+            
Broker.Request.QueryOptionValue.DEFAULT_IN_PREDICATE_SORT_THRESHOLD));
+    String rawTableName = 
TableNameBuilder.extractRawTableName(serverPinotQuery.getDataSource().getTableName());
+    if (serverPinotQuery.getFilterExpression() != null) {
+      handleBigInClause(rawTableName, serverPinotQuery.getFilterExpression(), 
inPredicateSortThreshold);
+    }
+    if (serverPinotQuery.getHavingExpression() != null) {
+      handleBigInClause(rawTableName, serverPinotQuery.getHavingExpression(), 
inPredicateSortThreshold);
+    }
+  }
+
+  private void handleBigInClause(String rawTableName, Expression expression, 
int inPredicateSortThreshold) {
+    if (expression.getType() == ExpressionType.FUNCTION) {
+      Function functionCall = expression.getFunctionCall();
+
+      switch (functionCall.getOperator()) {
+        case "IN":
+        case "NOT_IN":
+          List<Expression> operands = functionCall.getOperands();
+          if (operands.size() > inPredicateSortThreshold && 
isExpressionStringColumn(operands.get(0), rawTableName)) {
+            Collections.sort(operands.subList(1, operands.size()));

Review Comment:
   Expression compare is quite expensive. Also, it might yield unexpected 
result when the literal type is different, or by any chance some expression is 
not literal.
   
   We may move the sort to the server side and use the shared values in 
`QueryContext` to prevent per-segment computation. This way we can always get 
the correct data type, and process the values properly



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