[
https://issues.apache.org/jira/browse/BEAM-9953?focusedWorklogId=455125&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-455125
]
ASF GitHub Bot logged work on BEAM-9953:
----------------------------------------
Author: ASF GitHub Bot
Created on: 06/Jul/20 22:45
Start Date: 06/Jul/20 22:45
Worklog Time Spent: 10m
Work Description: amaliujia commented on a change in pull request #12169:
URL: https://github.com/apache/beam/pull/12169#discussion_r450517162
##########
File path:
sdks/java/extensions/sql/zetasql/src/main/java/org/apache/beam/sdk/extensions/sql/zetasql/translation/TVFScanConverter.java
##########
@@ -42,45 +42,57 @@
@Override
public RelNode convert(ResolvedTVFScan zetaNode, List<RelNode> inputs) {
RelNode input = inputs.get(0);
+ RexCall call =
+ getExpressionConverter()
+ .convertTableValuedFunction(
+ input,
+ zetaNode.getTvf(),
+ zetaNode.getArgumentList(),
+ zetaNode.getArgumentList().get(0).getScan() != null
+ ?
zetaNode.getArgumentList().get(0).getScan().getColumnList()
+ : Collections.emptyList());
RelNode tableFunctionScan =
LogicalTableFunctionScan.create(
- getCluster(),
- inputs,
- getExpressionConverter()
- .convertTableValuedFunction(
- input,
- zetaNode.getTvf(),
- zetaNode.getArgumentList(),
-
zetaNode.getArgumentList().get(0).getScan().getColumnList()),
- null,
- createRowTypeWithWindowStartAndEnd(input.getRowType()),
- Collections.EMPTY_SET);
+ getCluster(), inputs, call, null, call.getType(),
Collections.EMPTY_SET);
+ // Pure SQL UDF's language body is built bottom up, so
FunctionArgumentRefMapping should be
+ // already consumed thus it can be cleared now.
+ context.clearFunctionArgumentRefMapping();
Review comment:
The SQL plan building called from top, but built from bottom.
In this case, TVFScanConverter will be called first, where it knows what
values of function parameters used in later SELECT, so we add those parameters
to Context. Then it goes down to inputs of TVFScanConverter. For pure SQL
UDTVF, per definition, inputs of TVFScanConverter are UDTVF's SQL language
body, which are also ResolvedNode, and FuncitonArugmentRefMapping is consumed.
After the conversion goes back to TVFScanConverter, which means its input has
finished conversion (thus has consumed FuncitonArugmentRefMapping), thus
`FuncitonArugmentRefMapping` can be cleared.
The current implementation in this PR is still fragile. For example, if
there are more than one TVFScanConverter, I am thinking current implementation
will break. So my nest step is to improve testing coverage and catch more
complicated cases.
----------------------------------------------------------------
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: 455125)
Time Spent: 2h 40m (was: 2.5h)
> 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: 2h 40m
> 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)