[ https://issues.apache.org/jira/browse/HIVE-24154?focusedWorklogId=484562&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-484562 ]
ASF GitHub Bot logged work on HIVE-24154: ----------------------------------------- Author: ASF GitHub Bot Created on: 15/Sep/20 15:37 Start Date: 15/Sep/20 15:37 Worklog Time Spent: 10m Work Description: kgyrtkirk commented on a change in pull request #1492: URL: https://github.com/apache/hive/pull/1492#discussion_r488766066 ########## 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: I think this may not neccessarily false; consider: ``` x=1 and x=2 ``` which is `not true`; but in case `x is null` - the result of the `AND` will be `null` instead of false this could be only rewritten to `x is null and null`; but even in that case there could be other stuff which might affect null/false; so I think we may not do a return here. ---------------------------------------------------------------- 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: us...@infra.apache.org Issue Time Tracking ------------------- Worklog Id: (was: 484562) Time Spent: 1h 20m (was: 1h 10m) > Missing simplification opportunity with IN and EQUALS clauses > ------------------------------------------------------------- > > Key: HIVE-24154 > URL: https://issues.apache.org/jira/browse/HIVE-24154 > Project: Hive > Issue Type: Improvement > Components: CBO > Reporter: Jesus Camacho Rodriguez > Assignee: Jesus Camacho Rodriguez > Priority: Minor > Labels: pull-request-available > Time Spent: 1h 20m > Remaining Estimate: 0h > > For instance, in perf driver CBO query 74, there are several filters that > could be simplified further: > {code} > HiveFilter(condition=[AND(=($1, 1999), IN($1, 1998, 1999))]) > {code} > This may lead to incorrect estimates and leads to unnecessary execution time. -- This message was sent by Atlassian Jira (v8.3.4#803005)