jcamachor commented on a change in pull request #1492:
URL: https://github.com/apache/hive/pull/1492#discussion_r488774172
##########
File path:
ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HivePointLookupOptimizerRule.java
##########
@@ -727,44 +708,58 @@ private RexNode useStructIfNeeded(List<? extends RexNode>
columns) {
}
} else {
for (int j = 1; j < inCall.getOperands().size(); j++) {
- String expr = inCall.getOperands().get(j).toString();
- inLHSExprToRHSExprs.put(ref, expr);
- stringToExpr.put(expr, inCall.getOperands().get(j));
+ inLHSExprToRHSExprs.put(ref, inCall.getOperands().get(j));
+ }
+ }
+ operands.remove(i);
+ --i;
+ } else if (operand.getKind() == SqlKind.EQUALS) {
+ Constraint c = Constraint.of(operand);
+ if (c == null || !HiveCalciteUtil.isDeterministic(c.exprNode)) {
+ continue;
+ }
+ RexNode ref = c.exprNode;
+ if (inLHSExprToRHSExprs.containsKey(ref)) {
+
inLHSExprToRHSExprs.get(ref).retainAll(Collections.singleton(c.constNode));
+ if (!inLHSExprToRHSExprs.containsKey(ref)) {
+ // Note that Multimap does not keep a key if all its values
are removed.
+ // Hence, since there are no common expressions and it is
within an AND,
+ // we should return false
+ return rexBuilder.makeLiteral(false);
Review comment:
Good catch. It seems the problem was already there though. I am
revisiting this logic.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]