ggangadharan commented on code in PR #6402:
URL: https://github.com/apache/hive/pull/6402#discussion_r3023761383


##########
ql/src/java/org/apache/hadoop/hive/ql/parse/type/HiveFunctionHelper.java:
##########
@@ -346,8 +347,14 @@ public Void visitCall(final RexCall call) {
         GenericUDF nodeUDF = SqlFunctionConverter.getHiveUDF(
             call.getOperator(), call.getType(), call.getOperands().size());
         if (nodeUDF == null) {
+          // Some internal Calcite operators (e.g. COMPONENT_ACCESS used for 
nested field access over
+          // collections) are not backed by a Hive GenericUDF. They are not 
stateful and should not
+          // fail query compilation; still recurse into operands to find any 
stateful expressions.
+          if (call.getOperator() == HiveComponentAccess.COMPONENT_ACCESS) {
+            return super.visitCall(call);
+          }
           throw new AssertionError("Cannot retrieve function " + 
call.getOperator().getName()
-              + " within StatefulFunctionsChecker");
+                  + " (kind=" + call.getOperator().getKind() + ") within 
StatefulFunctionsChecker");
         }

Review Comment:
   updated like below as requested . 
   
   ```
     private void checkForStatefulFunctions(List<RexNode> exprs)
         throws SemanticException {
       RexVisitor<Void> visitor = new RexVisitorImpl<Void>(true) {
         @Override
         public Void visitCall(final RexCall call) {
           // TODO: We should be able to annotate functions in Calcite as 
stateful
           // so we do not have to map back and forth to Hive functions when we 
are
           // doing this check.
           GenericUDF nodeUDF = SqlFunctionConverter.getHiveUDF(
               call.getOperator(), call.getType(), call.getOperands().size());
           if (nodeUDF != null && FunctionRegistry.isStateful(nodeUDF)) {
             throw new Util.FoundOne(call);
           }
           return super.visitCall(call);
         }
       };
   
       try {
         for (RexNode expr : exprs) {
           expr.accept(visitor);
         }
       } catch (Util.FoundOne e) {
         throw new SemanticException("Stateful expressions cannot be used 
inside of CASE");
       }
     }
   ```



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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to