mdayakar commented on code in PR #6082:
URL: https://github.com/apache/hive/pull/6082#discussion_r2375494181


##########
ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HivePointLookupOptimizerRule.java:
##########
@@ -659,14 +658,17 @@ private static RexNode handleAND(RexBuilder rexBuilder, 
RexCall call) {
           } else {
             inLHSExprToRHSExprs.put(c.exprNode, new 
SimilarRexNodeElement(c.constNode));
           }
-          operands.remove(i);
-          --i;
+          ++eqExpressionCount;
+        } else {
+          newOperands.add(operand);
         }
       }
+      if (inExpressionCount + eqExpressionCount == 
inLHSExprToRHSExprs.keySet().size()) {

Review Comment:
   my bad, I didn't observe the type of `inLHSExprToRHSExprs` is a Multimap.



##########
ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HivePointLookupOptimizerRule.java:
##########
@@ -734,26 +736,30 @@ private static boolean shareSameType(
     private static RexNode handleOR(RexBuilder rexBuilder, RexCall call) {
       // IN clauses need to be combined by keeping all elements
       final List<RexNode> operands = new 
ArrayList<>(RexUtil.flattenOr(call.getOperands()));
+      final List<RexNode> newOperands = new ArrayList<>(operands.size());
       final Multimap<RexNode,SimilarRexNodeElement> inLHSExprToRHSExprs = 
LinkedHashMultimap.create();
-      for (int i = 0; i < operands.size(); i++) {
-        RexNode operand = operands.get(i);
-        if (operand instanceof RexCall && HiveIn.INSTANCE.equals(((RexCall) 
operand).op)) {
-          RexCall inCall = (RexCall) operand;
-          if (!HiveCalciteUtil.isDeterministic(inCall.getOperands().get(0))) {
+      int inExpressionCount = 0;
+      for (RexNode operand : operands) {
+        if (operand instanceof RexCall inCall && 
HiveIn.INSTANCE.equals(inCall.op)) {
+          if 
(!HiveCalciteUtil.isDeterministic(inCall.getOperands().getFirst())) {
             continue;
           }
-          RexNode ref = inCall.getOperands().get(0);
+          RexNode ref = inCall.getOperands().getFirst();
           for (int j = 1; j < inCall.getOperands().size(); j++) {
             inLHSExprToRHSExprs.put(ref, new 
SimilarRexNodeElement(inCall.getOperands().get(j)));
           }
-          operands.remove(i);
-          --i;
+          ++inExpressionCount;
+        } else {
+          newOperands.add(operand);
         }
       }
+      if (inExpressionCount == inLHSExprToRHSExprs.keySet().size()) {

Review Comment:
   my bad, I didn't observe the type of `inLHSExprToRHSExprs` is a Multimap.



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

Reply via email to