kasakrisz commented on code in PR #4237:
URL: https://github.com/apache/hive/pull/4237#discussion_r1172331165
##########
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 &&
Review Comment:
Good point. Added null check.
--
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]