amaliujia commented on a change in pull request #12153:
URL: https://github.com/apache/beam/pull/12153#discussion_r448552943
##########
File path:
sdks/java/extensions/sql/zetasql/src/main/java/org/apache/beam/sdk/extensions/sql/zetasql/SqlAnalyzer.java
##########
@@ -107,6 +128,43 @@ ResolvedStatement analyze(String sql) {
return Analyzer.analyzeStatement(sql, options, catalog);
}
+ /**
+ * Accepts the ParseResumeLocation for the current position in the SQL
string. Advances the
+ * ParseResumeLocation to the start of the next statement. Adds user-defined
functions to the
+ * catalog for use in following statements. Returns the resolved AST.
+ */
+ ResolvedStatement analyzeNextStatement(
+ ParseResumeLocation parseResumeLocation, AnalyzerOptions options,
SimpleCatalog catalog) {
+ ResolvedStatement resolvedStatement =
+ Analyzer.analyzeNextStatement(parseResumeLocation, options, catalog);
+ if (resolvedStatement.nodeKind() == RESOLVED_CREATE_FUNCTION_STMT) {
+ ResolvedCreateFunctionStmt createFunctionStmt =
+ (ResolvedCreateFunctionStmt) resolvedStatement;
+ Function userFunction =
+ new Function(
+ createFunctionStmt.getNamePath(),
+ USER_DEFINED_FUNCTIONS,
+ // TODO(BEAM-9954) handle aggregate functions
+ // TODO(BEAM-9969) handle table functions
+ Mode.SCALAR,
+
com.google.common.collect.ImmutableList.of(createFunctionStmt.getSignature()));
+ try {
+ catalog.addFunction(userFunction);
+ } catch (IllegalArgumentException e) {
+ throw new ParseException(
Review comment:
Also there is no test to cover this case. (Is there?)
----------------------------------------------------------------
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:
[email protected]