ibzib commented on a change in pull request #13200:
URL: https://github.com/apache/beam/pull/13200#discussion_r513097589



##########
File path: 
sdks/java/extensions/sql/zetasql/src/main/java/org/apache/beam/sdk/extensions/sql/zetasql/ZetaSQLPlannerImpl.java
##########
@@ -97,22 +102,43 @@ public RelRoot rel(String sql, QueryParameters params) {
     SimpleCatalog catalog =
         analyzer.createPopulatedCatalog(defaultSchemaPlus.getName(), options, 
tables);
 
-    ImmutableMap.Builder<String, ResolvedCreateFunctionStmt> udfBuilder = 
ImmutableMap.builder();
+    ImmutableMap.Builder<List<String>, ResolvedCreateFunctionStmt> udfBuilder =
+        ImmutableMap.builder();
     ImmutableMap.Builder<List<String>, ResolvedNode> udtvfBuilder = 
ImmutableMap.builder();
+    ImmutableMap.Builder<List<String>, Method> javaScalarFunctionBuilder = 
ImmutableMap.builder();
+    ImmutableMap.Builder<List<String>, Combine.CombineFn> 
javaAggregateFunctionBuilder =
+        ImmutableMap.builder();
+    JavaUdfLoader javaUdfLoader = new JavaUdfLoader();
 
     ResolvedStatement statement;
     ParseResumeLocation parseResumeLocation = new ParseResumeLocation(sql);
     do {
       statement = analyzer.analyzeNextStatement(parseResumeLocation, options, 
catalog);
       if (statement.nodeKind() == RESOLVED_CREATE_FUNCTION_STMT) {
         ResolvedCreateFunctionStmt createFunctionStmt = 
(ResolvedCreateFunctionStmt) statement;
-        // ResolvedCreateFunctionStmt does not include the full function name, 
so build it here.
-        String functionFullName =
-            String.format(
-                "%s:%s",
-                SqlAnalyzer.USER_DEFINED_FUNCTIONS,
-                String.join(".", createFunctionStmt.getNamePath()));
-        udfBuilder.put(functionFullName, createFunctionStmt);
+        if (createFunctionStmt.getLanguage().toUpperCase().equals("SQL")) {
+          udfBuilder.put(createFunctionStmt.getNamePath(), createFunctionStmt);
+        } else if 
(createFunctionStmt.getLanguage().toUpperCase().equals("JAVA")) {

Review comment:
       I exposed `SqlAnalyzer.getFunctionGroup` for this purpose.

##########
File path: 
sdks/java/extensions/sql/zetasql/src/main/java/org/apache/beam/sdk/extensions/sql/zetasql/ZetaSQLPlannerImpl.java
##########
@@ -97,22 +102,43 @@ public RelRoot rel(String sql, QueryParameters params) {
     SimpleCatalog catalog =
         analyzer.createPopulatedCatalog(defaultSchemaPlus.getName(), options, 
tables);
 
-    ImmutableMap.Builder<String, ResolvedCreateFunctionStmt> udfBuilder = 
ImmutableMap.builder();
+    ImmutableMap.Builder<List<String>, ResolvedCreateFunctionStmt> udfBuilder =
+        ImmutableMap.builder();
     ImmutableMap.Builder<List<String>, ResolvedNode> udtvfBuilder = 
ImmutableMap.builder();
+    ImmutableMap.Builder<List<String>, Method> javaScalarFunctionBuilder = 
ImmutableMap.builder();
+    ImmutableMap.Builder<List<String>, Combine.CombineFn> 
javaAggregateFunctionBuilder =
+        ImmutableMap.builder();
+    JavaUdfLoader javaUdfLoader = new JavaUdfLoader();
 
     ResolvedStatement statement;
     ParseResumeLocation parseResumeLocation = new ParseResumeLocation(sql);
     do {
       statement = analyzer.analyzeNextStatement(parseResumeLocation, options, 
catalog);
       if (statement.nodeKind() == RESOLVED_CREATE_FUNCTION_STMT) {
         ResolvedCreateFunctionStmt createFunctionStmt = 
(ResolvedCreateFunctionStmt) statement;
-        // ResolvedCreateFunctionStmt does not include the full function name, 
so build it here.
-        String functionFullName =
-            String.format(
-                "%s:%s",
-                SqlAnalyzer.USER_DEFINED_FUNCTIONS,
-                String.join(".", createFunctionStmt.getNamePath()));
-        udfBuilder.put(functionFullName, createFunctionStmt);
+        if (createFunctionStmt.getLanguage().toUpperCase().equals("SQL")) {

Review comment:
       ditto




----------------------------------------------------------------
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:
us...@infra.apache.org


Reply via email to