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



##########
File path: 
sdks/java/extensions/sql/zetasql/src/main/java/org/apache/beam/sdk/extensions/sql/zetasql/SqlAnalyzer.java
##########
@@ -116,6 +139,51 @@ static boolean isEndOfInput(ParseResumeLocation 
parseResumeLocation) {
     return tables.build();
   }
 
+  /** Returns the fully qualified name of the function defined in {@code 
statement}. */
+  static String getFunctionQualifiedName(ResolvedCreateFunctionStmt 
createFunctionStmt) {
+    return String.format(
+        "%s:%s",
+        getFunctionGroup(createFunctionStmt), String.join(".", 
createFunctionStmt.getNamePath()));
+  }
+
+  static String getFunctionGroup(ResolvedCreateFunctionStmt 
createFunctionStmt) {
+    switch (createFunctionStmt.getLanguage().toUpperCase()) {
+      case "JAVA":
+        return createFunctionStmt.getIsAggregate()
+            ? USER_DEFINED_JAVA_AGGREGATE_FUNCTIONS
+            : USER_DEFINED_JAVA_SCALAR_FUNCTIONS;
+      case "SQL":
+        if (createFunctionStmt.getIsAggregate()) {
+          throw new UnsupportedOperationException(
+              "Native SQL aggregate functions are not supported (BEAM-9954).");
+        }
+        return USER_DEFINED_FUNCTIONS;
+      case "PY":
+      case "PYTHON":
+      case "JS":
+      case "JAVASCRIPT":
+        throw new UnsupportedOperationException(
+            String.format(
+                "Function %s uses unsupported language %s.",
+                String.join(".", createFunctionStmt.getNamePath()),
+                createFunctionStmt.getLanguage()));
+      default:
+        throw new IllegalArgumentException(
+            String.format(
+                "Function %s uses unrecognized language %s.",
+                String.join(".", createFunctionStmt.getNamePath()),
+                createFunctionStmt.getLanguage()));
+    }
+  }
+
+  private Function createFunction(ResolvedCreateFunctionStmt 
createFunctionStmt) {
+    return new Function(
+        createFunctionStmt.getNamePath(),
+        getFunctionGroup(createFunctionStmt),
+        createFunctionStmt.getIsAggregate() ? Mode.AGGREGATE : Mode.SCALAR,

Review comment:
       This method is for `ResolvedCreateFunctionStmt`. 
`ResolvedCreateTableFunctionStmt` is a separate class altogether.




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