davidzollo commented on code in PR #10489:
URL: https://github.com/apache/seatunnel/pull/10489#discussion_r2883952400


##########
seatunnel-transforms-v2/src/main/java/org/apache/seatunnel/transform/sql/zeta/ZetaSQLEngine.java:
##########
@@ -84,15 +87,37 @@ public void init(
         this.inputRowType = inputRowType;
         this.sql = sql;
 
-        List<ZetaUDF> udfList = new ArrayList<>();
-        ClassLoader classLoader = 
Thread.currentThread().getContextClassLoader();
-        ServiceLoader.load(ZetaUDF.class, classLoader).forEach(udfList::add);
+        udfList = loadUDFs();
+        udfContext = new ZetaUDFContext();
 
         this.zetaSQLType = new ZetaSQLType(inputRowType, udfList);
-        this.zetaSQLFunction = new ZetaSQLFunction(inputRowType, zetaSQLType, 
udfList);
+        this.zetaSQLFunction = new ZetaSQLFunction(inputRowType, zetaSQLType, 
udfList, udfContext);
         this.zetaSQLFilter = new ZetaSQLFilter(zetaSQLFunction, zetaSQLType);
 
         parseSQL();
+        openUDFs();
+    }
+
+    protected List<ZetaUDF> loadUDFs() {
+        List<ZetaUDF> loadedUdfs = new ArrayList<>();
+        ClassLoader classLoader = 
Thread.currentThread().getContextClassLoader();
+        ServiceLoader.load(ZetaUDF.class, 
classLoader).forEach(loadedUdfs::add);
+        return loadedUdfs;
+    }
+
+    private void openUDFs() {
+        for (int i = 0; i < udfList.size(); i++) {
+            ZetaUDF udf = udfList.get(i);
+            try {
+                udf.open();
+            } catch (Exception e) {
+                closeUDFs(i - 1);

Review Comment:
   ```suggestion
                   closeUDFs(i - 1);
                   log.error("Open udf {} failed", udf.functionName(), e);
   ```



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

Reply via email to