[
https://issues.apache.org/jira/browse/BEAM-9953?focusedWorklogId=453649&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-453649
]
ASF GitHub Bot logged work on BEAM-9953:
----------------------------------------
Author: ASF GitHub Bot
Created on: 01/Jul/20 20:47
Start Date: 01/Jul/20 20:47
Worklog Time Spent: 10m
Work Description: ibzib commented on a change in pull request #12153:
URL: https://github.com/apache/beam/pull/12153#discussion_r448607767
##########
File path:
sdks/java/extensions/sql/zetasql/src/main/java/org/apache/beam/sdk/extensions/sql/zetasql/ZetaSQLPlannerImpl.java
##########
@@ -130,30 +135,57 @@ public RelRoot rel(SqlNode sqlNode) throws
RelConversionException {
}
public RelRoot rel(String sql, QueryParameters params) {
- this.cluster = RelOptCluster.create(planner, new RexBuilder(typeFactory));
- this.expressionConverter = new ExpressionConverter(cluster, params);
+ RelOptCluster cluster = RelOptCluster.create(planner, new
RexBuilder(typeFactory));
QueryTrait trait = new QueryTrait();
- // Set up table providers that need to be pre-registered
- // TODO(https://issues.apache.org/jira/browse/BEAM-8817): share this logic
between dialects
- List<List<String>> tables = Analyzer.extractTableNamesFromStatement(sql);
- TableResolution.registerTables(this.defaultSchemaPlus, tables);
-
- ResolvedStatement statement =
+ SqlAnalyzer analyzer =
SqlAnalyzer.getBuilder()
.withQueryParams(params)
.withQueryTrait(trait)
.withCalciteContext(config.getContext())
.withTopLevelSchema(defaultSchemaPlus)
.withTypeFactory((JavaTypeFactory) cluster.getTypeFactory())
- .analyze(sql);
+ .build();
+
+ AnalyzerOptions options = SqlAnalyzer.initAnalyzerOptions(params);
+
+ // Set up table providers that need to be pre-registered
+ List<List<String>> tables = analyzer.extractTableNames(sql, options);
+ TableResolution.registerTables(this.defaultSchemaPlus, tables);
+ SimpleCatalog catalog =
+ analyzer.createPopulatedCatalog(defaultSchemaPlus.getName(), options,
tables);
+
+ ImmutableMap.Builder<String, ResolvedCreateFunctionStmt> udfBuilder =
ImmutableMap.builder();
+
+ 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.
Review comment:
ResolvedCreateFunctionStmt contains the path as a list of strings, while
we need the whole path as a single string.
----------------------------------------------------------------
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]
Issue Time Tracking
-------------------
Worklog Id: (was: 453649)
Time Spent: 50m (was: 40m)
> Beam ZetaSQL supports multiple statements in a query
> ----------------------------------------------------
>
> Key: BEAM-9953
> URL: https://issues.apache.org/jira/browse/BEAM-9953
> Project: Beam
> Issue Type: Task
> Components: dsl-sql-zetasql
> Reporter: Rui Wang
> Assignee: Kyle Weaver
> Priority: P2
> Time Spent: 50m
> Remaining Estimate: 0h
>
> One example of multiple statements query:
> {code:java}
> CREATE FUNCTION fun_a (param_1 INT64); SELECT fun_a(10);
> {code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)