kgyrtkirk commented on a change in pull request #970: Hive 23100
URL: https://github.com/apache/hive/pull/970#discussion_r408712622
 
 

 ##########
 File path: 
ql/src/java/org/apache/hadoop/hive/ql/parse/type/TypeCheckProcFactory.java
 ##########
 @@ -1050,111 +1070,130 @@ protected T getXpathOrFuncExprNodeDesc(ASTNode expr,
               childrenList.add(child);
             }
           }
-          desc = exprFactory.createFuncCallExpr(genericUDF, funcText, 
childrenList);
+          expr = exprFactory.createFuncCallExpr(genericUDF, funcText, 
childrenList);
         } else if (ctx.isFoldExpr() && 
exprFactory.canConvertCASEIntoCOALESCEFuncCallExpr(genericUDF, children)) {
           // Rewrite CASE into COALESCE
-          desc = exprFactory.createFuncCallExpr(new GenericUDFCoalesce(), null,
+          expr = exprFactory.createFuncCallExpr(new GenericUDFCoalesce(), 
"coalesce",
               Lists.newArrayList(children.get(0), 
exprFactory.createBooleanConstantExpr(Boolean.FALSE.toString())));
           if 
(Boolean.FALSE.equals(exprFactory.getConstantValue(children.get(1)))) {
-            desc = exprFactory.createFuncCallExpr(new GenericUDFOPNot(), null, 
Lists.newArrayList(desc));
+            expr = exprFactory.createFuncCallExpr(new GenericUDFOPNot(), 
"not", Lists.newArrayList(expr));
           }
         } else {
-          desc = exprFactory.createFuncCallExpr(genericUDF, funcText, 
children);
+          expr = exprFactory.createFuncCallExpr(genericUDF, funcText, 
children);
         }
 
         // If the function is deterministic and the children are constants,
         // we try to fold the expression to remove e.g. cast on constant
-        if (ctx.isFoldExpr() && exprFactory.isFuncCallExpr(desc) &&
+        if (ctx.isFoldExpr() && exprFactory.isFuncCallExpr(expr) &&
             FunctionRegistry.isConsistentWithinQuery(genericUDF) &&
             exprFactory.isAllConstants(children)) {
-          T constantExpr = exprFactory.foldExpr(desc);
+          T constantExpr = exprFactory.foldExpr(expr);
           if (constantExpr != null) {
-            desc = constantExpr;
+            expr = constantExpr;
           }
         }
       }
-      // UDFOPPositive is a no-op.
-      // However, we still create it, and then remove it here, to make sure we
-      // only allow
-      // "+" for numeric types.
-      if (exprFactory.isPOSITIVEFuncCallExpr(desc)) {
-        assert (exprFactory.getExprChildren(desc).size() == 1);
-        desc = exprFactory.getExprChildren(desc).get(0);
+
+      if (exprFactory.isPOSITIVEFuncCallExpr(expr)) {
+        // UDFOPPositive is a no-op.
+        assert (exprFactory.getExprChildren(expr).size() == 1);
+        expr = exprFactory.getExprChildren(expr).get(0);
+      } else if (exprFactory.isNEGATIVEFuncCallExpr(expr)) {
+        // UDFOPNegative should always be folded.
+        assert (exprFactory.getExprChildren(expr).size() == 1);
+        T input = exprFactory.getExprChildren(expr).get(0);
+        if (exprFactory.isConstantExpr(input)) {
 
 Review comment:
   I think this should have happened around 15 lines above - or not?
   are we missing the mapping of UDFOPPositive?

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


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to