[
https://issues.apache.org/jira/browse/BEAM-9363?focusedWorklogId=432243&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-432243
]
ASF GitHub Bot logged work on BEAM-9363:
----------------------------------------
Author: ASF GitHub Bot
Created on: 08/May/20 20:15
Start Date: 08/May/20 20:15
Worklog Time Spent: 10m
Work Description: amaliujia commented on a change in pull request #10946:
URL: https://github.com/apache/beam/pull/10946#discussion_r422351792
##########
File path:
sdks/java/extensions/sql/zetasql/src/main/java/org/apache/beam/sdk/extensions/sql/zetasql/translation/ExpressionConverter.java
##########
@@ -551,6 +561,60 @@ public RexNode convertResolvedLiteral(ResolvedLiteral
resolvedLiteral) {
return ret;
}
+ public RexCall convertTableValuedFunction(
+ RelNode input,
+ TableValuedFunction tvf,
+ List<ResolvedNodes.ResolvedTVFArgument> argumentList,
+ List<ResolvedColumn> inputTableColumns) {
+ switch (tvf.getName()) {
+ case "TUMBLE":
+ // TUMBLE tvf's second argument is descriptor.
+ ResolvedColumn wmCol =
+
extractWatermarkColumnFromDescriptor(argumentList.get(1).getDescriptorArg());
+ if (wmCol.getType().getKind() != TYPE_TIMESTAMP) {
+ throw new IllegalArgumentException(
+ "Watermarked column should be TIMESTAMP type: "
+ + extractWatermarkColumnNameFromDescriptor(
+ argumentList.get(1).getDescriptorArg()));
+ }
+ return (RexCall)
+ rexBuilder()
+ .makeCall(
+ new SqlWindowTableFunction(SqlKind.TUMBLE.name()),
+ convertRelNodeToRexRangeRef(input),
+ convertWatermarkedResolvedColumnToRexInputRef(wmCol,
inputTableColumns),
+ convertIntervalToRexIntervalLiteral(
+ (ResolvedLiteral) argumentList.get(2).getExpr()));
+ default:
+ throw new UnsupportedOperationException(
+ "Does not support table-valued function: " + tvf.getName());
+ }
+ }
+
+ private RexInputRef convertWatermarkedResolvedColumnToRexInputRef(
+ ResolvedColumn wmCol, List<ResolvedColumn> inputTableColumns) {
+ for (int i = 0; i < inputTableColumns.size(); i++) {
+ if (inputTableColumns.get(i).equals(wmCol)) {
+ return rexBuilder()
+ .makeInputRef(TypeUtils.toRelDataType(rexBuilder(),
wmCol.getType(), false), i);
+ }
+ }
+
+ // ZetaSQL parser guarantees that wmCol can be found from
inputTableColumns.
+ // so it shouldn't reach here.
+ throw new IllegalArgumentException();
Review comment:
I moved comments here to exception as the exception message. I don't
have a concert description for in which normal case it will reach this step. It
could reach this step when ZetaSQL has bugs, but putting something like
"ZetaSQL has bugs to make you reach this exception" sounds not useful neither.
----------------------------------------------------------------
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: 432243)
Time Spent: 3h 20m (was: 3h 10m)
> BeamSQL windowing as TVF
> ------------------------
>
> Key: BEAM-9363
> URL: https://issues.apache.org/jira/browse/BEAM-9363
> Project: Beam
> Issue Type: New Feature
> Components: dsl-sql, dsl-sql-zetasql
> Reporter: Rui Wang
> Assignee: Rui Wang
> Priority: Major
> Time Spent: 3h 20m
> Remaining Estimate: 0h
>
> This Jira tracks the implementation for
> https://s.apache.org/streaming-beam-sql
> TVF is table-valued function, which is a SQL feature that produce a table as
> function's output.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)