soumyakanti3578 commented on code in PR #4330:
URL: https://github.com/apache/hive/pull/4330#discussion_r1198334353


##########
hplsql/src/main/java/org/apache/hive/hplsql/udf/Udf.java:
##########
@@ -66,48 +64,23 @@ public ObjectInspector initialize(ObjectInspector[] 
arguments) throws UDFArgumen
     if (!(arguments[0] instanceof StringObjectInspector)) {
       throw new UDFArgumentException("First argument must be a string");
     }
-    SessionState sessionState = SessionState.get();
-    if (sessionState != null) {
-      // we are still in HiveServer, get the source of the HplSQL function and 
store it.
-      functionDefinition = loadSource(sessionState, 
functionName(arguments[0]));
-    }
     queryOI = (StringObjectInspector)arguments[0];
+    funcDefOI = (StringObjectInspector)arguments[arguments.length-1];
     argumentsOI = arguments;
     return PrimitiveObjectInspectorFactory.javaStringObjectInspector;
   }
 
-  protected String loadSource(SessionState sessionState, String functionName) 
throws UDFArgumentException {
-    Exec exec = sessionState.getDynamicVar(Exec.class);
-    try {
-      StoredProcedure storedProcedure = exec.getMsc().getStoredProcedure(
-              new StoredProcedureRequest(
-                      SessionState.get().getCurrentCatalog(),
-                      SessionState.get().getCurrentDatabase(),
-                      functionName));
-      return storedProcedure != null ? storedProcedure.getSource() : null;
-    } catch (TException e) {
-      throw new UDFArgumentException(e);
-    }
-  }
-
-  protected String functionName(ObjectInspector argument) {
-    ConstantObjectInspector inspector = (ConstantObjectInspector) (argument);
-    String functionCall = inspector.getWritableConstantValue().toString();
-    return functionCall.split("\\(")[0].toUpperCase();
-  }
-
   /**
    * Execute UDF
    */
   @Override
   public Object evaluate(DeferredObject[] arguments) throws HiveException {
-    if (exec == null) {
-      exec = new Exec();
-      exec.setQueryExecutor(QueryExecutor.DISABLED);
-      exec.init();
-      if (functionDefinition != null) { // if it's null, it can be a built-in 
function
-        exec.parseAndEval(Arguments.script(functionDefinition));
-      }
+    if (functionDefinition == null) { // if it's null, it can be a built-in 
function
+      int idx = arguments.length-1;
+      setParameterForPrimitiveTypeArgument(":" + idx, arguments[idx].get(), 
funcDefOI);
+      functionDefinition = 
funcDefOI.getPrimitiveJavaObject(arguments[idx].get());
+      LOG.info("functionDefinition: {}", functionDefinition);

Review Comment:
   I will change it to DEBUG 👍🏼 



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