You are viewing a plain text version of this content. The canonical link for it is here.
Posted to gitbox@hive.apache.org by GitBox <gi...@apache.org> on 2020/09/13 10:28:07 UTC

[GitHub] [hive] kgyrtkirk commented on a change in pull request #1492: HIVE-24154: Missing simplification opportunity with IN and EQUALS cla…

kgyrtkirk commented on a change in pull request #1492:
URL: https://github.com/apache/hive/pull/1492#discussion_r487511233



##########
File path: ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HivePointLookupOptimizerRule.java
##########
@@ -734,6 +721,30 @@ private RexNode useStructIfNeeded(List<? extends RexNode> columns) {
               }
               operands.remove(i);
               --i;
+            } else if (operand.getKind() == SqlKind.EQUALS) {
+              Constraint c = Constraint.of(operand);
+              if (c == null || !HiveCalciteUtil.isDeterministic(c.exprNode)) {
+                continue;
+              }
+              String ref = c.exprNode.toString();
+              stringToExpr.put(ref, c.exprNode);
+              if (inLHSExprToRHSExprs.containsKey(ref)) {
+                String expr = c.constNode.toString();
+                stringToExpr.put(expr, c.constNode);

Review comment:
       note: we have RexNode-s are comparable; this string2expr stuff is not neccessarily needed anymore

##########
File path: ql/src/test/results/clientpositive/perf/tez/constraints/cbo_query74.q.out
##########
@@ -147,7 +147,7 @@ HiveSortLimit(sort0=[$2], sort1=[$0], sort2=[$1], dir0=[ASC], dir1=[ASC], dir2=[
                           HiveProject(ss_sold_date_sk=[$0], ss_customer_sk=[$3], ss_net_paid=[$20])
                             HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
                       HiveProject(d_date_sk=[$0])
-                        HiveFilter(condition=[AND(=($1, 1999), IN($1, 1998, 1999))])
+                        HiveFilter(condition=[=($1, 1999)])

Review comment:
       I see that this patch works - but would have thinked that we didn't need something like this anymore - because IN is opened in an early phase - so Calcite should see a bunch of ANDs and ORs - and if that's true - RexSimplify could make this simplification - and there would be no need to enhance PointLookup...
   
   I wonder how the IN was retained ...or re-created... 

##########
File path: ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HivePointLookupOptimizerRule.java
##########
@@ -599,7 +587,7 @@ public ConstraintGroup(RexNode rexNode) {
           if (constraint == null) {
             throw new SemanticException("Unable to find constraint which was earlier added.");
           }
-          ret.add(constraint.exprNode);
+          ret.add(constraint.constNode);

Review comment:
       oh my; Constrain had it's constructor arguments swapped! what a typo!




----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org