amansinha100 commented on code in PR #4237:
URL: https://github.com/apache/hive/pull/4237#discussion_r1168973804


##########
ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HivePointLookupOptimizerRule.java:
##########
@@ -669,6 +670,22 @@ private static RexNode handleAND(RexBuilder rexBuilder, 
RexCall call) {
       return RexUtil.composeConjunction(rexBuilder, newOperands, false);
     }
 
+    private static void retainAll(Collection<RexNode> elementsToRetain, 
Collection<RexNode> collection) {
+      collection.removeIf(rexNode -> elementsToRetain.stream().noneMatch(
+              rexNodeToRetain -> equalsWithSimilarType(rexNode, 
rexNodeToRetain)));
+    }
+
+    private static boolean equalsWithSimilarType(RexNode rexNode1, RexNode 
rexNode2) {
+      if (!(rexNode1 instanceof RexLiteral) || !(rexNode2 instanceof 
RexLiteral)) {
+        return rexNode1.equals(rexNode2);
+      }
+
+      RexLiteral rexLiteral1 = (RexLiteral) rexNode1;
+      RexLiteral rexLiteral2 = (RexLiteral) rexNode2;
+      return rexLiteral1.getValue().compareTo(rexLiteral2.getValue()) == 0 &&
+              
rexLiteral1.getType().getSqlTypeName().equals(rexLiteral2.getType().getSqlTypeName());

Review Comment:
   I wasn't worried about performance..just the fact that there was redundant 
check.  But yeah I understand the reason for having the check also within 
equalsWithSimilarType.  Ok to leave it as-is. 



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