vvivekiyer commented on code in PR #8518:
URL: https://github.com/apache/pinot/pull/8518#discussion_r859461905


##########
pinot-common/src/main/java/org/apache/pinot/sql/parsers/rewriter/PredicateComparisonRewriter.java:
##########
@@ -33,75 +36,138 @@ public class PredicateComparisonRewriter implements 
QueryRewriter {
   public PinotQuery rewrite(PinotQuery pinotQuery) {
     Expression filterExpression = pinotQuery.getFilterExpression();
     if (filterExpression != null) {
-      
pinotQuery.setFilterExpression(updateComparisonPredicate(filterExpression));
+      pinotQuery.setFilterExpression(updatePredicate(filterExpression, null));
     }
     Expression havingExpression = pinotQuery.getHavingExpression();
     if (havingExpression != null) {
-      
pinotQuery.setHavingExpression(updateComparisonPredicate(havingExpression));
+      pinotQuery.setHavingExpression(updatePredicate(havingExpression, null));
     }
     return pinotQuery;
   }
 
-  // This method converts a predicate expression to the what Pinot could 
evaluate.
-  // For comparison expression, left operand could be any expression, but 
right operand only
-  // supports literal.
-  // E.g. 'WHERE a > b' will be updated to 'WHERE a - b > 0'
-  private static Expression updateComparisonPredicate(Expression expression) {
-    Function function = expression.getFunctionCall();
-    if (function != null) {
-      FilterKind filterKind;
-      try {
-        filterKind = FilterKind.valueOf(function.getOperator());
-      } catch (Exception e) {
-        throw new SqlCompilationException("Unsupported filter kind: " + 
function.getOperator());
-      }
-      List<Expression> operands = function.getOperands();
-      switch (filterKind) {
-        case AND:
-        case OR:
-        case NOT:
-          
operands.replaceAll(PredicateComparisonRewriter::updateComparisonPredicate);
-          break;
-        case EQUALS:
-        case NOT_EQUALS:
-        case GREATER_THAN:
-        case GREATER_THAN_OR_EQUAL:
-        case LESS_THAN:
-        case LESS_THAN_OR_EQUAL:
-          Expression firstOperand = operands.get(0);
-          Expression secondOperand = operands.get(1);
+  /**
+   This method converts a predicate expression to the what Pinot could 
evaluate.
+   1. For comparison expression, left operand could be any expression, but 
right operand only
+   supports literal. E.g. 'WHERE a > b' will be converted to 'WHERE a - b > 0'
+   2. Updates boolean predicates (literals and scalar functions) that are 
missing an EQUALS filter.
+   *
+   *
+   * @param expression current expression in the expression tree
+   * @param parentFunction parent expression
+   * @return re-written expression.
+   */

Review Comment:
   Done.



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