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/07/31 01:15:00 UTC

[GitHub] [hive] jcamachor commented on a change in pull request #1326: HIVE-23941: Refactor TypeCheckProcFactory to be database agnostic

jcamachor commented on a change in pull request #1326:
URL: https://github.com/apache/hive/pull/1326#discussion_r463353432



##########
File path: ql/src/java/org/apache/hadoop/hive/ql/parse/type/TypeCheckProcFactory.java
##########
@@ -868,17 +849,15 @@ protected T getXpathOrFuncExprNodeDesc(ASTNode node,
       String funcText = getFunctionText(node, isFunction);
       T expr;
       if (funcText.equals(".")) {
-        // "." : FIELD Expression
-
         assert (children.size() == 2);
         // Only allow constant field name for now
         assert (exprFactory.isConstantExpr(children.get(1)));
         T object = children.get(0);
-
+       

Review comment:
       nit. whitespace (there are a few below too)

##########
File path: ql/src/java/org/apache/hadoop/hive/ql/parse/type/TypeCheckProcFactory.java
##########
@@ -1063,19 +1007,20 @@ protected T getXpathOrFuncExprNodeDesc(ASTNode node,
           if (numEntries == 1) {
             children.addAll(expressions.asMap().values().iterator().next());
             funcText = "in";
-            genericUDF = new GenericUDFIn();
+            fi = exprFactory.getFunctionInfo("in");
           } else {
+            FunctionInfo inFunctionInfo  = exprFactory.getFunctionInfo("in");
             for (Collection<T> c : expressions.asMap().values()) {
-              newExprs.add(
-                  exprFactory.createFuncCallExpr(
-                      new GenericUDFIn(), "in", (List<T>) c));
+              newExprs.add(exprFactory.createFuncCallExpr(null, inFunctionInfo,
+	          "in", (List<T>) c));
             }
             children.addAll(newExprs);
             funcText = "or";
-            genericUDF = new GenericUDFOPOr();
+            fi = exprFactory.getFunctionInfo("or");
+	    functionInfoChangedFromIn = true;

Review comment:
       nit. indentation off here too

##########
File path: ql/src/java/org/apache/hadoop/hive/ql/parse/type/HiveFunctionHelper.java
##########
@@ -545,4 +551,67 @@ public RexNode foldExpression(RexNode expr) {
     return result.get(0);
   }
 
+  /**
+   * {@inheritDoc}
+   */
+  @Override
+  public boolean isAndFunction(FunctionInfo fi) {
+    return fi.getGenericUDF() instanceof GenericUDFOPAnd;
+  }
+
+  /**
+   * {@inheritDoc}
+   */
+  @Override
+  public boolean isOrFunction(FunctionInfo fi) {
+    return fi.getGenericUDF() instanceof GenericUDFOPOr;
+  }
+
+  /**
+   * {@inheritDoc}
+   */
+  @Override
+  public boolean isInFunction(FunctionInfo fi) {
+    return fi.getGenericUDF() instanceof GenericUDFIn;
+  }
+
+  /**
+   * {@inheritDoc}
+   */
+  @Override
+  public boolean isCompareFunction(FunctionInfo fi) {
+    return fi.getGenericUDF() instanceof GenericUDFBaseCompare;
+  }
+
+  /**
+   * {@inheritDoc}
+   */
+  @Override
+  public boolean isEqualFunction(FunctionInfo fi) {
+    return fi.getGenericUDF() instanceof GenericUDFOPEqual
+        && !(fi.getGenericUDF() instanceof GenericUDFOPEqualNS);
+  }
+
+  /**
+   * {@inheritDoc}
+   */
+  @Override
+  public boolean isConsistentWithinQuery(FunctionInfo fi) {
+    //TODO: don't getGenericUDF
+    return FunctionRegistry.isConsistentWithinQuery(fi.getGenericUDF());
+  }
+
+  /**
+   * {@inheritDoc}
+   */
+  @Override
+  public boolean isStateful(FunctionInfo fi) {
+    //TODO: don't getGenericUDF

Review comment:
       This TODO? Is there a follow-up?

##########
File path: ql/src/java/org/apache/hadoop/hive/ql/parse/type/FunctionHelper.java
##########
@@ -82,6 +82,20 @@ default RexNode foldExpression(RexNode expr) {
     return expr;
   }
 
+  boolean isAndFunction(FunctionInfo fi);

Review comment:
       Would you mind to add a short comment to all these methods, even if may seem obvious for some of them?

##########
File path: ql/src/java/org/apache/hadoop/hive/ql/exec/HiveFunctionInfo.java
##########
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hive.ql.exec;
+
+import org.apache.hadoop.hive.ql.udf.generic.GenericUDF;
+import org.apache.hadoop.hive.ql.udf.generic.GenericUDTF;
+import org.apache.hadoop.hive.ql.udf.ptf.TableFunctionResolver;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * HiveFunctionInfo.

Review comment:
       `FunctionInfo implementation for Hive.` ?

##########
File path: ql/src/java/org/apache/hadoop/hive/ql/parse/type/HiveFunctionHelper.java
##########
@@ -545,4 +551,67 @@ public RexNode foldExpression(RexNode expr) {
     return result.get(0);
   }
 
+  /**
+   * {@inheritDoc}
+   */
+  @Override
+  public boolean isAndFunction(FunctionInfo fi) {
+    return fi.getGenericUDF() instanceof GenericUDFOPAnd;
+  }
+
+  /**
+   * {@inheritDoc}
+   */
+  @Override
+  public boolean isOrFunction(FunctionInfo fi) {
+    return fi.getGenericUDF() instanceof GenericUDFOPOr;
+  }
+
+  /**
+   * {@inheritDoc}
+   */
+  @Override
+  public boolean isInFunction(FunctionInfo fi) {
+    return fi.getGenericUDF() instanceof GenericUDFIn;
+  }
+
+  /**
+   * {@inheritDoc}
+   */
+  @Override
+  public boolean isCompareFunction(FunctionInfo fi) {
+    return fi.getGenericUDF() instanceof GenericUDFBaseCompare;
+  }
+
+  /**
+   * {@inheritDoc}
+   */
+  @Override
+  public boolean isEqualFunction(FunctionInfo fi) {
+    return fi.getGenericUDF() instanceof GenericUDFOPEqual
+        && !(fi.getGenericUDF() instanceof GenericUDFOPEqualNS);
+  }
+
+  /**
+   * {@inheritDoc}
+   */
+  @Override
+  public boolean isConsistentWithinQuery(FunctionInfo fi) {
+    //TODO: don't getGenericUDF

Review comment:
       This TODO? Is there a follow-up?

##########
File path: 4cf072b.diff
##########
@@ -0,0 +1,975 @@
+From 4cf072b81a591c4ab31a11c959149edb3d82d569 Mon Sep 17 00:00:00 2001

Review comment:
       Can we remove this file? :)

##########
File path: ql/src/java/org/apache/hadoop/hive/ql/parse/type/TypeCheckProcFactory.java
##########
@@ -1018,15 +958,19 @@ protected T getXpathOrFuncExprNodeDesc(ASTNode node,
           if (newChild == null) {
             // non-interpretable as target type...
             // TODO: all comparisons with null should result in null
-            if (genericUDF instanceof GenericUDFOPEqual
-                && !(genericUDF instanceof GenericUDFOPEqualNS)) {
+            if (exprFactory.isEqualFunction(fi)) {
               return exprFactory.createBooleanConstantExpr(null);
             }
           } else {
             children.set(constIdx, newChild);
           }
         }
-        if (genericUDF instanceof GenericUDFIn) {
+	// The "in" function is sometimes changed to an "or".  Later on, the "or"

Review comment:
       nit. indentation




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