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 2021/01/28 13:28:30 UTC

[GitHub] [hive] pgaref commented on a change in pull request #1726: HIVE-24458: Add a method to provide a non-normalized ExpressionTree

pgaref commented on a change in pull request #1726:
URL: https://github.com/apache/hive/pull/1726#discussion_r566060211



##########
File path: ql/src/test/org/apache/hadoop/hive/ql/io/sarg/TestSearchArgumentImpl.java
##########
@@ -85,100 +89,101 @@ public static PredicateLeaf createPredicateLeaf(PredicateLeaf.Operator operator,
   @Test
   public void testNotPushdown() throws Exception {
     assertEquals("leaf-1", SearchArgumentImpl.BuilderImpl.pushDownNot(leaf(1))
-        .toString());
+        .toOldString());
     assertEquals("(not leaf-1)",
-        SearchArgumentImpl.BuilderImpl.pushDownNot(not(leaf(1))).toString());
+        SearchArgumentImpl.BuilderImpl.pushDownNot(not(leaf(1))).toOldString());
     assertEquals("leaf-1",
         SearchArgumentImpl.BuilderImpl.pushDownNot(not(not(leaf(1))))
-            .toString());
+            .toOldString());
     assertEquals("(not leaf-1)",
         SearchArgumentImpl.BuilderImpl.pushDownNot(not(not(not(leaf(1))))).
-            toString());
+            toOldString());
     assertEquals("(or leaf-1 (not leaf-2))",
         SearchArgumentImpl.BuilderImpl.pushDownNot(not(and(not(leaf(1)),
-            leaf(2)))).toString());
+            leaf(2)))).toOldString());
     assertEquals("(and (not leaf-1) leaf-2)",
         SearchArgumentImpl.BuilderImpl.pushDownNot(not(or(leaf(1),
-            not(leaf(2))))).toString());
+            not(leaf(2))))).toOldString());
     assertEquals("(or (or (not leaf-1) leaf-2) leaf-3)",
         SearchArgumentImpl.BuilderImpl.pushDownNot(or(not(and(leaf(1),
                 not(leaf(2)))),
-            not(not(leaf(3))))).toString());
+            not(not(leaf(3))))).toOldString());
     assertEquals("NO", SearchArgumentImpl.BuilderImpl.pushDownNot(
-        not(constant(TruthValue.YES))).toString());
+        not(constant(TruthValue.YES))).toOldString());
     assertEquals("YES", SearchArgumentImpl.BuilderImpl.pushDownNot(
-        not(constant(TruthValue.NO))).toString());
+        not(constant(TruthValue.NO))).toOldString());
     assertEquals("NULL", SearchArgumentImpl.BuilderImpl.pushDownNot(
-        not(constant(TruthValue.NULL))).toString());
+        not(constant(TruthValue.NULL))).toOldString());
     assertEquals("YES_NO", SearchArgumentImpl.BuilderImpl.pushDownNot(
-        not(constant(TruthValue.YES_NO))).toString());
+        not(constant(TruthValue.YES_NO))).toOldString());
     assertEquals("YES_NULL", SearchArgumentImpl.BuilderImpl.pushDownNot(
-        not(constant(TruthValue.NO_NULL))).toString());
+        not(constant(TruthValue.NO_NULL))).toOldString());
     assertEquals("NO_NULL", SearchArgumentImpl.BuilderImpl.pushDownNot(
-        not(constant(TruthValue.YES_NULL))).toString());
+        not(constant(TruthValue.YES_NULL))).toOldString());
     assertEquals("YES_NO_NULL", SearchArgumentImpl.BuilderImpl.pushDownNot(
-        not(constant(TruthValue.YES_NO_NULL))).toString());
+        not(constant(TruthValue.YES_NO_NULL))).toOldString());
   }
 
   @Test
   public void testFlatten() throws Exception {
-    assertEquals("leaf-1", SearchArgumentImpl.BuilderImpl.flatten(leaf(1)).toString());
+    PredicateLeafImpl leaf1 = new PredicateLeafImpl();

Review comment:
       Unused variable

##########
File path: storage-api/src/java/org/apache/hadoop/hive/ql/io/sarg/ExpressionTree.java
##########
@@ -31,25 +31,25 @@
   public enum Operator {OR, AND, NOT, LEAF, CONSTANT}
   private final Operator operator;
   private final List<ExpressionTree> children;
-  private int leaf;
+  private final SearchArgumentImpl.PredicateLeafImpl leaf;

Review comment:
       This could be changed to PredicateLeaf -- see below

##########
File path: storage-api/src/java/org/apache/hadoop/hive/ql/io/sarg/SearchArgumentImpl.java
##########
@@ -504,28 +493,18 @@ public SearchArgument build() {
         throw new IllegalArgumentException("Failed to end " +
             currentTree.size() + " operations.");
       }
+      ExpressionTree optimized = optimize(root);

Review comment:
       maybe rename vars to compact and normalized ExpressionTree to avoid confusion?

##########
File path: storage-api/src/test/org/apache/hadoop/hive/ql/io/sarg/SearchArgumentFactoryTest.java
##########
@@ -0,0 +1,160 @@
+package org.apache.hadoop.hive.ql.io.sarg;

Review comment:
       Apache License?

##########
File path: storage-api/src/java/org/apache/hadoop/hive/ql/io/sarg/SearchArgument.java
##########
@@ -162,6 +162,13 @@ public boolean isNeeded() {
    */
   public ExpressionTree getExpression();
 
+  /**
+   * Get the expression tree without the normalization to conjunctive normal

Review comment:
       Nit: could also explicitly say in **getExpression** above that it normalizes the expression




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