You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2021/03/14 08:35:24 UTC
[GitHub] [flink] beyond1920 opened a new pull request #15195: [FLINK-19609][table-planner-blink] Support streaming window join in planner
beyond1920 opened a new pull request #15195:
URL: https://github.com/apache/flink/pull/15195
## What is the purpose of the change
This pull request aims to support streaming WindowJoin in planner.
## Brief change log
- Introduce `StreamPhysicalWindowJoin`
- Update `FlinkChangelogModeInterenceProgram` and `FlinkRelMdWindowProperties` to take `StreamPhysicalWindowJoin` into consideration.
- Introduce `StreamPhysicalWindowJoinRule` to convert `FlinkLogicalJoin` to `StreamPhysicalWindowJoin` if join condition contains window starts equality of input tables and window ends equality of input tables.
## Verifying this change
- UT in `WindowJoinTest`.
## Does this pull request potentially affect one of the following parts:
- Dependencies (does it add or upgrade a dependency): (no)
- The public API, i.e., is any changed class annotated with `@Public(Evolving)`: (no)
- The serializers: (no)
- The runtime per-record code paths (performance sensitive): (no)
- Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn/Mesos, ZooKeeper: (no)
- The S3 file system connector: (no)
## Documentation
- Does this pull request introduce a new feature? (no)
- If yes, how is the feature documented? (not applicable)
----------------------------------------------------------------
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:
users@infra.apache.org
[GitHub] [flink] beyond1920 commented on a change in pull request #15195: [FLINK-19609][table-planner-blink] Support streaming window join in planner
Posted by GitBox <gi...@apache.org>.
beyond1920 commented on a change in pull request #15195:
URL: https://github.com/apache/flink/pull/15195#discussion_r594019149
##########
File path: flink-table/flink-table-planner-blink/src/test/resources/org/apache/flink/table/planner/plan/stream/sql/join/WindowJoinTest.xml
##########
@@ -0,0 +1,1041 @@
+<?xml version="1.0" ?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to you under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+-->
+<Root>
+ <TestCase name="testCantMergeWindowTVF_Cumulate">
+ <Resource name="sql">
+ <![CDATA[
+SELECT L.a, L.b, L.c, R.a, R.b, R.c
+FROM (
+ SELECT *
+ FROM TABLE(
+ CUMULATE(TABLE MyTable, DESCRIPTOR(rowtime), INTERVAL '10' MINUTE, INTERVAL '1' HOUR))
+) L
+JOIN (
+ SELECT *
+ FROM TABLE(
+ CUMULATE(TABLE MyTable2, DESCRIPTOR(rowtime), INTERVAL '10' MINUTE, INTERVAL '1' HOUR))
+) R
+ON L.window_start = R.window_start AND L.window_end = R.window_end AND L.a = R.a
+ ]]>
+ </Resource>
+ <Resource name="ast">
+ <![CDATA[
+LogicalProject(a=[$0], b=[$1], c=[$2], a0=[$8], b0=[$9], c0=[$10])
++- LogicalJoin(condition=[AND(=($5, $13), =($6, $14), =($0, $8))], joinType=[inner])
+ :- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4], window_start=[$5], window_end=[$6], window_time=[$7])
+ : +- LogicalTableFunctionScan(invocation=[CUMULATE($4, DESCRIPTOR($3), 600000:INTERVAL MINUTE, 3600000:INTERVAL HOUR)], rowType=[RecordType(INTEGER a, VARCHAR(2147483647) b, BIGINT c, TIME ATTRIBUTE(ROWTIME) rowtime, TIME ATTRIBUTE(PROCTIME) proctime, TIMESTAMP(3) window_start, TIMESTAMP(3) window_end, TIME ATTRIBUTE(ROWTIME) window_time)])
+ : +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4])
+ : +- LogicalWatermarkAssigner(rowtime=[rowtime], watermark=[-($3, 1000:INTERVAL SECOND)])
+ : +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[PROCTIME()])
+ : +- LogicalTableScan(table=[[default_catalog, default_database, MyTable]])
+ +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4], window_start=[$5], window_end=[$6], window_time=[$7])
+ +- LogicalTableFunctionScan(invocation=[CUMULATE($4, DESCRIPTOR($3), 600000:INTERVAL MINUTE, 3600000:INTERVAL HOUR)], rowType=[RecordType(INTEGER a, VARCHAR(2147483647) b, BIGINT c, TIME ATTRIBUTE(ROWTIME) rowtime, TIME ATTRIBUTE(PROCTIME) proctime, TIMESTAMP(3) window_start, TIMESTAMP(3) window_end, TIME ATTRIBUTE(ROWTIME) window_time)])
+ +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4])
+ +- LogicalWatermarkAssigner(rowtime=[rowtime], watermark=[-($3, 1000:INTERVAL SECOND)])
+ +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[PROCTIME()])
+ +- LogicalTableScan(table=[[default_catalog, default_database, MyTable2]])
+]]>
+ </Resource>
+ <Resource name="optimized rel plan">
+ <![CDATA[
+Calc(select=[a, b, c, a0, b0, c0])
++- WindowJoin(leftWindow=[CUMULATE(win_start=[window_start], win_end=[window_end], max_size=[1 h], step=[10 min])], rightWindow=[CUMULATE(win_start=[window_start], win_end=[window_end], max_size=[1 h], step=[10 min])], joinType=[InnerJoin], where=[=(a, a0)], select=[a, b, c, window_start, window_end, a0, b0, c0, window_start0, window_end0])
Review comment:
Good point! Do we need to throw UnsupportedException in planner, Or just when translate to ExecNode?
----------------------------------------------------------------
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:
users@infra.apache.org
[GitHub] [flink] flinkbot edited a comment on pull request #15195: [FLINK-19609][table-planner-blink] Support streaming window join in planner
Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #15195:
URL: https://github.com/apache/flink/pull/15195#issuecomment-798871942
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "8f844ec2c7ace18f8d6a78efbabea949dd7b9a8c",
"status" : "DELETED",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14614",
"triggerID" : "8f844ec2c7ace18f8d6a78efbabea949dd7b9a8c",
"triggerType" : "PUSH"
}, {
"hash" : "c7a1c712fc6f803918ab49a8e07994e1bc590652",
"status" : "DELETED",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14663",
"triggerID" : "c7a1c712fc6f803918ab49a8e07994e1bc590652",
"triggerType" : "PUSH"
}, {
"hash" : "162ca63148a9c1c924936bc17743f830082d800e",
"status" : "DELETED",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14668",
"triggerID" : "162ca63148a9c1c924936bc17743f830082d800e",
"triggerType" : "PUSH"
}, {
"hash" : "0a79f7d2655ee39ce1bb193bde327b1121b80ff4",
"status" : "DELETED",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14683",
"triggerID" : "0a79f7d2655ee39ce1bb193bde327b1121b80ff4",
"triggerType" : "PUSH"
}, {
"hash" : "7de577188142578d0ed819e2623aedbcb1baccc5",
"status" : "DELETED",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14689",
"triggerID" : "7de577188142578d0ed819e2623aedbcb1baccc5",
"triggerType" : "PUSH"
}, {
"hash" : "44281b2314b6c5bf6b2cfc3387164b9aa7efcc74",
"status" : "SUCCESS",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14706",
"triggerID" : "44281b2314b6c5bf6b2cfc3387164b9aa7efcc74",
"triggerType" : "PUSH"
}, {
"hash" : "693860368d8c271691f65cdd37644d99df7786a5",
"status" : "UNKNOWN",
"url" : "TBD",
"triggerID" : "693860368d8c271691f65cdd37644d99df7786a5",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* 44281b2314b6c5bf6b2cfc3387164b9aa7efcc74 Azure: [SUCCESS](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14706)
* 693860368d8c271691f65cdd37644d99df7786a5 UNKNOWN
<details>
<summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot run travis` re-run the last Travis build
- `@flinkbot run azure` re-run the last Azure build
</details>
----------------------------------------------------------------
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:
users@infra.apache.org
[GitHub] [flink] wuchong commented on a change in pull request #15195: [FLINK-19609][table-planner-blink] Support streaming window join in planner
Posted by GitBox <gi...@apache.org>.
wuchong commented on a change in pull request #15195:
URL: https://github.com/apache/flink/pull/15195#discussion_r594019685
##########
File path: flink-table/flink-table-planner-blink/src/test/resources/org/apache/flink/table/planner/plan/stream/sql/join/WindowJoinTest.xml
##########
@@ -0,0 +1,1041 @@
+<?xml version="1.0" ?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to you under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+-->
+<Root>
+ <TestCase name="testCantMergeWindowTVF_Cumulate">
+ <Resource name="sql">
+ <![CDATA[
+SELECT L.a, L.b, L.c, R.a, R.b, R.c
+FROM (
+ SELECT *
+ FROM TABLE(
+ CUMULATE(TABLE MyTable, DESCRIPTOR(rowtime), INTERVAL '10' MINUTE, INTERVAL '1' HOUR))
+) L
+JOIN (
+ SELECT *
+ FROM TABLE(
+ CUMULATE(TABLE MyTable2, DESCRIPTOR(rowtime), INTERVAL '10' MINUTE, INTERVAL '1' HOUR))
+) R
+ON L.window_start = R.window_start AND L.window_end = R.window_end AND L.a = R.a
+ ]]>
+ </Resource>
+ <Resource name="ast">
+ <![CDATA[
+LogicalProject(a=[$0], b=[$1], c=[$2], a0=[$8], b0=[$9], c0=[$10])
++- LogicalJoin(condition=[AND(=($5, $13), =($6, $14), =($0, $8))], joinType=[inner])
+ :- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4], window_start=[$5], window_end=[$6], window_time=[$7])
+ : +- LogicalTableFunctionScan(invocation=[CUMULATE($4, DESCRIPTOR($3), 600000:INTERVAL MINUTE, 3600000:INTERVAL HOUR)], rowType=[RecordType(INTEGER a, VARCHAR(2147483647) b, BIGINT c, TIME ATTRIBUTE(ROWTIME) rowtime, TIME ATTRIBUTE(PROCTIME) proctime, TIMESTAMP(3) window_start, TIMESTAMP(3) window_end, TIME ATTRIBUTE(ROWTIME) window_time)])
+ : +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4])
+ : +- LogicalWatermarkAssigner(rowtime=[rowtime], watermark=[-($3, 1000:INTERVAL SECOND)])
+ : +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[PROCTIME()])
+ : +- LogicalTableScan(table=[[default_catalog, default_database, MyTable]])
+ +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4], window_start=[$5], window_end=[$6], window_time=[$7])
+ +- LogicalTableFunctionScan(invocation=[CUMULATE($4, DESCRIPTOR($3), 600000:INTERVAL MINUTE, 3600000:INTERVAL HOUR)], rowType=[RecordType(INTEGER a, VARCHAR(2147483647) b, BIGINT c, TIME ATTRIBUTE(ROWTIME) rowtime, TIME ATTRIBUTE(PROCTIME) proctime, TIMESTAMP(3) window_start, TIMESTAMP(3) window_end, TIME ATTRIBUTE(ROWTIME) window_time)])
+ +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4])
+ +- LogicalWatermarkAssigner(rowtime=[rowtime], watermark=[-($3, 1000:INTERVAL SECOND)])
+ +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[PROCTIME()])
+ +- LogicalTableScan(table=[[default_catalog, default_database, MyTable2]])
+]]>
+ </Resource>
+ <Resource name="optimized rel plan">
+ <![CDATA[
+Calc(select=[a, b, c, a0, b0, c0])
++- WindowJoin(leftWindow=[CUMULATE(win_start=[window_start], win_end=[window_end], max_size=[1 h], step=[10 min])], rightWindow=[CUMULATE(win_start=[window_start], win_end=[window_end], max_size=[1 h], step=[10 min])], joinType=[InnerJoin], where=[=(a, a0)], select=[a, b, c, window_start, window_end, a0, b0, c0, window_start0, window_end0])
Review comment:
throwing a readable exception sounds good to me.
----------------------------------------------------------------
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:
users@infra.apache.org
[GitHub] [flink] flinkbot edited a comment on pull request #15195: [FLINK-19609][table-planner-blink] Support streaming window join in planner
Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #15195:
URL: https://github.com/apache/flink/pull/15195#issuecomment-798871942
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "8f844ec2c7ace18f8d6a78efbabea949dd7b9a8c",
"status" : "DELETED",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14614",
"triggerID" : "8f844ec2c7ace18f8d6a78efbabea949dd7b9a8c",
"triggerType" : "PUSH"
}, {
"hash" : "c7a1c712fc6f803918ab49a8e07994e1bc590652",
"status" : "DELETED",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14663",
"triggerID" : "c7a1c712fc6f803918ab49a8e07994e1bc590652",
"triggerType" : "PUSH"
}, {
"hash" : "162ca63148a9c1c924936bc17743f830082d800e",
"status" : "DELETED",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14668",
"triggerID" : "162ca63148a9c1c924936bc17743f830082d800e",
"triggerType" : "PUSH"
}, {
"hash" : "0a79f7d2655ee39ce1bb193bde327b1121b80ff4",
"status" : "DELETED",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14683",
"triggerID" : "0a79f7d2655ee39ce1bb193bde327b1121b80ff4",
"triggerType" : "PUSH"
}, {
"hash" : "7de577188142578d0ed819e2623aedbcb1baccc5",
"status" : "DELETED",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14689",
"triggerID" : "7de577188142578d0ed819e2623aedbcb1baccc5",
"triggerType" : "PUSH"
}, {
"hash" : "44281b2314b6c5bf6b2cfc3387164b9aa7efcc74",
"status" : "SUCCESS",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14706",
"triggerID" : "44281b2314b6c5bf6b2cfc3387164b9aa7efcc74",
"triggerType" : "PUSH"
}, {
"hash" : "693860368d8c271691f65cdd37644d99df7786a5",
"status" : "PENDING",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14861",
"triggerID" : "693860368d8c271691f65cdd37644d99df7786a5",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* 44281b2314b6c5bf6b2cfc3387164b9aa7efcc74 Azure: [SUCCESS](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14706)
* 693860368d8c271691f65cdd37644d99df7786a5 Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14861)
<details>
<summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot run travis` re-run the last Travis build
- `@flinkbot run azure` re-run the last Azure build
</details>
----------------------------------------------------------------
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:
users@infra.apache.org
[GitHub] [flink] flinkbot edited a comment on pull request #15195: [FLINK-19609][table-planner-blink] Support streaming window join in planner
Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #15195:
URL: https://github.com/apache/flink/pull/15195#issuecomment-798871942
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "8f844ec2c7ace18f8d6a78efbabea949dd7b9a8c",
"status" : "DELETED",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14614",
"triggerID" : "8f844ec2c7ace18f8d6a78efbabea949dd7b9a8c",
"triggerType" : "PUSH"
}, {
"hash" : "c7a1c712fc6f803918ab49a8e07994e1bc590652",
"status" : "DELETED",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14663",
"triggerID" : "c7a1c712fc6f803918ab49a8e07994e1bc590652",
"triggerType" : "PUSH"
}, {
"hash" : "162ca63148a9c1c924936bc17743f830082d800e",
"status" : "DELETED",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14668",
"triggerID" : "162ca63148a9c1c924936bc17743f830082d800e",
"triggerType" : "PUSH"
}, {
"hash" : "0a79f7d2655ee39ce1bb193bde327b1121b80ff4",
"status" : "FAILURE",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14683",
"triggerID" : "0a79f7d2655ee39ce1bb193bde327b1121b80ff4",
"triggerType" : "PUSH"
}, {
"hash" : "7de577188142578d0ed819e2623aedbcb1baccc5",
"status" : "PENDING",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14689",
"triggerID" : "7de577188142578d0ed819e2623aedbcb1baccc5",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* 0a79f7d2655ee39ce1bb193bde327b1121b80ff4 Azure: [FAILURE](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14683)
* 7de577188142578d0ed819e2623aedbcb1baccc5 Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14689)
<details>
<summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot run travis` re-run the last Travis build
- `@flinkbot run azure` re-run the last Azure build
</details>
----------------------------------------------------------------
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:
users@infra.apache.org
[GitHub] [flink] flinkbot edited a comment on pull request #15195: [FLINK-19609][table-planner-blink] Support streaming window join in planner
Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #15195:
URL: https://github.com/apache/flink/pull/15195#issuecomment-798871942
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "8f844ec2c7ace18f8d6a78efbabea949dd7b9a8c",
"status" : "DELETED",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14614",
"triggerID" : "8f844ec2c7ace18f8d6a78efbabea949dd7b9a8c",
"triggerType" : "PUSH"
}, {
"hash" : "c7a1c712fc6f803918ab49a8e07994e1bc590652",
"status" : "DELETED",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14663",
"triggerID" : "c7a1c712fc6f803918ab49a8e07994e1bc590652",
"triggerType" : "PUSH"
}, {
"hash" : "162ca63148a9c1c924936bc17743f830082d800e",
"status" : "DELETED",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14668",
"triggerID" : "162ca63148a9c1c924936bc17743f830082d800e",
"triggerType" : "PUSH"
}, {
"hash" : "0a79f7d2655ee39ce1bb193bde327b1121b80ff4",
"status" : "DELETED",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14683",
"triggerID" : "0a79f7d2655ee39ce1bb193bde327b1121b80ff4",
"triggerType" : "PUSH"
}, {
"hash" : "7de577188142578d0ed819e2623aedbcb1baccc5",
"status" : "CANCELED",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14689",
"triggerID" : "7de577188142578d0ed819e2623aedbcb1baccc5",
"triggerType" : "PUSH"
}, {
"hash" : "44281b2314b6c5bf6b2cfc3387164b9aa7efcc74",
"status" : "PENDING",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14706",
"triggerID" : "44281b2314b6c5bf6b2cfc3387164b9aa7efcc74",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* 7de577188142578d0ed819e2623aedbcb1baccc5 Azure: [CANCELED](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14689)
* 44281b2314b6c5bf6b2cfc3387164b9aa7efcc74 Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14706)
<details>
<summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot run travis` re-run the last Travis build
- `@flinkbot run azure` re-run the last Azure build
</details>
----------------------------------------------------------------
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:
users@infra.apache.org
[GitHub] [flink] beyond1920 commented on a change in pull request #15195: [FLINK-19609][table-planner-blink] Support streaming window join in planner
Posted by GitBox <gi...@apache.org>.
beyond1920 commented on a change in pull request #15195:
URL: https://github.com/apache/flink/pull/15195#discussion_r594057866
##########
File path: flink-table/flink-table-planner-blink/src/test/resources/org/apache/flink/table/planner/plan/stream/sql/join/WindowJoinTest.xml
##########
@@ -0,0 +1,1041 @@
+<?xml version="1.0" ?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to you under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+-->
+<Root>
+ <TestCase name="testCantMergeWindowTVF_Cumulate">
+ <Resource name="sql">
+ <![CDATA[
+SELECT L.a, L.b, L.c, R.a, R.b, R.c
+FROM (
+ SELECT *
+ FROM TABLE(
+ CUMULATE(TABLE MyTable, DESCRIPTOR(rowtime), INTERVAL '10' MINUTE, INTERVAL '1' HOUR))
+) L
+JOIN (
+ SELECT *
+ FROM TABLE(
+ CUMULATE(TABLE MyTable2, DESCRIPTOR(rowtime), INTERVAL '10' MINUTE, INTERVAL '1' HOUR))
+) R
+ON L.window_start = R.window_start AND L.window_end = R.window_end AND L.a = R.a
+ ]]>
+ </Resource>
+ <Resource name="ast">
+ <![CDATA[
+LogicalProject(a=[$0], b=[$1], c=[$2], a0=[$8], b0=[$9], c0=[$10])
++- LogicalJoin(condition=[AND(=($5, $13), =($6, $14), =($0, $8))], joinType=[inner])
+ :- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4], window_start=[$5], window_end=[$6], window_time=[$7])
+ : +- LogicalTableFunctionScan(invocation=[CUMULATE($4, DESCRIPTOR($3), 600000:INTERVAL MINUTE, 3600000:INTERVAL HOUR)], rowType=[RecordType(INTEGER a, VARCHAR(2147483647) b, BIGINT c, TIME ATTRIBUTE(ROWTIME) rowtime, TIME ATTRIBUTE(PROCTIME) proctime, TIMESTAMP(3) window_start, TIMESTAMP(3) window_end, TIME ATTRIBUTE(ROWTIME) window_time)])
+ : +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4])
+ : +- LogicalWatermarkAssigner(rowtime=[rowtime], watermark=[-($3, 1000:INTERVAL SECOND)])
+ : +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[PROCTIME()])
+ : +- LogicalTableScan(table=[[default_catalog, default_database, MyTable]])
+ +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4], window_start=[$5], window_end=[$6], window_time=[$7])
+ +- LogicalTableFunctionScan(invocation=[CUMULATE($4, DESCRIPTOR($3), 600000:INTERVAL MINUTE, 3600000:INTERVAL HOUR)], rowType=[RecordType(INTEGER a, VARCHAR(2147483647) b, BIGINT c, TIME ATTRIBUTE(ROWTIME) rowtime, TIME ATTRIBUTE(PROCTIME) proctime, TIMESTAMP(3) window_start, TIMESTAMP(3) window_end, TIME ATTRIBUTE(ROWTIME) window_time)])
+ +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4])
+ +- LogicalWatermarkAssigner(rowtime=[rowtime], watermark=[-($3, 1000:INTERVAL SECOND)])
+ +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[PROCTIME()])
+ +- LogicalTableScan(table=[[default_catalog, default_database, MyTable2]])
+]]>
+ </Resource>
+ <Resource name="optimized rel plan">
+ <![CDATA[
+Calc(select=[a, b, c, a0, b0, c0])
++- WindowJoin(leftWindow=[CUMULATE(win_start=[window_start], win_end=[window_end], max_size=[1 h], step=[10 min])], rightWindow=[CUMULATE(win_start=[window_start], win_end=[window_end], max_size=[1 h], step=[10 min])], joinType=[InnerJoin], where=[=(a, a0)], select=[a, b, c, window_start, window_end, a0, b0, c0, window_start0, window_end0])
Review comment:
Ok. If I understand well, the problem also exists in `WindowJoin`, `WindowAggregate`, `WindowJoin` when input window strategy is `WindowAttachedWindowingStrategy`, and `TimeAttribute` is proc-time at the same time. Right?
----------------------------------------------------------------
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:
users@infra.apache.org
[GitHub] [flink] wuchong merged pull request #15195: [FLINK-19609][table-planner-blink] Support streaming window join in planner
Posted by GitBox <gi...@apache.org>.
wuchong merged pull request #15195:
URL: https://github.com/apache/flink/pull/15195
----------------------------------------------------------------
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:
users@infra.apache.org
[GitHub] [flink] flinkbot edited a comment on pull request #15195: [FLINK-19609][table-planner-blink] Support streaming window join in planner
Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #15195:
URL: https://github.com/apache/flink/pull/15195#issuecomment-798871942
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "8f844ec2c7ace18f8d6a78efbabea949dd7b9a8c",
"status" : "DELETED",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14614",
"triggerID" : "8f844ec2c7ace18f8d6a78efbabea949dd7b9a8c",
"triggerType" : "PUSH"
}, {
"hash" : "c7a1c712fc6f803918ab49a8e07994e1bc590652",
"status" : "DELETED",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14663",
"triggerID" : "c7a1c712fc6f803918ab49a8e07994e1bc590652",
"triggerType" : "PUSH"
}, {
"hash" : "162ca63148a9c1c924936bc17743f830082d800e",
"status" : "PENDING",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14668",
"triggerID" : "162ca63148a9c1c924936bc17743f830082d800e",
"triggerType" : "PUSH"
}, {
"hash" : "0a79f7d2655ee39ce1bb193bde327b1121b80ff4",
"status" : "FAILURE",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14683",
"triggerID" : "0a79f7d2655ee39ce1bb193bde327b1121b80ff4",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* 162ca63148a9c1c924936bc17743f830082d800e Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14668)
* 0a79f7d2655ee39ce1bb193bde327b1121b80ff4 Azure: [FAILURE](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14683)
<details>
<summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot run travis` re-run the last Travis build
- `@flinkbot run azure` re-run the last Azure build
</details>
----------------------------------------------------------------
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:
users@infra.apache.org
[GitHub] [flink] beyond1920 commented on a change in pull request #15195: [FLINK-19609][table-planner-blink] Support streaming window join in planner
Posted by GitBox <gi...@apache.org>.
beyond1920 commented on a change in pull request #15195:
URL: https://github.com/apache/flink/pull/15195#discussion_r594063115
##########
File path: flink-table/flink-table-planner-blink/src/main/scala/org/apache/flink/table/planner/plan/nodes/physical/stream/StreamPhysicalWindowJoin.scala
##########
@@ -0,0 +1,91 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.flink.table.planner.plan.nodes.physical.stream
+
+import org.apache.flink.table.api.TableException
+import org.apache.flink.table.planner.plan.logical.WindowingStrategy
+import org.apache.flink.table.planner.plan.nodes.exec.ExecNode
+import org.apache.flink.table.planner.plan.nodes.physical.common.CommonPhysicalJoin
+import org.apache.flink.table.planner.plan.utils.PythonUtil.containsPythonCall
+import org.apache.flink.table.planner.plan.utils.RelExplainUtil.preferExpressionFormat
+
+import org.apache.calcite.plan.{RelOptCluster, RelTraitSet}
+import org.apache.calcite.rel._
+import org.apache.calcite.rel.core.{Join, JoinRelType}
+import org.apache.calcite.rex.RexNode
+
+import scala.collection.JavaConversions._
+import scala.collection.JavaConverters._
+
+/**
+ * The window join requires the join condition contains window starts equality of
+ * input tables and window ends equality of input tables.
+ * The semantic of window join is the same to the DataStream window join.
+ */
+class StreamPhysicalWindowJoin(
+ cluster: RelOptCluster,
+ traitSet: RelTraitSet,
+ leftRel: RelNode,
+ rightRel: RelNode,
+ joinType: JoinRelType,
+ // remaining join condition contains all of join condition except window starts equality
+ // and window end equality
+ remainingCondition: RexNode,
+ val leftWindowing: WindowingStrategy,
+ val rightWindowing: WindowingStrategy)
Review comment:
done
----------------------------------------------------------------
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:
users@infra.apache.org
[GitHub] [flink] flinkbot edited a comment on pull request #15195: [FLINK-19609][table-planner-blink] Support streaming window join in planner
Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #15195:
URL: https://github.com/apache/flink/pull/15195#issuecomment-798871942
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "8f844ec2c7ace18f8d6a78efbabea949dd7b9a8c",
"status" : "DELETED",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14614",
"triggerID" : "8f844ec2c7ace18f8d6a78efbabea949dd7b9a8c",
"triggerType" : "PUSH"
}, {
"hash" : "c7a1c712fc6f803918ab49a8e07994e1bc590652",
"status" : "DELETED",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14663",
"triggerID" : "c7a1c712fc6f803918ab49a8e07994e1bc590652",
"triggerType" : "PUSH"
}, {
"hash" : "162ca63148a9c1c924936bc17743f830082d800e",
"status" : "DELETED",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14668",
"triggerID" : "162ca63148a9c1c924936bc17743f830082d800e",
"triggerType" : "PUSH"
}, {
"hash" : "0a79f7d2655ee39ce1bb193bde327b1121b80ff4",
"status" : "DELETED",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14683",
"triggerID" : "0a79f7d2655ee39ce1bb193bde327b1121b80ff4",
"triggerType" : "PUSH"
}, {
"hash" : "7de577188142578d0ed819e2623aedbcb1baccc5",
"status" : "DELETED",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14689",
"triggerID" : "7de577188142578d0ed819e2623aedbcb1baccc5",
"triggerType" : "PUSH"
}, {
"hash" : "44281b2314b6c5bf6b2cfc3387164b9aa7efcc74",
"status" : "SUCCESS",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14706",
"triggerID" : "44281b2314b6c5bf6b2cfc3387164b9aa7efcc74",
"triggerType" : "PUSH"
}, {
"hash" : "693860368d8c271691f65cdd37644d99df7786a5",
"status" : "PENDING",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14861",
"triggerID" : "693860368d8c271691f65cdd37644d99df7786a5",
"triggerType" : "PUSH"
}, {
"hash" : "47ef3ba16e9a53261be1fd78014d1cab14bc0cf7",
"status" : "PENDING",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14865",
"triggerID" : "47ef3ba16e9a53261be1fd78014d1cab14bc0cf7",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* 44281b2314b6c5bf6b2cfc3387164b9aa7efcc74 Azure: [SUCCESS](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14706)
* 693860368d8c271691f65cdd37644d99df7786a5 Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14861)
* 47ef3ba16e9a53261be1fd78014d1cab14bc0cf7 Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14865)
<details>
<summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot run travis` re-run the last Travis build
- `@flinkbot run azure` re-run the last Azure build
</details>
----------------------------------------------------------------
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:
users@infra.apache.org
[GitHub] [flink] beyond1920 commented on a change in pull request #15195: [FLINK-19609][table-planner-blink] Support streaming window join in planner
Posted by GitBox <gi...@apache.org>.
beyond1920 commented on a change in pull request #15195:
URL: https://github.com/apache/flink/pull/15195#discussion_r594017123
##########
File path: flink-table/flink-table-planner-blink/src/main/scala/org/apache/flink/table/planner/plan/optimize/program/FlinkChangelogModeInferenceProgram.scala
##########
@@ -266,6 +266,12 @@ class FlinkChangelogModeInferenceProgram extends FlinkOptimizeProgram[StreamOpti
}
createNewNode(join, children, providedTrait, requiredTrait, requester)
+ case windowJoin: StreamPhysicalWindowJoin =>
+ // window join support all changes in input
+ val children = visitChildren(rel, ModifyKindSetTrait.ALL_CHANGES)
Review comment:
OK
----------------------------------------------------------------
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:
users@infra.apache.org
[GitHub] [flink] flinkbot commented on pull request #15195: [FLINK-19609][table-planner-blink] Support streaming window join in planner
Posted by GitBox <gi...@apache.org>.
flinkbot commented on pull request #15195:
URL: https://github.com/apache/flink/pull/15195#issuecomment-798871942
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "8f844ec2c7ace18f8d6a78efbabea949dd7b9a8c",
"status" : "UNKNOWN",
"url" : "TBD",
"triggerID" : "8f844ec2c7ace18f8d6a78efbabea949dd7b9a8c",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* 8f844ec2c7ace18f8d6a78efbabea949dd7b9a8c UNKNOWN
<details>
<summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot run travis` re-run the last Travis build
- `@flinkbot run azure` re-run the last Azure build
</details>
----------------------------------------------------------------
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:
users@infra.apache.org
[GitHub] [flink] beyond1920 commented on pull request #15195: [FLINK-19609][table-planner-blink] Support streaming window join in planner
Posted by GitBox <gi...@apache.org>.
beyond1920 commented on pull request #15195:
URL: https://github.com/apache/flink/pull/15195#issuecomment-800963250
@wuchong Thanks a lot. The update is good.
----------------------------------------------------------------
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:
users@infra.apache.org
[GitHub] [flink] flinkbot edited a comment on pull request #15195: [FLINK-19609][table-planner-blink] Support streaming window join in planner
Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #15195:
URL: https://github.com/apache/flink/pull/15195#issuecomment-798871942
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "8f844ec2c7ace18f8d6a78efbabea949dd7b9a8c",
"status" : "FAILURE",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14614",
"triggerID" : "8f844ec2c7ace18f8d6a78efbabea949dd7b9a8c",
"triggerType" : "PUSH"
}, {
"hash" : "c7a1c712fc6f803918ab49a8e07994e1bc590652",
"status" : "PENDING",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14663",
"triggerID" : "c7a1c712fc6f803918ab49a8e07994e1bc590652",
"triggerType" : "PUSH"
}, {
"hash" : "162ca63148a9c1c924936bc17743f830082d800e",
"status" : "UNKNOWN",
"url" : "TBD",
"triggerID" : "162ca63148a9c1c924936bc17743f830082d800e",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* 8f844ec2c7ace18f8d6a78efbabea949dd7b9a8c Azure: [FAILURE](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14614)
* c7a1c712fc6f803918ab49a8e07994e1bc590652 Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14663)
* 162ca63148a9c1c924936bc17743f830082d800e UNKNOWN
<details>
<summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot run travis` re-run the last Travis build
- `@flinkbot run azure` re-run the last Azure build
</details>
----------------------------------------------------------------
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:
users@infra.apache.org
[GitHub] [flink] wuchong commented on a change in pull request #15195: [FLINK-19609][table-planner-blink] Support streaming window join in planner
Posted by GitBox <gi...@apache.org>.
wuchong commented on a change in pull request #15195:
URL: https://github.com/apache/flink/pull/15195#discussion_r594020680
##########
File path: flink-table/flink-table-planner-blink/src/main/scala/org/apache/flink/table/planner/plan/nodes/physical/stream/StreamPhysicalWindowJoin.scala
##########
@@ -0,0 +1,91 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.flink.table.planner.plan.nodes.physical.stream
+
+import org.apache.flink.table.api.TableException
+import org.apache.flink.table.planner.plan.logical.WindowingStrategy
+import org.apache.flink.table.planner.plan.nodes.exec.ExecNode
+import org.apache.flink.table.planner.plan.nodes.physical.common.CommonPhysicalJoin
+import org.apache.flink.table.planner.plan.utils.PythonUtil.containsPythonCall
+import org.apache.flink.table.planner.plan.utils.RelExplainUtil.preferExpressionFormat
+
+import org.apache.calcite.plan.{RelOptCluster, RelTraitSet}
+import org.apache.calcite.rel._
+import org.apache.calcite.rel.core.{Join, JoinRelType}
+import org.apache.calcite.rex.RexNode
+
+import scala.collection.JavaConversions._
+import scala.collection.JavaConverters._
+
+/**
+ * The window join requires the join condition contains window starts equality of
+ * input tables and window ends equality of input tables.
+ * The semantic of window join is the same to the DataStream window join.
+ */
+class StreamPhysicalWindowJoin(
+ cluster: RelOptCluster,
+ traitSet: RelTraitSet,
+ leftRel: RelNode,
+ rightRel: RelNode,
+ joinType: JoinRelType,
+ // remaining join condition contains all of join condition except window starts equality
+ // and window end equality
+ remainingCondition: RexNode,
+ val leftWindowing: WindowingStrategy,
+ val rightWindowing: WindowingStrategy)
Review comment:
I see. You are right. Would be better to check the two window strategies in the physical node by overriding `isValid`.
----------------------------------------------------------------
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:
users@infra.apache.org
[GitHub] [flink] beyond1920 commented on a change in pull request #15195: [FLINK-19609][table-planner-blink] Support streaming window join in planner
Posted by GitBox <gi...@apache.org>.
beyond1920 commented on a change in pull request #15195:
URL: https://github.com/apache/flink/pull/15195#discussion_r594018250
##########
File path: flink-table/flink-table-planner-blink/src/main/scala/org/apache/flink/table/planner/plan/utils/WindowJoinUtil.scala
##########
@@ -0,0 +1,219 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.planner.plan.utils
+
+import org.apache.flink.table.api.TableException
+import org.apache.flink.table.planner.plan.metadata.FlinkRelMetadataQuery
+import org.apache.flink.table.planner.plan.nodes.logical.FlinkLogicalJoin
+import org.apache.flink.table.planner.plan.`trait`.RelWindowProperties
+
+import org.apache.calcite.rex.{RexInputRef, RexNode, RexUtil}
+import org.apache.calcite.sql.fun.SqlStdOperatorTable
+import org.apache.calcite.util.ImmutableIntList
+
+import scala.collection.JavaConversions._
+import scala.collection.mutable
+
+/**
+ * Util for window join.
+ */
+object WindowJoinUtil {
+
+ /**
+ * Get window properties of left and right child.
+ *
+ * @param join input join
+ * @return window properties of left and right child.
+ */
+ def getChildWindowProperties(
+ join: FlinkLogicalJoin): (RelWindowProperties, RelWindowProperties) = {
+ val fmq = FlinkRelMetadataQuery.reuseOrCreate(join.getCluster.getMetadataQuery)
+ (fmq.getRelWindowProperties(join.getLeft), fmq.getRelWindowProperties(join.getRight))
+ }
+
+ /**
+ * Checks whether join condition contains window starts equality of input tables or window
+ * ends equality of input tables.
+ *
+ * @param join input join
+ * @return True if join condition contains window starts equality of input tables and window
+ * ends equality of input tables. Else false.
+ */
+ def containsWindowStartEqualityOrEndEquality(join: FlinkLogicalJoin): Boolean = {
+ val (windowStartEqualityLeftKeys, windowEndEqualityLeftKeys, _, _) =
+ excludeWindowStartEqualityAndEndEqualityFromJoinInfoPairs(join)
+ windowStartEqualityLeftKeys.nonEmpty || windowEndEqualityLeftKeys.nonEmpty
+ }
+
+ /**
+ * Excludes window starts equality and window ends equality from join info.
+ *
+ * @param join input join
+ * @return Remain join information after excludes window starts equality and window ends
+ * equality from join.
+ * The first element is left join keys of window starts equality,
+ * the second element is left join keys of window ends equality,
+ * the third element is right join keys of window starts equality,
+ * the forth element is right join keys of window ends equality,
+ * the fifth element is remain left join keys,
+ * the sixth element is remain right join keys,
+ * the last element is remain join condition which includes remain equal condition and
+ * non-equal condition.
+ */
+ def excludeWindowStartEqualityAndEndEqualityFromJoinCondition(
+ join: FlinkLogicalJoin): (
+ ImmutableIntList,
+ ImmutableIntList,
+ ImmutableIntList,
+ ImmutableIntList,
+ ImmutableIntList,
+ ImmutableIntList,
+ RexNode) = {
+ val (
+ windowStartEqualityLeftKeys,
+ windowEndEqualityLeftKeys,
+ windowStartEqualityRightKeys,
+ windowEndEqualityRightKeys) =
+ excludeWindowStartEqualityAndEndEqualityFromJoinInfoPairs(join)
+
+ val joinInfo = join.analyzeCondition()
+ val (remainLeftKeys, remainRightKeys, remainCondition) = if (
+ windowStartEqualityLeftKeys.nonEmpty || windowEndEqualityLeftKeys.nonEmpty) {
+ val joinFieldsType = join.getRowType.getFieldList
+ val leftFieldCnt = join.getLeft.getRowType.getFieldCount
+ val rexBuilder = join.getCluster.getRexBuilder
+ val remainEquals = mutable.ArrayBuffer[RexNode]()
+ val remainLeftKeysArray = mutable.ArrayBuffer[Int]()
+ val remainRightKeysArray = mutable.ArrayBuffer[Int]()
+ // convert remain pairs to RexInputRef tuple for building SqlStdOperatorTable.EQUALS calls
+ joinInfo.pairs().foreach { p =>
+ if (!windowStartEqualityLeftKeys.contains(p.source) &&
+ !windowEndEqualityLeftKeys.contains(p.source)) {
+ val leftFieldType = joinFieldsType.get(p.source).getType
+ val leftInputRef = new RexInputRef(p.source, leftFieldType)
+ val rightIndex = leftFieldCnt + p.target
+ val rightFieldType = joinFieldsType.get(rightIndex).getType
+ val rightInputRef = new RexInputRef(rightIndex, rightFieldType)
+ val remainEqual = rexBuilder.makeCall(
+ SqlStdOperatorTable.EQUALS,
Review comment:
remainCondition contains two part:
1. remain equal condition exclude window start equality and window end equality
2. non-equal condition
----------------------------------------------------------------
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:
users@infra.apache.org
[GitHub] [flink] beyond1920 commented on pull request #15195: [FLINK-19609][table-planner-blink] Support streaming window join in planner
Posted by GitBox <gi...@apache.org>.
beyond1920 commented on pull request #15195:
URL: https://github.com/apache/flink/pull/15195#issuecomment-799076070
@wuchong Thanks for review. I've address all your comments.
----------------------------------------------------------------
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:
users@infra.apache.org
[GitHub] [flink] beyond1920 commented on a change in pull request #15195: [FLINK-19609][table-planner-blink] Support streaming window join in planner
Posted by GitBox <gi...@apache.org>.
beyond1920 commented on a change in pull request #15195:
URL: https://github.com/apache/flink/pull/15195#discussion_r594034270
##########
File path: flink-table/flink-table-planner-blink/src/test/resources/org/apache/flink/table/planner/plan/stream/sql/join/WindowJoinTest.xml
##########
@@ -0,0 +1,1041 @@
+<?xml version="1.0" ?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to you under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+-->
+<Root>
+ <TestCase name="testCantMergeWindowTVF_Cumulate">
+ <Resource name="sql">
+ <![CDATA[
+SELECT L.a, L.b, L.c, R.a, R.b, R.c
+FROM (
+ SELECT *
+ FROM TABLE(
+ CUMULATE(TABLE MyTable, DESCRIPTOR(rowtime), INTERVAL '10' MINUTE, INTERVAL '1' HOUR))
+) L
+JOIN (
+ SELECT *
+ FROM TABLE(
+ CUMULATE(TABLE MyTable2, DESCRIPTOR(rowtime), INTERVAL '10' MINUTE, INTERVAL '1' HOUR))
+) R
+ON L.window_start = R.window_start AND L.window_end = R.window_end AND L.a = R.a
+ ]]>
+ </Resource>
+ <Resource name="ast">
+ <![CDATA[
+LogicalProject(a=[$0], b=[$1], c=[$2], a0=[$8], b0=[$9], c0=[$10])
++- LogicalJoin(condition=[AND(=($5, $13), =($6, $14), =($0, $8))], joinType=[inner])
+ :- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4], window_start=[$5], window_end=[$6], window_time=[$7])
+ : +- LogicalTableFunctionScan(invocation=[CUMULATE($4, DESCRIPTOR($3), 600000:INTERVAL MINUTE, 3600000:INTERVAL HOUR)], rowType=[RecordType(INTEGER a, VARCHAR(2147483647) b, BIGINT c, TIME ATTRIBUTE(ROWTIME) rowtime, TIME ATTRIBUTE(PROCTIME) proctime, TIMESTAMP(3) window_start, TIMESTAMP(3) window_end, TIME ATTRIBUTE(ROWTIME) window_time)])
+ : +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4])
+ : +- LogicalWatermarkAssigner(rowtime=[rowtime], watermark=[-($3, 1000:INTERVAL SECOND)])
+ : +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[PROCTIME()])
+ : +- LogicalTableScan(table=[[default_catalog, default_database, MyTable]])
+ +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4], window_start=[$5], window_end=[$6], window_time=[$7])
+ +- LogicalTableFunctionScan(invocation=[CUMULATE($4, DESCRIPTOR($3), 600000:INTERVAL MINUTE, 3600000:INTERVAL HOUR)], rowType=[RecordType(INTEGER a, VARCHAR(2147483647) b, BIGINT c, TIME ATTRIBUTE(ROWTIME) rowtime, TIME ATTRIBUTE(PROCTIME) proctime, TIMESTAMP(3) window_start, TIMESTAMP(3) window_end, TIME ATTRIBUTE(ROWTIME) window_time)])
+ +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4])
+ +- LogicalWatermarkAssigner(rowtime=[rowtime], watermark=[-($3, 1000:INTERVAL SECOND)])
+ +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[PROCTIME()])
+ +- LogicalTableScan(table=[[default_catalog, default_database, MyTable2]])
+]]>
+ </Resource>
+ <Resource name="optimized rel plan">
+ <![CDATA[
+Calc(select=[a, b, c, a0, b0, c0])
++- WindowJoin(leftWindow=[CUMULATE(win_start=[window_start], win_end=[window_end], max_size=[1 h], step=[10 min])], rightWindow=[CUMULATE(win_start=[window_start], win_end=[window_end], max_size=[1 h], step=[10 min])], joinType=[InnerJoin], where=[=(a, a0)], select=[a, b, c, window_start, window_end, a0, b0, c0, window_start0, window_end0])
+ :- Exchange(distribution=[hash[a]])
+ : +- Calc(select=[a, b, c, window_start, window_end])
+ : +- WindowTableFunction(window=[CUMULATE(time_col=[rowtime], max_size=[1 h], step=[10 min])])
+ : +- WatermarkAssigner(rowtime=[rowtime], watermark=[-(rowtime, 1000:INTERVAL SECOND)])
+ : +- Calc(select=[a, b, c, rowtime, PROCTIME() AS proctime])
+ : +- TableSourceScan(table=[[default_catalog, default_database, MyTable]], fields=[a, b, c, rowtime])
+ +- Exchange(distribution=[hash[a]])
+ +- Calc(select=[a, b, c, window_start, window_end])
+ +- WindowTableFunction(window=[CUMULATE(time_col=[rowtime], max_size=[1 h], step=[10 min])])
+ +- WatermarkAssigner(rowtime=[rowtime], watermark=[-(rowtime, 1000:INTERVAL SECOND)])
+ +- Calc(select=[a, b, c, rowtime, PROCTIME() AS proctime])
+ +- TableSourceScan(table=[[default_catalog, default_database, MyTable2]], fields=[a, b, c, rowtime])
+]]>
+ </Resource>
+ </TestCase>
+ <TestCase name="testCantMergeWindowTVF_CumulateOnProctime">
+ <Resource name="sql">
+ <![CDATA[
+SELECT L.a, L.b, L.c, R.a, R.b, R.c
+FROM (
+ SELECT *
+ FROM TABLE(
+ CUMULATE(TABLE MyTable, DESCRIPTOR(proctime), INTERVAL '10' MINUTE, INTERVAL '1' HOUR))
+) L
+JOIN (
+ SELECT *
+ FROM TABLE(
+ CUMULATE(TABLE MyTable2, DESCRIPTOR(proctime), INTERVAL '10' MINUTE, INTERVAL '1' HOUR))
+) R
+ON L.window_start = R.window_start AND L.window_end = R.window_end AND L.a = R.a
+ ]]>
+ </Resource>
+ <Resource name="ast">
+ <![CDATA[
+LogicalProject(a=[$0], b=[$1], c=[$2], a0=[$8], b0=[$9], c0=[$10])
++- LogicalJoin(condition=[AND(=($5, $13), =($6, $14), =($0, $8))], joinType=[inner])
+ :- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4], window_start=[$5], window_end=[$6], window_time=[$7])
+ : +- LogicalTableFunctionScan(invocation=[CUMULATE($4, DESCRIPTOR($4), 600000:INTERVAL MINUTE, 3600000:INTERVAL HOUR)], rowType=[RecordType(INTEGER a, VARCHAR(2147483647) b, BIGINT c, TIME ATTRIBUTE(ROWTIME) rowtime, TIME ATTRIBUTE(PROCTIME) proctime, TIMESTAMP(3) window_start, TIMESTAMP(3) window_end, TIME ATTRIBUTE(PROCTIME) window_time)])
+ : +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4])
+ : +- LogicalWatermarkAssigner(rowtime=[rowtime], watermark=[-($3, 1000:INTERVAL SECOND)])
+ : +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[PROCTIME()])
+ : +- LogicalTableScan(table=[[default_catalog, default_database, MyTable]])
+ +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4], window_start=[$5], window_end=[$6], window_time=[$7])
+ +- LogicalTableFunctionScan(invocation=[CUMULATE($4, DESCRIPTOR($4), 600000:INTERVAL MINUTE, 3600000:INTERVAL HOUR)], rowType=[RecordType(INTEGER a, VARCHAR(2147483647) b, BIGINT c, TIME ATTRIBUTE(ROWTIME) rowtime, TIME ATTRIBUTE(PROCTIME) proctime, TIMESTAMP(3) window_start, TIMESTAMP(3) window_end, TIME ATTRIBUTE(PROCTIME) window_time)])
+ +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4])
+ +- LogicalWatermarkAssigner(rowtime=[rowtime], watermark=[-($3, 1000:INTERVAL SECOND)])
+ +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[PROCTIME()])
+ +- LogicalTableScan(table=[[default_catalog, default_database, MyTable2]])
+]]>
+ </Resource>
+ <Resource name="optimized rel plan">
+ <![CDATA[
+Calc(select=[a, b, c, a0, b0, c0])
++- WindowJoin(leftWindow=[CUMULATE(win_start=[window_start], win_end=[window_end], max_size=[1 h], step=[10 min])], rightWindow=[CUMULATE(win_start=[window_start], win_end=[window_end], max_size=[1 h], step=[10 min])], joinType=[InnerJoin], where=[=(a, a0)], select=[a, b, c, window_start, window_end, a0, b0, c0, window_start0, window_end0])
+ :- Exchange(distribution=[hash[a]])
+ : +- Calc(select=[a, b, c, window_start, window_end])
+ : +- WindowTableFunction(window=[CUMULATE(time_col=[proctime], max_size=[1 h], step=[10 min])])
+ : +- WatermarkAssigner(rowtime=[rowtime], watermark=[-(rowtime, 1000:INTERVAL SECOND)])
+ : +- Calc(select=[a, b, c, rowtime, PROCTIME() AS proctime])
+ : +- TableSourceScan(table=[[default_catalog, default_database, MyTable]], fields=[a, b, c, rowtime])
+ +- Exchange(distribution=[hash[a]])
+ +- Calc(select=[a, b, c, window_start, window_end])
+ +- WindowTableFunction(window=[CUMULATE(time_col=[proctime], max_size=[1 h], step=[10 min])])
+ +- WatermarkAssigner(rowtime=[rowtime], watermark=[-(rowtime, 1000:INTERVAL SECOND)])
+ +- Calc(select=[a, b, c, rowtime, PROCTIME() AS proctime])
+ +- TableSourceScan(table=[[default_catalog, default_database, MyTable2]], fields=[a, b, c, rowtime])
+]]>
+ </Resource>
+ </TestCase>
+ <TestCase name="testCantMergeWindowTVF_Hop">
+ <Resource name="sql">
+ <![CDATA[
+SELECT L.a, L.b, L.c, R.a, R.b, R.c
+FROM (
+ SELECT *
+ FROM TABLE(
+ HOP(TABLE MyTable, DESCRIPTOR(rowtime), INTERVAL '5' MINUTE, INTERVAL '10' MINUTE))
+) L
+JOIN (
+ SELECT *
+ FROM TABLE(
+ HOP(TABLE MyTable2, DESCRIPTOR(rowtime), INTERVAL '5' MINUTE, INTERVAL '10' MINUTE))
+) R
+ON L.window_start = R.window_start AND L.window_end = R.window_end AND L.a = R.a
+ ]]>
+ </Resource>
+ <Resource name="ast">
+ <![CDATA[
+LogicalProject(a=[$0], b=[$1], c=[$2], a0=[$8], b0=[$9], c0=[$10])
++- LogicalJoin(condition=[AND(=($5, $13), =($6, $14), =($0, $8))], joinType=[inner])
+ :- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4], window_start=[$5], window_end=[$6], window_time=[$7])
+ : +- LogicalTableFunctionScan(invocation=[HOP($4, DESCRIPTOR($3), 300000:INTERVAL MINUTE, 600000:INTERVAL MINUTE)], rowType=[RecordType(INTEGER a, VARCHAR(2147483647) b, BIGINT c, TIME ATTRIBUTE(ROWTIME) rowtime, TIME ATTRIBUTE(PROCTIME) proctime, TIMESTAMP(3) window_start, TIMESTAMP(3) window_end, TIME ATTRIBUTE(ROWTIME) window_time)])
+ : +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4])
+ : +- LogicalWatermarkAssigner(rowtime=[rowtime], watermark=[-($3, 1000:INTERVAL SECOND)])
+ : +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[PROCTIME()])
+ : +- LogicalTableScan(table=[[default_catalog, default_database, MyTable]])
+ +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4], window_start=[$5], window_end=[$6], window_time=[$7])
+ +- LogicalTableFunctionScan(invocation=[HOP($4, DESCRIPTOR($3), 300000:INTERVAL MINUTE, 600000:INTERVAL MINUTE)], rowType=[RecordType(INTEGER a, VARCHAR(2147483647) b, BIGINT c, TIME ATTRIBUTE(ROWTIME) rowtime, TIME ATTRIBUTE(PROCTIME) proctime, TIMESTAMP(3) window_start, TIMESTAMP(3) window_end, TIME ATTRIBUTE(ROWTIME) window_time)])
+ +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4])
+ +- LogicalWatermarkAssigner(rowtime=[rowtime], watermark=[-($3, 1000:INTERVAL SECOND)])
+ +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[PROCTIME()])
+ +- LogicalTableScan(table=[[default_catalog, default_database, MyTable2]])
+]]>
+ </Resource>
+ <Resource name="optimized rel plan">
+ <![CDATA[
+Calc(select=[a, b, c, a0, b0, c0])
++- WindowJoin(leftWindow=[HOP(win_start=[window_start], win_end=[window_end], size=[10 min], slide=[5 min])], rightWindow=[HOP(win_start=[window_start], win_end=[window_end], size=[10 min], slide=[5 min])], joinType=[InnerJoin], where=[=(a, a0)], select=[a, b, c, window_start, window_end, a0, b0, c0, window_start0, window_end0])
+ :- Exchange(distribution=[hash[a]])
+ : +- Calc(select=[a, b, c, window_start, window_end])
+ : +- WindowTableFunction(window=[HOP(time_col=[rowtime], size=[10 min], slide=[5 min])])
+ : +- WatermarkAssigner(rowtime=[rowtime], watermark=[-(rowtime, 1000:INTERVAL SECOND)])
+ : +- Calc(select=[a, b, c, rowtime, PROCTIME() AS proctime])
+ : +- TableSourceScan(table=[[default_catalog, default_database, MyTable]], fields=[a, b, c, rowtime])
+ +- Exchange(distribution=[hash[a]])
+ +- Calc(select=[a, b, c, window_start, window_end])
+ +- WindowTableFunction(window=[HOP(time_col=[rowtime], size=[10 min], slide=[5 min])])
+ +- WatermarkAssigner(rowtime=[rowtime], watermark=[-(rowtime, 1000:INTERVAL SECOND)])
+ +- Calc(select=[a, b, c, rowtime, PROCTIME() AS proctime])
+ +- TableSourceScan(table=[[default_catalog, default_database, MyTable2]], fields=[a, b, c, rowtime])
+]]>
+ </Resource>
+ </TestCase>
+ <TestCase name="testCantMergeWindowTVF_HopOnProctime">
+ <Resource name="sql">
+ <![CDATA[
+SELECT L.a, L.b, L.c, R.a, R.b, R.c
+FROM (
+ SELECT *
+ FROM TABLE(
+ HOP(TABLE MyTable, DESCRIPTOR(proctime), INTERVAL '5' MINUTE, INTERVAL '10' MINUTE))
+) L
+JOIN (
+ SELECT *
+ FROM TABLE(
+ HOP(TABLE MyTable2, DESCRIPTOR(proctime), INTERVAL '5' MINUTE, INTERVAL '10' MINUTE))
+) R
+ON L.window_start = R.window_start AND L.window_end = R.window_end AND L.a = R.a
+ ]]>
+ </Resource>
+ <Resource name="ast">
+ <![CDATA[
+LogicalProject(a=[$0], b=[$1], c=[$2], a0=[$8], b0=[$9], c0=[$10])
++- LogicalJoin(condition=[AND(=($5, $13), =($6, $14), =($0, $8))], joinType=[inner])
+ :- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4], window_start=[$5], window_end=[$6], window_time=[$7])
+ : +- LogicalTableFunctionScan(invocation=[HOP($4, DESCRIPTOR($4), 300000:INTERVAL MINUTE, 600000:INTERVAL MINUTE)], rowType=[RecordType(INTEGER a, VARCHAR(2147483647) b, BIGINT c, TIME ATTRIBUTE(ROWTIME) rowtime, TIME ATTRIBUTE(PROCTIME) proctime, TIMESTAMP(3) window_start, TIMESTAMP(3) window_end, TIME ATTRIBUTE(PROCTIME) window_time)])
+ : +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4])
+ : +- LogicalWatermarkAssigner(rowtime=[rowtime], watermark=[-($3, 1000:INTERVAL SECOND)])
+ : +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[PROCTIME()])
+ : +- LogicalTableScan(table=[[default_catalog, default_database, MyTable]])
+ +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4], window_start=[$5], window_end=[$6], window_time=[$7])
+ +- LogicalTableFunctionScan(invocation=[HOP($4, DESCRIPTOR($4), 300000:INTERVAL MINUTE, 600000:INTERVAL MINUTE)], rowType=[RecordType(INTEGER a, VARCHAR(2147483647) b, BIGINT c, TIME ATTRIBUTE(ROWTIME) rowtime, TIME ATTRIBUTE(PROCTIME) proctime, TIMESTAMP(3) window_start, TIMESTAMP(3) window_end, TIME ATTRIBUTE(PROCTIME) window_time)])
+ +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4])
+ +- LogicalWatermarkAssigner(rowtime=[rowtime], watermark=[-($3, 1000:INTERVAL SECOND)])
+ +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[PROCTIME()])
+ +- LogicalTableScan(table=[[default_catalog, default_database, MyTable2]])
+]]>
+ </Resource>
+ <Resource name="optimized rel plan">
+ <![CDATA[
+Calc(select=[a, b, c, a0, b0, c0])
++- WindowJoin(leftWindow=[HOP(win_start=[window_start], win_end=[window_end], size=[10 min], slide=[5 min])], rightWindow=[HOP(win_start=[window_start], win_end=[window_end], size=[10 min], slide=[5 min])], joinType=[InnerJoin], where=[=(a, a0)], select=[a, b, c, window_start, window_end, a0, b0, c0, window_start0, window_end0])
+ :- Exchange(distribution=[hash[a]])
+ : +- Calc(select=[a, b, c, window_start, window_end])
+ : +- WindowTableFunction(window=[HOP(time_col=[proctime], size=[10 min], slide=[5 min])])
+ : +- WatermarkAssigner(rowtime=[rowtime], watermark=[-(rowtime, 1000:INTERVAL SECOND)])
+ : +- Calc(select=[a, b, c, rowtime, PROCTIME() AS proctime])
+ : +- TableSourceScan(table=[[default_catalog, default_database, MyTable]], fields=[a, b, c, rowtime])
+ +- Exchange(distribution=[hash[a]])
+ +- Calc(select=[a, b, c, window_start, window_end])
+ +- WindowTableFunction(window=[HOP(time_col=[proctime], size=[10 min], slide=[5 min])])
+ +- WatermarkAssigner(rowtime=[rowtime], watermark=[-(rowtime, 1000:INTERVAL SECOND)])
+ +- Calc(select=[a, b, c, rowtime, PROCTIME() AS proctime])
+ +- TableSourceScan(table=[[default_catalog, default_database, MyTable2]], fields=[a, b, c, rowtime])
+]]>
+ </Resource>
+ </TestCase>
+ <TestCase name="testCantMergeWindowTVF_Tumble">
+ <Resource name="sql">
+ <![CDATA[
+SELECT L.a, L.b, L.c, R.a, R.b, R.c
+FROM (
+ SELECT *
+ FROM TABLE(TUMBLE(TABLE MyTable, DESCRIPTOR(rowtime), INTERVAL '15' MINUTE))
+) L
+JOIN (
+ SELECT *
+ FROM TABLE(TUMBLE(TABLE MyTable2, DESCRIPTOR(rowtime), INTERVAL '15' MINUTE))
+) R
+ON L.window_start = R.window_start AND L.window_end = R.window_end AND L.a = R.a
+ ]]>
+ </Resource>
+ <Resource name="ast">
+ <![CDATA[
+LogicalProject(a=[$0], b=[$1], c=[$2], a0=[$8], b0=[$9], c0=[$10])
++- LogicalJoin(condition=[AND(=($5, $13), =($6, $14), =($0, $8))], joinType=[inner])
+ :- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4], window_start=[$5], window_end=[$6], window_time=[$7])
+ : +- LogicalTableFunctionScan(invocation=[TUMBLE($4, DESCRIPTOR($3), 900000:INTERVAL MINUTE)], rowType=[RecordType(INTEGER a, VARCHAR(2147483647) b, BIGINT c, TIME ATTRIBUTE(ROWTIME) rowtime, TIME ATTRIBUTE(PROCTIME) proctime, TIMESTAMP(3) window_start, TIMESTAMP(3) window_end, TIME ATTRIBUTE(ROWTIME) window_time)])
+ : +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4])
+ : +- LogicalWatermarkAssigner(rowtime=[rowtime], watermark=[-($3, 1000:INTERVAL SECOND)])
+ : +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[PROCTIME()])
+ : +- LogicalTableScan(table=[[default_catalog, default_database, MyTable]])
+ +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4], window_start=[$5], window_end=[$6], window_time=[$7])
+ +- LogicalTableFunctionScan(invocation=[TUMBLE($4, DESCRIPTOR($3), 900000:INTERVAL MINUTE)], rowType=[RecordType(INTEGER a, VARCHAR(2147483647) b, BIGINT c, TIME ATTRIBUTE(ROWTIME) rowtime, TIME ATTRIBUTE(PROCTIME) proctime, TIMESTAMP(3) window_start, TIMESTAMP(3) window_end, TIME ATTRIBUTE(ROWTIME) window_time)])
+ +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4])
+ +- LogicalWatermarkAssigner(rowtime=[rowtime], watermark=[-($3, 1000:INTERVAL SECOND)])
+ +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[PROCTIME()])
+ +- LogicalTableScan(table=[[default_catalog, default_database, MyTable2]])
+]]>
+ </Resource>
+ <Resource name="optimized rel plan">
+ <![CDATA[
+Calc(select=[a, b, c, a0, b0, c0])
++- WindowJoin(leftWindow=[TUMBLE(win_start=[window_start], win_end=[window_end], size=[15 min])], rightWindow=[TUMBLE(win_start=[window_start], win_end=[window_end], size=[15 min])], joinType=[InnerJoin], where=[=(a, a0)], select=[a, b, c, window_start, window_end, a0, b0, c0, window_start0, window_end0])
+ :- Exchange(distribution=[hash[a]])
+ : +- Calc(select=[a, b, c, window_start, window_end])
+ : +- WindowTableFunction(window=[TUMBLE(time_col=[rowtime], size=[15 min])])
+ : +- WatermarkAssigner(rowtime=[rowtime], watermark=[-(rowtime, 1000:INTERVAL SECOND)])
+ : +- Calc(select=[a, b, c, rowtime, PROCTIME() AS proctime])
+ : +- TableSourceScan(table=[[default_catalog, default_database, MyTable]], fields=[a, b, c, rowtime])
+ +- Exchange(distribution=[hash[a]])
+ +- Calc(select=[a, b, c, window_start, window_end])
+ +- WindowTableFunction(window=[TUMBLE(time_col=[rowtime], size=[15 min])])
+ +- WatermarkAssigner(rowtime=[rowtime], watermark=[-(rowtime, 1000:INTERVAL SECOND)])
+ +- Calc(select=[a, b, c, rowtime, PROCTIME() AS proctime])
+ +- TableSourceScan(table=[[default_catalog, default_database, MyTable2]], fields=[a, b, c, rowtime])
+]]>
+ </Resource>
+ </TestCase>
+ <TestCase name="testCantMergeWindowTVF_TumbleOnProctime">
+ <Resource name="sql">
+ <![CDATA[
+SELECT L.a, L.b, L.c, R.a, R.b, R.c
+FROM (
+ SELECT *
+ FROM TABLE(TUMBLE(TABLE MyTable, DESCRIPTOR(proctime), INTERVAL '15' MINUTE))
+) L
+JOIN (
+ SELECT *
+ FROM TABLE(TUMBLE(TABLE MyTable2, DESCRIPTOR(proctime), INTERVAL '15' MINUTE))
+) R
+ON L.window_start = R.window_start AND L.window_end = R.window_end AND L.a = R.a
+ ]]>
+ </Resource>
+ <Resource name="ast">
+ <![CDATA[
+LogicalProject(a=[$0], b=[$1], c=[$2], a0=[$8], b0=[$9], c0=[$10])
++- LogicalJoin(condition=[AND(=($5, $13), =($6, $14), =($0, $8))], joinType=[inner])
+ :- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4], window_start=[$5], window_end=[$6], window_time=[$7])
+ : +- LogicalTableFunctionScan(invocation=[TUMBLE($4, DESCRIPTOR($4), 900000:INTERVAL MINUTE)], rowType=[RecordType(INTEGER a, VARCHAR(2147483647) b, BIGINT c, TIME ATTRIBUTE(ROWTIME) rowtime, TIME ATTRIBUTE(PROCTIME) proctime, TIMESTAMP(3) window_start, TIMESTAMP(3) window_end, TIME ATTRIBUTE(PROCTIME) window_time)])
+ : +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4])
+ : +- LogicalWatermarkAssigner(rowtime=[rowtime], watermark=[-($3, 1000:INTERVAL SECOND)])
+ : +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[PROCTIME()])
+ : +- LogicalTableScan(table=[[default_catalog, default_database, MyTable]])
+ +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4], window_start=[$5], window_end=[$6], window_time=[$7])
+ +- LogicalTableFunctionScan(invocation=[TUMBLE($4, DESCRIPTOR($4), 900000:INTERVAL MINUTE)], rowType=[RecordType(INTEGER a, VARCHAR(2147483647) b, BIGINT c, TIME ATTRIBUTE(ROWTIME) rowtime, TIME ATTRIBUTE(PROCTIME) proctime, TIMESTAMP(3) window_start, TIMESTAMP(3) window_end, TIME ATTRIBUTE(PROCTIME) window_time)])
+ +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4])
+ +- LogicalWatermarkAssigner(rowtime=[rowtime], watermark=[-($3, 1000:INTERVAL SECOND)])
+ +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[PROCTIME()])
+ +- LogicalTableScan(table=[[default_catalog, default_database, MyTable2]])
+]]>
+ </Resource>
+ <Resource name="optimized rel plan">
+ <![CDATA[
+Calc(select=[a, b, c, a0, b0, c0])
++- WindowJoin(leftWindow=[TUMBLE(win_start=[window_start], win_end=[window_end], size=[15 min])], rightWindow=[TUMBLE(win_start=[window_start], win_end=[window_end], size=[15 min])], joinType=[InnerJoin], where=[=(a, a0)], select=[a, b, c, window_start, window_end, a0, b0, c0, window_start0, window_end0])
+ :- Exchange(distribution=[hash[a]])
+ : +- Calc(select=[a, b, c, window_start, window_end])
+ : +- WindowTableFunction(window=[TUMBLE(time_col=[proctime], size=[15 min])])
+ : +- WatermarkAssigner(rowtime=[rowtime], watermark=[-(rowtime, 1000:INTERVAL SECOND)])
+ : +- Calc(select=[a, b, c, rowtime, PROCTIME() AS proctime])
+ : +- TableSourceScan(table=[[default_catalog, default_database, MyTable]], fields=[a, b, c, rowtime])
+ +- Exchange(distribution=[hash[a]])
+ +- Calc(select=[a, b, c, window_start, window_end])
+ +- WindowTableFunction(window=[TUMBLE(time_col=[proctime], size=[15 min])])
+ +- WatermarkAssigner(rowtime=[rowtime], watermark=[-(rowtime, 1000:INTERVAL SECOND)])
+ +- Calc(select=[a, b, c, rowtime, PROCTIME() AS proctime])
+ +- TableSourceScan(table=[[default_catalog, default_database, MyTable2]], fields=[a, b, c, rowtime])
+]]>
+ </Resource>
+ </TestCase>
+ <TestCase name="testOnCumulateWindowAggregate">
+ <Resource name="sql">
+ <![CDATA[
+SELECT L.*, R.*
+FROM (
+ SELECT
+ a,
+ window_start,
+ window_end,
+ window_time,
+ count(*) as cnt,
+ count(distinct c) AS uv
+ FROM TABLE(
+ CUMULATE(
+ TABLE MyTable, DESCRIPTOR(rowtime), INTERVAL '10' MINUTE, INTERVAL '1' HOUR))
+ GROUP BY a, window_start, window_end, window_time
+) L
+JOIN (
+ SELECT
+ a,
+ window_start,
+ window_end,
+ window_time,
+ count(*) as cnt,
+ count(distinct c) AS uv
+ FROM TABLE(
+ CUMULATE(
+ TABLE MyTable2, DESCRIPTOR(rowtime), INTERVAL '10' MINUTE, INTERVAL '1' HOUR))
+ GROUP BY a, window_start, window_end, window_time
+) R
+ON L.window_start = R.window_start AND L.window_end = R.window_end AND L.a = R.a
+ ]]>
+ </Resource>
+ <Resource name="ast">
+ <![CDATA[
+LogicalProject(a=[$0], window_start=[$1], window_end=[$2], window_time=[$3], cnt=[$4], uv=[$5], a0=[$6], window_start0=[$7], window_end0=[$8], window_time0=[$9], cnt0=[$10], uv0=[$11])
++- LogicalJoin(condition=[AND(=($1, $7), =($2, $8), =($0, $6))], joinType=[inner])
+ :- LogicalAggregate(group=[{0, 1, 2, 3}], cnt=[COUNT()], uv=[COUNT(DISTINCT $4)])
+ : +- LogicalProject(a=[$0], window_start=[$5], window_end=[$6], window_time=[$7], c=[$2])
+ : +- LogicalTableFunctionScan(invocation=[CUMULATE($4, DESCRIPTOR($3), 600000:INTERVAL MINUTE, 3600000:INTERVAL HOUR)], rowType=[RecordType(INTEGER a, VARCHAR(2147483647) b, BIGINT c, TIME ATTRIBUTE(ROWTIME) rowtime, TIME ATTRIBUTE(PROCTIME) proctime, TIMESTAMP(3) window_start, TIMESTAMP(3) window_end, TIME ATTRIBUTE(ROWTIME) window_time)])
+ : +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4])
+ : +- LogicalWatermarkAssigner(rowtime=[rowtime], watermark=[-($3, 1000:INTERVAL SECOND)])
+ : +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[PROCTIME()])
+ : +- LogicalTableScan(table=[[default_catalog, default_database, MyTable]])
+ +- LogicalAggregate(group=[{0, 1, 2, 3}], cnt=[COUNT()], uv=[COUNT(DISTINCT $4)])
+ +- LogicalProject(a=[$0], window_start=[$5], window_end=[$6], window_time=[$7], c=[$2])
+ +- LogicalTableFunctionScan(invocation=[CUMULATE($4, DESCRIPTOR($3), 600000:INTERVAL MINUTE, 3600000:INTERVAL HOUR)], rowType=[RecordType(INTEGER a, VARCHAR(2147483647) b, BIGINT c, TIME ATTRIBUTE(ROWTIME) rowtime, TIME ATTRIBUTE(PROCTIME) proctime, TIMESTAMP(3) window_start, TIMESTAMP(3) window_end, TIME ATTRIBUTE(ROWTIME) window_time)])
+ +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4])
+ +- LogicalWatermarkAssigner(rowtime=[rowtime], watermark=[-($3, 1000:INTERVAL SECOND)])
+ +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[PROCTIME()])
+ +- LogicalTableScan(table=[[default_catalog, default_database, MyTable2]])
+]]>
+ </Resource>
+ <Resource name="optimized rel plan">
+ <![CDATA[
+WindowJoin(leftWindow=[CUMULATE(win_start=[window_start], win_end=[window_end], max_size=[1 h], step=[10 min])], rightWindow=[CUMULATE(win_start=[window_start], win_end=[window_end], max_size=[1 h], step=[10 min])], joinType=[InnerJoin], where=[=(a, a0)], select=[a, window_start, window_end, window_time, cnt, uv, a0, window_start0, window_end0, window_time0, cnt0, uv0])
+:- Exchange(distribution=[hash[a]])
+: +- Calc(select=[a, window_start, window_end, window_time, cnt, uv])
+: +- WindowAggregate(groupBy=[a], window=[CUMULATE(time_col=[rowtime], max_size=[1 h], step=[10 min])], select=[a, COUNT(*) AS cnt, COUNT(DISTINCT c) AS uv, start('w$) AS window_start, end('w$) AS window_end, rowtime('w$) AS window_time])
+: +- Exchange(distribution=[hash[a]])
+: +- Calc(select=[a, c, rowtime])
+: +- WatermarkAssigner(rowtime=[rowtime], watermark=[-(rowtime, 1000:INTERVAL SECOND)])
+: +- Calc(select=[a, b, c, rowtime, PROCTIME() AS proctime])
+: +- TableSourceScan(table=[[default_catalog, default_database, MyTable]], fields=[a, b, c, rowtime])
++- Exchange(distribution=[hash[a]])
+ +- Calc(select=[a, window_start, window_end, window_time, cnt, uv])
+ +- WindowAggregate(groupBy=[a], window=[CUMULATE(time_col=[rowtime], max_size=[1 h], step=[10 min])], select=[a, COUNT(*) AS cnt, COUNT(DISTINCT c) AS uv, start('w$) AS window_start, end('w$) AS window_end, rowtime('w$) AS window_time])
+ +- Exchange(distribution=[hash[a]])
+ +- Calc(select=[a, c, rowtime])
+ +- WatermarkAssigner(rowtime=[rowtime], watermark=[-(rowtime, 1000:INTERVAL SECOND)])
+ +- Calc(select=[a, b, c, rowtime, PROCTIME() AS proctime])
+ +- TableSourceScan(table=[[default_catalog, default_database, MyTable2]], fields=[a, b, c, rowtime])
+]]>
+ </Resource>
+ </TestCase>
+ <TestCase name="testTimeAttributePropagateForWindowJoin1">
+ <Resource name="sql">
+ <![CDATA[
+SELECT tmp1.*, MyTable4.* FROM tmp1 JOIN MyTable4 ON
+ tmp1.a = MyTable4.a AND
+ tmp1.rowtime BETWEEN
+ MyTable4.rowtime - INTERVAL '10' SECOND AND
+ MyTable4.rowtime + INTERVAL '1' HOUR
+]]>
+ </Resource>
+ <Resource name="ast">
+ <![CDATA[
+LogicalProject(rowtime=[$0], a=[$1], l_cnt=[$2], l_uv=[$3], r_cnt=[$4], r_uv=[$5], a0=[$6], b=[$7], c=[$8], rowtime0=[$9], proctime=[$10])
++- LogicalJoin(condition=[AND(=($1, $6), >=($0, -($9, 10000:INTERVAL SECOND)), <=($0, +($9, 3600000:INTERVAL HOUR)))], joinType=[inner])
+ :- LogicalProject(rowtime=[$3], a=[$0], l_cnt=[$4], l_uv=[$5], r_cnt=[$10], r_uv=[$11])
+ : +- LogicalJoin(condition=[AND(=($1, $7), =($2, $8), =($0, $6))], joinType=[inner])
+ : :- LogicalAggregate(group=[{0, 1, 2, 3}], cnt=[COUNT()], uv=[COUNT(DISTINCT $4)])
+ : : +- LogicalProject(a=[$0], window_start=[$5], window_end=[$6], window_time=[$7], c=[$2])
+ : : +- LogicalTableFunctionScan(invocation=[CUMULATE($4, DESCRIPTOR($3), 600000:INTERVAL MINUTE, 3600000:INTERVAL HOUR)], rowType=[RecordType(INTEGER a, VARCHAR(2147483647) b, BIGINT c, TIME ATTRIBUTE(ROWTIME) rowtime, TIME ATTRIBUTE(PROCTIME) proctime, TIMESTAMP(3) window_start, TIMESTAMP(3) window_end, TIME ATTRIBUTE(ROWTIME) window_time)])
+ : : +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4])
+ : : +- LogicalWatermarkAssigner(rowtime=[rowtime], watermark=[-($3, 1000:INTERVAL SECOND)])
+ : : +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[PROCTIME()])
+ : : +- LogicalTableScan(table=[[default_catalog, default_database, MyTable]])
+ : +- LogicalAggregate(group=[{0, 1, 2, 3}], cnt=[COUNT()], uv=[COUNT(DISTINCT $4)])
+ : +- LogicalProject(a=[$0], window_start=[$5], window_end=[$6], window_time=[$7], c=[$2])
+ : +- LogicalTableFunctionScan(invocation=[CUMULATE($4, DESCRIPTOR($3), 600000:INTERVAL MINUTE, 3600000:INTERVAL HOUR)], rowType=[RecordType(INTEGER a, VARCHAR(2147483647) b, BIGINT c, TIME ATTRIBUTE(ROWTIME) rowtime, TIME ATTRIBUTE(PROCTIME) proctime, TIMESTAMP(3) window_start, TIMESTAMP(3) window_end, TIME ATTRIBUTE(ROWTIME) window_time)])
+ : +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4])
+ : +- LogicalWatermarkAssigner(rowtime=[rowtime], watermark=[-($3, 1000:INTERVAL SECOND)])
+ : +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[PROCTIME()])
+ : +- LogicalTableScan(table=[[default_catalog, default_database, MyTable2]])
+ +- LogicalWatermarkAssigner(rowtime=[rowtime], watermark=[-($3, 1000:INTERVAL SECOND)])
+ +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[PROCTIME()])
+ +- LogicalTableScan(table=[[default_catalog, default_database, MyTable4]])
+]]>
+ </Resource>
+ <Resource name="optimized rel plan">
+ <![CDATA[
+Calc(select=[rowtime, a, l_cnt, l_uv, r_cnt, r_uv, a0, b, c, rowtime0, PROCTIME_MATERIALIZE(proctime) AS proctime])
++- IntervalJoin(joinType=[InnerJoin], windowBounds=[isRowTime=true, leftLowerBound=-10000, leftUpperBound=3600000, leftTimeIndex=0, rightTimeIndex=3], where=[AND(=(a, a0), >=(rowtime, -(rowtime0, 10000:INTERVAL SECOND)), <=(rowtime, +(rowtime0, 3600000:INTERVAL HOUR)))], select=[rowtime, a, l_cnt, l_uv, r_cnt, r_uv, a0, b, c, rowtime0, proctime])
+ :- Exchange(distribution=[hash[a]])
+ : +- Calc(select=[window_time AS rowtime, a, cnt AS l_cnt, uv AS l_uv, cnt0 AS r_cnt, uv0 AS r_uv])
+ : +- WindowJoin(leftWindow=[CUMULATE(win_start=[window_start], win_end=[window_end], max_size=[1 h], step=[10 min])], rightWindow=[CUMULATE(win_start=[window_start], win_end=[window_end], max_size=[1 h], step=[10 min])], joinType=[InnerJoin], where=[=(a, a0)], select=[a, window_start, window_end, window_time, cnt, uv, a0, window_start0, window_end0, cnt0, uv0])
+ : :- Exchange(distribution=[hash[a]])
+ : : +- Calc(select=[a, window_start, window_end, window_time, cnt, uv])
+ : : +- WindowAggregate(groupBy=[a], window=[CUMULATE(time_col=[rowtime], max_size=[1 h], step=[10 min])], select=[a, COUNT(*) AS cnt, COUNT(DISTINCT c) AS uv, start('w$) AS window_start, end('w$) AS window_end, rowtime('w$) AS window_time])
+ : : +- Exchange(distribution=[hash[a]])
+ : : +- Calc(select=[a, c, rowtime])
+ : : +- WatermarkAssigner(rowtime=[rowtime], watermark=[-(rowtime, 1000:INTERVAL SECOND)])
+ : : +- Calc(select=[a, b, c, rowtime, PROCTIME() AS proctime])
+ : : +- TableSourceScan(table=[[default_catalog, default_database, MyTable]], fields=[a, b, c, rowtime])
+ : +- Exchange(distribution=[hash[a]])
+ : +- Calc(select=[a, window_start, window_end, cnt, uv])
+ : +- WindowAggregate(groupBy=[a], window=[CUMULATE(time_col=[rowtime], max_size=[1 h], step=[10 min])], select=[a, COUNT(*) AS cnt, COUNT(DISTINCT c) AS uv, start('w$) AS window_start, end('w$) AS window_end, rowtime('w$) AS window_time])
+ : +- Exchange(distribution=[hash[a]])
+ : +- Calc(select=[a, c, rowtime])
+ : +- WatermarkAssigner(rowtime=[rowtime], watermark=[-(rowtime, 1000:INTERVAL SECOND)])
+ : +- Calc(select=[a, b, c, rowtime, PROCTIME() AS proctime])
+ : +- TableSourceScan(table=[[default_catalog, default_database, MyTable2]], fields=[a, b, c, rowtime])
+ +- Exchange(distribution=[hash[a]])
+ +- WatermarkAssigner(rowtime=[rowtime], watermark=[-(rowtime, 1000:INTERVAL SECOND)])
+ +- Calc(select=[a, b, c, rowtime, PROCTIME() AS proctime])
+ +- TableSourceScan(table=[[default_catalog, default_database, MyTable4]], fields=[a, b, c, rowtime])
+]]>
+ </Resource>
+ </TestCase>
+ <TestCase name="testOnCumulateWindowAggregateOnProctime">
+ <Resource name="sql">
+ <![CDATA[
+SELECT L.*, R.*
+FROM (
+ SELECT
+ a,
+ window_start,
+ window_end,
+ window_time,
+ count(*) as cnt,
+ count(distinct c) AS uv
+ FROM TABLE(
+ CUMULATE(
+ TABLE MyTable, DESCRIPTOR(proctime), INTERVAL '10' MINUTE, INTERVAL '1' HOUR))
+ GROUP BY a, window_start, window_end, window_time
+) L
+JOIN (
+ SELECT
+ a,
+ window_start,
+ window_end,
+ window_time,
+ count(*) as cnt,
+ count(distinct c) AS uv
+ FROM TABLE(
+ CUMULATE(
+ TABLE MyTable2, DESCRIPTOR(proctime), INTERVAL '10' MINUTE, INTERVAL '1' HOUR))
+ GROUP BY a, window_start, window_end, window_time
+) R
+ON L.window_start = R.window_start AND L.window_end = R.window_end AND L.a = R.a
+ ]]>
+ </Resource>
+ <Resource name="ast">
+ <![CDATA[
+LogicalProject(a=[$0], window_start=[$1], window_end=[$2], window_time=[$3], cnt=[$4], uv=[$5], a0=[$6], window_start0=[$7], window_end0=[$8], window_time0=[$9], cnt0=[$10], uv0=[$11])
++- LogicalJoin(condition=[AND(=($1, $7), =($2, $8), =($0, $6))], joinType=[inner])
+ :- LogicalAggregate(group=[{0, 1, 2, 3}], cnt=[COUNT()], uv=[COUNT(DISTINCT $4)])
+ : +- LogicalProject(a=[$0], window_start=[$5], window_end=[$6], window_time=[$7], c=[$2])
+ : +- LogicalTableFunctionScan(invocation=[CUMULATE($4, DESCRIPTOR($4), 600000:INTERVAL MINUTE, 3600000:INTERVAL HOUR)], rowType=[RecordType(INTEGER a, VARCHAR(2147483647) b, BIGINT c, TIME ATTRIBUTE(ROWTIME) rowtime, TIME ATTRIBUTE(PROCTIME) proctime, TIMESTAMP(3) window_start, TIMESTAMP(3) window_end, TIME ATTRIBUTE(PROCTIME) window_time)])
+ : +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4])
+ : +- LogicalWatermarkAssigner(rowtime=[rowtime], watermark=[-($3, 1000:INTERVAL SECOND)])
+ : +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[PROCTIME()])
+ : +- LogicalTableScan(table=[[default_catalog, default_database, MyTable]])
+ +- LogicalAggregate(group=[{0, 1, 2, 3}], cnt=[COUNT()], uv=[COUNT(DISTINCT $4)])
+ +- LogicalProject(a=[$0], window_start=[$5], window_end=[$6], window_time=[$7], c=[$2])
+ +- LogicalTableFunctionScan(invocation=[CUMULATE($4, DESCRIPTOR($4), 600000:INTERVAL MINUTE, 3600000:INTERVAL HOUR)], rowType=[RecordType(INTEGER a, VARCHAR(2147483647) b, BIGINT c, TIME ATTRIBUTE(ROWTIME) rowtime, TIME ATTRIBUTE(PROCTIME) proctime, TIMESTAMP(3) window_start, TIMESTAMP(3) window_end, TIME ATTRIBUTE(PROCTIME) window_time)])
+ +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4])
+ +- LogicalWatermarkAssigner(rowtime=[rowtime], watermark=[-($3, 1000:INTERVAL SECOND)])
+ +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[PROCTIME()])
+ +- LogicalTableScan(table=[[default_catalog, default_database, MyTable2]])
+]]>
+ </Resource>
+ <Resource name="optimized rel plan">
+ <![CDATA[
+Calc(select=[a, window_start, window_end, PROCTIME_MATERIALIZE(window_time) AS window_time, cnt, uv, a0, window_start0, window_end0, PROCTIME_MATERIALIZE(window_time0) AS window_time0, cnt0, uv0])
++- WindowJoin(leftWindow=[CUMULATE(win_start=[window_start], win_end=[window_end], max_size=[1 h], step=[10 min])], rightWindow=[CUMULATE(win_start=[window_start], win_end=[window_end], max_size=[1 h], step=[10 min])], joinType=[InnerJoin], where=[=(a, a0)], select=[a, window_start, window_end, window_time, cnt, uv, a0, window_start0, window_end0, window_time0, cnt0, uv0])
+ :- Exchange(distribution=[hash[a]])
+ : +- Calc(select=[a, window_start, window_end, window_time, cnt, uv])
+ : +- WindowAggregate(groupBy=[a], window=[CUMULATE(time_col=[proctime], max_size=[1 h], step=[10 min])], select=[a, COUNT(*) AS cnt, COUNT(DISTINCT c) AS uv, start('w$) AS window_start, end('w$) AS window_end, proctime('w$) AS window_time])
+ : +- Exchange(distribution=[hash[a]])
+ : +- Calc(select=[a, c, proctime])
+ : +- WatermarkAssigner(rowtime=[rowtime], watermark=[-(rowtime, 1000:INTERVAL SECOND)])
+ : +- Calc(select=[a, b, c, rowtime, PROCTIME() AS proctime])
+ : +- TableSourceScan(table=[[default_catalog, default_database, MyTable]], fields=[a, b, c, rowtime])
+ +- Exchange(distribution=[hash[a]])
+ +- Calc(select=[a, window_start, window_end, window_time, cnt, uv])
+ +- WindowAggregate(groupBy=[a], window=[CUMULATE(time_col=[proctime], max_size=[1 h], step=[10 min])], select=[a, COUNT(*) AS cnt, COUNT(DISTINCT c) AS uv, start('w$) AS window_start, end('w$) AS window_end, proctime('w$) AS window_time])
+ +- Exchange(distribution=[hash[a]])
+ +- Calc(select=[a, c, proctime])
+ +- WatermarkAssigner(rowtime=[rowtime], watermark=[-(rowtime, 1000:INTERVAL SECOND)])
+ +- Calc(select=[a, b, c, rowtime, PROCTIME() AS proctime])
+ +- TableSourceScan(table=[[default_catalog, default_database, MyTable2]], fields=[a, b, c, rowtime])
+]]>
+ </Resource>
+ </TestCase>
+ <TestCase name="testOnHopWindowAggregate">
+ <Resource name="sql">
+ <![CDATA[
+SELECT L.*, R.*
+FROM (
+ SELECT
+ a,
+ window_start,
+ window_end,
+ window_time,
+ count(*) as cnt,
+ count(distinct c) AS uv
+ FROM TABLE(
+ HOP(TABLE MyTable, DESCRIPTOR(rowtime), INTERVAL '5' MINUTE, INTERVAL '10' MINUTE))
+ GROUP BY a, window_start, window_end, window_time
+) L
+JOIN (
+ SELECT
+ a,
+ window_start,
+ window_end,
+ window_time,
+ count(*) as cnt,
+ count(distinct c) AS uv
+ FROM TABLE(
+ HOP(TABLE MyTable2, DESCRIPTOR(rowtime), INTERVAL '5' MINUTE, INTERVAL '10' MINUTE))
+ GROUP BY a, window_start, window_end, window_time
+) R
+ON L.window_start = R.window_start AND L.window_end = R.window_end AND L.a = R.a
+ ]]>
+ </Resource>
+ <Resource name="ast">
+ <![CDATA[
+LogicalProject(a=[$0], window_start=[$1], window_end=[$2], window_time=[$3], cnt=[$4], uv=[$5], a0=[$6], window_start0=[$7], window_end0=[$8], window_time0=[$9], cnt0=[$10], uv0=[$11])
++- LogicalJoin(condition=[AND(=($1, $7), =($2, $8), =($0, $6))], joinType=[inner])
+ :- LogicalAggregate(group=[{0, 1, 2, 3}], cnt=[COUNT()], uv=[COUNT(DISTINCT $4)])
+ : +- LogicalProject(a=[$0], window_start=[$5], window_end=[$6], window_time=[$7], c=[$2])
+ : +- LogicalTableFunctionScan(invocation=[HOP($4, DESCRIPTOR($3), 300000:INTERVAL MINUTE, 600000:INTERVAL MINUTE)], rowType=[RecordType(INTEGER a, VARCHAR(2147483647) b, BIGINT c, TIME ATTRIBUTE(ROWTIME) rowtime, TIME ATTRIBUTE(PROCTIME) proctime, TIMESTAMP(3) window_start, TIMESTAMP(3) window_end, TIME ATTRIBUTE(ROWTIME) window_time)])
+ : +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4])
+ : +- LogicalWatermarkAssigner(rowtime=[rowtime], watermark=[-($3, 1000:INTERVAL SECOND)])
+ : +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[PROCTIME()])
+ : +- LogicalTableScan(table=[[default_catalog, default_database, MyTable]])
+ +- LogicalAggregate(group=[{0, 1, 2, 3}], cnt=[COUNT()], uv=[COUNT(DISTINCT $4)])
+ +- LogicalProject(a=[$0], window_start=[$5], window_end=[$6], window_time=[$7], c=[$2])
+ +- LogicalTableFunctionScan(invocation=[HOP($4, DESCRIPTOR($3), 300000:INTERVAL MINUTE, 600000:INTERVAL MINUTE)], rowType=[RecordType(INTEGER a, VARCHAR(2147483647) b, BIGINT c, TIME ATTRIBUTE(ROWTIME) rowtime, TIME ATTRIBUTE(PROCTIME) proctime, TIMESTAMP(3) window_start, TIMESTAMP(3) window_end, TIME ATTRIBUTE(ROWTIME) window_time)])
+ +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4])
+ +- LogicalWatermarkAssigner(rowtime=[rowtime], watermark=[-($3, 1000:INTERVAL SECOND)])
+ +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[PROCTIME()])
+ +- LogicalTableScan(table=[[default_catalog, default_database, MyTable2]])
+]]>
+ </Resource>
+ <Resource name="optimized rel plan">
+ <![CDATA[
+WindowJoin(leftWindow=[HOP(win_start=[window_start], win_end=[window_end], size=[10 min], slide=[5 min])], rightWindow=[HOP(win_start=[window_start], win_end=[window_end], size=[10 min], slide=[5 min])], joinType=[InnerJoin], where=[=(a, a0)], select=[a, window_start, window_end, window_time, cnt, uv, a0, window_start0, window_end0, window_time0, cnt0, uv0])
+:- Exchange(distribution=[hash[a]])
+: +- Calc(select=[a, window_start, window_end, window_time, cnt, uv])
+: +- WindowAggregate(groupBy=[a], window=[HOP(time_col=[rowtime], size=[10 min], slide=[5 min])], select=[a, COUNT(*) AS cnt, COUNT(DISTINCT c) AS uv, start('w$) AS window_start, end('w$) AS window_end, rowtime('w$) AS window_time])
+: +- Exchange(distribution=[hash[a]])
+: +- Calc(select=[a, c, rowtime])
+: +- WatermarkAssigner(rowtime=[rowtime], watermark=[-(rowtime, 1000:INTERVAL SECOND)])
+: +- Calc(select=[a, b, c, rowtime, PROCTIME() AS proctime])
+: +- TableSourceScan(table=[[default_catalog, default_database, MyTable]], fields=[a, b, c, rowtime])
++- Exchange(distribution=[hash[a]])
+ +- Calc(select=[a, window_start, window_end, window_time, cnt, uv])
+ +- WindowAggregate(groupBy=[a], window=[HOP(time_col=[rowtime], size=[10 min], slide=[5 min])], select=[a, COUNT(*) AS cnt, COUNT(DISTINCT c) AS uv, start('w$) AS window_start, end('w$) AS window_end, rowtime('w$) AS window_time])
+ +- Exchange(distribution=[hash[a]])
+ +- Calc(select=[a, c, rowtime])
+ +- WatermarkAssigner(rowtime=[rowtime], watermark=[-(rowtime, 1000:INTERVAL SECOND)])
+ +- Calc(select=[a, b, c, rowtime, PROCTIME() AS proctime])
+ +- TableSourceScan(table=[[default_catalog, default_database, MyTable2]], fields=[a, b, c, rowtime])
+]]>
+ </Resource>
+ </TestCase>
+ <TestCase name="testOnHopWindowAggregateOnProctime">
+ <Resource name="sql">
+ <![CDATA[
+SELECT L.*, R.*
+FROM (
+ SELECT
+ a,
+ window_start,
+ window_end,
+ window_time,
+ count(*) as cnt,
+ count(distinct c) AS uv
+ FROM TABLE(
+ HOP(TABLE MyTable, DESCRIPTOR(proctime), INTERVAL '5' MINUTE, INTERVAL '10' MINUTE))
+ GROUP BY a, window_start, window_end, window_time
+) L
+JOIN (
+ SELECT
+ a,
+ window_start,
+ window_end,
+ window_time,
+ count(*) as cnt,
+ count(distinct c) AS uv
+ FROM TABLE(
+ HOP(TABLE MyTable2, DESCRIPTOR(proctime), INTERVAL '5' MINUTE, INTERVAL '10' MINUTE))
+ GROUP BY a, window_start, window_end, window_time
+) R
+ON L.window_start = R.window_start AND L.window_end = R.window_end AND L.a = R.a
+ ]]>
+ </Resource>
+ <Resource name="ast">
+ <![CDATA[
+LogicalProject(a=[$0], window_start=[$1], window_end=[$2], window_time=[$3], cnt=[$4], uv=[$5], a0=[$6], window_start0=[$7], window_end0=[$8], window_time0=[$9], cnt0=[$10], uv0=[$11])
++- LogicalJoin(condition=[AND(=($1, $7), =($2, $8), =($0, $6))], joinType=[inner])
+ :- LogicalAggregate(group=[{0, 1, 2, 3}], cnt=[COUNT()], uv=[COUNT(DISTINCT $4)])
+ : +- LogicalProject(a=[$0], window_start=[$5], window_end=[$6], window_time=[$7], c=[$2])
+ : +- LogicalTableFunctionScan(invocation=[HOP($4, DESCRIPTOR($4), 300000:INTERVAL MINUTE, 600000:INTERVAL MINUTE)], rowType=[RecordType(INTEGER a, VARCHAR(2147483647) b, BIGINT c, TIME ATTRIBUTE(ROWTIME) rowtime, TIME ATTRIBUTE(PROCTIME) proctime, TIMESTAMP(3) window_start, TIMESTAMP(3) window_end, TIME ATTRIBUTE(PROCTIME) window_time)])
+ : +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4])
+ : +- LogicalWatermarkAssigner(rowtime=[rowtime], watermark=[-($3, 1000:INTERVAL SECOND)])
+ : +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[PROCTIME()])
+ : +- LogicalTableScan(table=[[default_catalog, default_database, MyTable]])
+ +- LogicalAggregate(group=[{0, 1, 2, 3}], cnt=[COUNT()], uv=[COUNT(DISTINCT $4)])
+ +- LogicalProject(a=[$0], window_start=[$5], window_end=[$6], window_time=[$7], c=[$2])
+ +- LogicalTableFunctionScan(invocation=[HOP($4, DESCRIPTOR($4), 300000:INTERVAL MINUTE, 600000:INTERVAL MINUTE)], rowType=[RecordType(INTEGER a, VARCHAR(2147483647) b, BIGINT c, TIME ATTRIBUTE(ROWTIME) rowtime, TIME ATTRIBUTE(PROCTIME) proctime, TIMESTAMP(3) window_start, TIMESTAMP(3) window_end, TIME ATTRIBUTE(PROCTIME) window_time)])
+ +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4])
+ +- LogicalWatermarkAssigner(rowtime=[rowtime], watermark=[-($3, 1000:INTERVAL SECOND)])
+ +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[PROCTIME()])
+ +- LogicalTableScan(table=[[default_catalog, default_database, MyTable2]])
+]]>
+ </Resource>
+ <Resource name="optimized rel plan">
+ <![CDATA[
+Calc(select=[a, window_start, window_end, PROCTIME_MATERIALIZE(window_time) AS window_time, cnt, uv, a0, window_start0, window_end0, PROCTIME_MATERIALIZE(window_time0) AS window_time0, cnt0, uv0])
++- WindowJoin(leftWindow=[HOP(win_start=[window_start], win_end=[window_end], size=[10 min], slide=[5 min])], rightWindow=[HOP(win_start=[window_start], win_end=[window_end], size=[10 min], slide=[5 min])], joinType=[InnerJoin], where=[=(a, a0)], select=[a, window_start, window_end, window_time, cnt, uv, a0, window_start0, window_end0, window_time0, cnt0, uv0])
+ :- Exchange(distribution=[hash[a]])
+ : +- Calc(select=[a, window_start, window_end, window_time, cnt, uv])
+ : +- WindowAggregate(groupBy=[a], window=[HOP(time_col=[proctime], size=[10 min], slide=[5 min])], select=[a, COUNT(*) AS cnt, COUNT(DISTINCT c) AS uv, start('w$) AS window_start, end('w$) AS window_end, proctime('w$) AS window_time])
+ : +- Exchange(distribution=[hash[a]])
+ : +- Calc(select=[a, c, proctime])
+ : +- WatermarkAssigner(rowtime=[rowtime], watermark=[-(rowtime, 1000:INTERVAL SECOND)])
+ : +- Calc(select=[a, b, c, rowtime, PROCTIME() AS proctime])
+ : +- TableSourceScan(table=[[default_catalog, default_database, MyTable]], fields=[a, b, c, rowtime])
+ +- Exchange(distribution=[hash[a]])
+ +- Calc(select=[a, window_start, window_end, window_time, cnt, uv])
+ +- WindowAggregate(groupBy=[a], window=[HOP(time_col=[proctime], size=[10 min], slide=[5 min])], select=[a, COUNT(*) AS cnt, COUNT(DISTINCT c) AS uv, start('w$) AS window_start, end('w$) AS window_end, proctime('w$) AS window_time])
+ +- Exchange(distribution=[hash[a]])
+ +- Calc(select=[a, c, proctime])
+ +- WatermarkAssigner(rowtime=[rowtime], watermark=[-(rowtime, 1000:INTERVAL SECOND)])
+ +- Calc(select=[a, b, c, rowtime, PROCTIME() AS proctime])
+ +- TableSourceScan(table=[[default_catalog, default_database, MyTable2]], fields=[a, b, c, rowtime])
+]]>
+ </Resource>
+ </TestCase>
+ <TestCase name="testOnTumbleWindowAggregate">
+ <Resource name="sql">
+ <![CDATA[
+SELECT L.*, R.*
+FROM (
+ SELECT
+ a,
+ window_start,
+ window_end,
+ window_time,
+ count(*) as cnt,
+ count(distinct c) AS uv
+ FROM TABLE(TUMBLE(TABLE MyTable, DESCRIPTOR(rowtime), INTERVAL '15' MINUTE))
+ GROUP BY a, window_start, window_end, window_time
+) L
+JOIN (
+ SELECT
+ a,
+ window_start,
+ window_end,
+ window_time,
+ count(*) as cnt,
+ count(distinct c) AS uv
+ FROM TABLE(TUMBLE(TABLE MyTable2, DESCRIPTOR(rowtime), INTERVAL '15' MINUTE))
+ GROUP BY a, window_start, window_end, window_time
+) R
+ON L.window_start = R.window_start AND L.window_end = R.window_end AND L.a = R.a
+ ]]>
+ </Resource>
+ <Resource name="ast">
+ <![CDATA[
+LogicalProject(a=[$0], window_start=[$1], window_end=[$2], window_time=[$3], cnt=[$4], uv=[$5], a0=[$6], window_start0=[$7], window_end0=[$8], window_time0=[$9], cnt0=[$10], uv0=[$11])
++- LogicalJoin(condition=[AND(=($1, $7), =($2, $8), =($0, $6))], joinType=[inner])
+ :- LogicalAggregate(group=[{0, 1, 2, 3}], cnt=[COUNT()], uv=[COUNT(DISTINCT $4)])
+ : +- LogicalProject(a=[$0], window_start=[$5], window_end=[$6], window_time=[$7], c=[$2])
+ : +- LogicalTableFunctionScan(invocation=[TUMBLE($4, DESCRIPTOR($3), 900000:INTERVAL MINUTE)], rowType=[RecordType(INTEGER a, VARCHAR(2147483647) b, BIGINT c, TIME ATTRIBUTE(ROWTIME) rowtime, TIME ATTRIBUTE(PROCTIME) proctime, TIMESTAMP(3) window_start, TIMESTAMP(3) window_end, TIME ATTRIBUTE(ROWTIME) window_time)])
+ : +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4])
+ : +- LogicalWatermarkAssigner(rowtime=[rowtime], watermark=[-($3, 1000:INTERVAL SECOND)])
+ : +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[PROCTIME()])
+ : +- LogicalTableScan(table=[[default_catalog, default_database, MyTable]])
+ +- LogicalAggregate(group=[{0, 1, 2, 3}], cnt=[COUNT()], uv=[COUNT(DISTINCT $4)])
+ +- LogicalProject(a=[$0], window_start=[$5], window_end=[$6], window_time=[$7], c=[$2])
+ +- LogicalTableFunctionScan(invocation=[TUMBLE($4, DESCRIPTOR($3), 900000:INTERVAL MINUTE)], rowType=[RecordType(INTEGER a, VARCHAR(2147483647) b, BIGINT c, TIME ATTRIBUTE(ROWTIME) rowtime, TIME ATTRIBUTE(PROCTIME) proctime, TIMESTAMP(3) window_start, TIMESTAMP(3) window_end, TIME ATTRIBUTE(ROWTIME) window_time)])
+ +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4])
+ +- LogicalWatermarkAssigner(rowtime=[rowtime], watermark=[-($3, 1000:INTERVAL SECOND)])
+ +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[PROCTIME()])
+ +- LogicalTableScan(table=[[default_catalog, default_database, MyTable2]])
+]]>
+ </Resource>
+ <Resource name="optimized rel plan">
+ <![CDATA[
+WindowJoin(leftWindow=[TUMBLE(win_start=[window_start], win_end=[window_end], size=[15 min])], rightWindow=[TUMBLE(win_start=[window_start], win_end=[window_end], size=[15 min])], joinType=[InnerJoin], where=[=(a, a0)], select=[a, window_start, window_end, window_time, cnt, uv, a0, window_start0, window_end0, window_time0, cnt0, uv0])
+:- Exchange(distribution=[hash[a]])
+: +- Calc(select=[a, window_start, window_end, window_time, cnt, uv])
+: +- WindowAggregate(groupBy=[a], window=[TUMBLE(time_col=[rowtime], size=[15 min])], select=[a, COUNT(*) AS cnt, COUNT(DISTINCT c) AS uv, start('w$) AS window_start, end('w$) AS window_end, rowtime('w$) AS window_time])
+: +- Exchange(distribution=[hash[a]])
+: +- Calc(select=[a, c, rowtime])
+: +- WatermarkAssigner(rowtime=[rowtime], watermark=[-(rowtime, 1000:INTERVAL SECOND)])
+: +- Calc(select=[a, b, c, rowtime, PROCTIME() AS proctime])
+: +- TableSourceScan(table=[[default_catalog, default_database, MyTable]], fields=[a, b, c, rowtime])
++- Exchange(distribution=[hash[a]])
+ +- Calc(select=[a, window_start, window_end, window_time, cnt, uv])
+ +- WindowAggregate(groupBy=[a], window=[TUMBLE(time_col=[rowtime], size=[15 min])], select=[a, COUNT(*) AS cnt, COUNT(DISTINCT c) AS uv, start('w$) AS window_start, end('w$) AS window_end, rowtime('w$) AS window_time])
+ +- Exchange(distribution=[hash[a]])
+ +- Calc(select=[a, c, rowtime])
+ +- WatermarkAssigner(rowtime=[rowtime], watermark=[-(rowtime, 1000:INTERVAL SECOND)])
+ +- Calc(select=[a, b, c, rowtime, PROCTIME() AS proctime])
+ +- TableSourceScan(table=[[default_catalog, default_database, MyTable2]], fields=[a, b, c, rowtime])
+]]>
+ </Resource>
+ </TestCase>
+ <TestCase name="testOnTumbleWindowAggregateOnProctime">
+ <Resource name="sql">
+ <![CDATA[
+SELECT L.*, R.*
+FROM (
+ SELECT
+ a,
+ window_start,
+ window_end,
+ window_time,
+ count(*) as cnt,
+ count(distinct c) AS uv
+ FROM TABLE(TUMBLE(TABLE MyTable, DESCRIPTOR(proctime), INTERVAL '15' MINUTE))
+ GROUP BY a, window_start, window_end, window_time
+) L
+JOIN (
+ SELECT
+ a,
+ window_start,
+ window_end,
+ window_time,
+ count(*) as cnt,
+ count(distinct c) AS uv
+ FROM TABLE(TUMBLE(TABLE MyTable2, DESCRIPTOR(proctime), INTERVAL '15' MINUTE))
+ GROUP BY a, window_start, window_end, window_time
+) R
+ON L.window_start = R.window_start AND L.window_end = R.window_end AND L.a = R.a
+ ]]>
+ </Resource>
+ <Resource name="ast">
+ <![CDATA[
+LogicalProject(a=[$0], window_start=[$1], window_end=[$2], window_time=[$3], cnt=[$4], uv=[$5], a0=[$6], window_start0=[$7], window_end0=[$8], window_time0=[$9], cnt0=[$10], uv0=[$11])
++- LogicalJoin(condition=[AND(=($1, $7), =($2, $8), =($0, $6))], joinType=[inner])
+ :- LogicalAggregate(group=[{0, 1, 2, 3}], cnt=[COUNT()], uv=[COUNT(DISTINCT $4)])
+ : +- LogicalProject(a=[$0], window_start=[$5], window_end=[$6], window_time=[$7], c=[$2])
+ : +- LogicalTableFunctionScan(invocation=[TUMBLE($4, DESCRIPTOR($4), 900000:INTERVAL MINUTE)], rowType=[RecordType(INTEGER a, VARCHAR(2147483647) b, BIGINT c, TIME ATTRIBUTE(ROWTIME) rowtime, TIME ATTRIBUTE(PROCTIME) proctime, TIMESTAMP(3) window_start, TIMESTAMP(3) window_end, TIME ATTRIBUTE(PROCTIME) window_time)])
+ : +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4])
+ : +- LogicalWatermarkAssigner(rowtime=[rowtime], watermark=[-($3, 1000:INTERVAL SECOND)])
+ : +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[PROCTIME()])
+ : +- LogicalTableScan(table=[[default_catalog, default_database, MyTable]])
+ +- LogicalAggregate(group=[{0, 1, 2, 3}], cnt=[COUNT()], uv=[COUNT(DISTINCT $4)])
+ +- LogicalProject(a=[$0], window_start=[$5], window_end=[$6], window_time=[$7], c=[$2])
+ +- LogicalTableFunctionScan(invocation=[TUMBLE($4, DESCRIPTOR($4), 900000:INTERVAL MINUTE)], rowType=[RecordType(INTEGER a, VARCHAR(2147483647) b, BIGINT c, TIME ATTRIBUTE(ROWTIME) rowtime, TIME ATTRIBUTE(PROCTIME) proctime, TIMESTAMP(3) window_start, TIMESTAMP(3) window_end, TIME ATTRIBUTE(PROCTIME) window_time)])
+ +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4])
+ +- LogicalWatermarkAssigner(rowtime=[rowtime], watermark=[-($3, 1000:INTERVAL SECOND)])
+ +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[PROCTIME()])
+ +- LogicalTableScan(table=[[default_catalog, default_database, MyTable2]])
+]]>
+ </Resource>
+ <Resource name="optimized rel plan">
+ <![CDATA[
+Calc(select=[a, window_start, window_end, PROCTIME_MATERIALIZE(window_time) AS window_time, cnt, uv, a0, window_start0, window_end0, PROCTIME_MATERIALIZE(window_time0) AS window_time0, cnt0, uv0])
++- WindowJoin(leftWindow=[TUMBLE(win_start=[window_start], win_end=[window_end], size=[15 min])], rightWindow=[TUMBLE(win_start=[window_start], win_end=[window_end], size=[15 min])], joinType=[InnerJoin], where=[=(a, a0)], select=[a, window_start, window_end, window_time, cnt, uv, a0, window_start0, window_end0, window_time0, cnt0, uv0])
+ :- Exchange(distribution=[hash[a]])
+ : +- Calc(select=[a, window_start, window_end, window_time, cnt, uv])
+ : +- WindowAggregate(groupBy=[a], window=[TUMBLE(time_col=[proctime], size=[15 min])], select=[a, COUNT(*) AS cnt, COUNT(DISTINCT c) AS uv, start('w$) AS window_start, end('w$) AS window_end, proctime('w$) AS window_time])
+ : +- Exchange(distribution=[hash[a]])
+ : +- Calc(select=[a, c, proctime])
+ : +- WatermarkAssigner(rowtime=[rowtime], watermark=[-(rowtime, 1000:INTERVAL SECOND)])
+ : +- Calc(select=[a, b, c, rowtime, PROCTIME() AS proctime])
+ : +- TableSourceScan(table=[[default_catalog, default_database, MyTable]], fields=[a, b, c, rowtime])
+ +- Exchange(distribution=[hash[a]])
+ +- Calc(select=[a, window_start, window_end, window_time, cnt, uv])
+ +- WindowAggregate(groupBy=[a], window=[TUMBLE(time_col=[proctime], size=[15 min])], select=[a, COUNT(*) AS cnt, COUNT(DISTINCT c) AS uv, start('w$) AS window_start, end('w$) AS window_end, proctime('w$) AS window_time])
+ +- Exchange(distribution=[hash[a]])
+ +- Calc(select=[a, c, proctime])
+ +- WatermarkAssigner(rowtime=[rowtime], watermark=[-(rowtime, 1000:INTERVAL SECOND)])
+ +- Calc(select=[a, b, c, rowtime, PROCTIME() AS proctime])
+ +- TableSourceScan(table=[[default_catalog, default_database, MyTable2]], fields=[a, b, c, rowtime])
+]]>
+ </Resource>
+ </TestCase>
+ <TestCase name="testTimeAttributePropagateForWindowJoin">
+ <Resource name="sql">
+ <![CDATA[
+SELECT tmp.*, MyTable3.* FROM tmp JOIN MyTable3 ON
+ tmp.a = MyTable3.a AND
+ tmp.rowtime BETWEEN
+ MyTable3.rowtime - INTERVAL '10' SECOND AND
+ MyTable3.rowtime + INTERVAL '1' HOUR
+]]>
+ </Resource>
+ <Resource name="ast">
+ <![CDATA[
+LogicalProject(rowtime=[$0], a=[$1], l_b=[$2], l_c=[$3], r_b=[$4], r_c=[$5], a0=[$6], b=[$7], c=[$8], rowtime0=[$9], proctime=[$10])
++- LogicalJoin(condition=[AND(=($1, $6), >=($0, -($9, 10000:INTERVAL SECOND)), <=($0, +($9, 3600000:INTERVAL HOUR)))], joinType=[inner])
+ :- LogicalProject(rowtime=[$7], a=[$0], l_b=[$1], l_c=[$2], r_b=[$9], r_c=[$10])
+ : +- LogicalJoin(condition=[AND(=($5, $13), =($6, $14), =($0, $8))], joinType=[inner])
+ : :- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4], window_start=[$5], window_end=[$6], window_time=[$7])
+ : : +- LogicalTableFunctionScan(invocation=[TUMBLE($4, DESCRIPTOR($3), 900000:INTERVAL MINUTE)], rowType=[RecordType(INTEGER a, VARCHAR(2147483647) b, BIGINT c, TIME ATTRIBUTE(ROWTIME) rowtime, TIME ATTRIBUTE(PROCTIME) proctime, TIMESTAMP(3) window_start, TIMESTAMP(3) window_end, TIME ATTRIBUTE(ROWTIME) window_time)])
+ : : +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4])
+ : : +- LogicalWatermarkAssigner(rowtime=[rowtime], watermark=[-($3, 1000:INTERVAL SECOND)])
+ : : +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[PROCTIME()])
+ : : +- LogicalTableScan(table=[[default_catalog, default_database, MyTable]])
+ : +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4], window_start=[$5], window_end=[$6], window_time=[$7])
+ : +- LogicalTableFunctionScan(invocation=[TUMBLE($4, DESCRIPTOR($3), 900000:INTERVAL MINUTE)], rowType=[RecordType(INTEGER a, VARCHAR(2147483647) b, BIGINT c, TIME ATTRIBUTE(ROWTIME) rowtime, TIME ATTRIBUTE(PROCTIME) proctime, TIMESTAMP(3) window_start, TIMESTAMP(3) window_end, TIME ATTRIBUTE(ROWTIME) window_time)])
+ : +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4])
+ : +- LogicalWatermarkAssigner(rowtime=[rowtime], watermark=[-($3, 1000:INTERVAL SECOND)])
+ : +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[PROCTIME()])
+ : +- LogicalTableScan(table=[[default_catalog, default_database, MyTable2]])
+ +- LogicalWatermarkAssigner(rowtime=[rowtime], watermark=[-($3, 1000:INTERVAL SECOND)])
+ +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[PROCTIME()])
+ +- LogicalTableScan(table=[[default_catalog, default_database, MyTable3]])
+]]>
+ </Resource>
+ <Resource name="optimized rel plan">
+ <![CDATA[
+Calc(select=[rowtime, a, l_b, l_c, r_b, r_c, a0, b, c, rowtime0, PROCTIME_MATERIALIZE(proctime) AS proctime])
++- IntervalJoin(joinType=[InnerJoin], windowBounds=[isRowTime=true, leftLowerBound=-10000, leftUpperBound=3600000, leftTimeIndex=0, rightTimeIndex=3], where=[AND(=(a, a0), >=(rowtime, -(rowtime0, 10000:INTERVAL SECOND)), <=(rowtime, +(rowtime0, 3600000:INTERVAL HOUR)))], select=[rowtime, a, l_b, l_c, r_b, r_c, a0, b, c, rowtime0, proctime])
+ :- Exchange(distribution=[hash[a]])
+ : +- Calc(select=[window_time AS rowtime, a, b AS l_b, c AS l_c, b0 AS r_b, c0 AS r_c])
+ : +- WindowJoin(leftWindow=[TUMBLE(win_start=[window_start], win_end=[window_end], size=[15 min])], rightWindow=[TUMBLE(win_start=[window_start], win_end=[window_end], size=[15 min])], joinType=[InnerJoin], where=[=(a, a0)], select=[a, b, c, window_start, window_end, window_time, a0, b0, c0, window_start0, window_end0])
+ : :- Exchange(distribution=[hash[a]])
+ : : +- Calc(select=[a, b, c, window_start, window_end, window_time])
+ : : +- WindowTableFunction(window=[TUMBLE(time_col=[rowtime], size=[15 min])])
+ : : +- WatermarkAssigner(rowtime=[rowtime], watermark=[-(rowtime, 1000:INTERVAL SECOND)])
+ : : +- Calc(select=[a, b, c, rowtime, PROCTIME() AS proctime])
+ : : +- TableSourceScan(table=[[default_catalog, default_database, MyTable]], fields=[a, b, c, rowtime])
+ : +- Exchange(distribution=[hash[a]])
+ : +- Calc(select=[a, b, c, window_start, window_end])
+ : +- WindowTableFunction(window=[TUMBLE(time_col=[rowtime], size=[15 min])])
+ : +- WatermarkAssigner(rowtime=[rowtime], watermark=[-(rowtime, 1000:INTERVAL SECOND)])
+ : +- Calc(select=[a, b, c, rowtime, PROCTIME() AS proctime])
+ : +- TableSourceScan(table=[[default_catalog, default_database, MyTable2]], fields=[a, b, c, rowtime])
+ +- Exchange(distribution=[hash[a]])
+ +- WatermarkAssigner(rowtime=[rowtime], watermark=[-(rowtime, 1000:INTERVAL SECOND)])
+ +- Calc(select=[a, b, c, rowtime, PROCTIME() AS proctime])
+ +- TableSourceScan(table=[[default_catalog, default_database, MyTable3]], fields=[a, b, c, rowtime])
+]]>
+ </Resource>
+ </TestCase>
+ <TestCase name="testWindowJoinWithNonEqui">
+ <Resource name="sql">
+ <![CDATA[
+SELECT L.*, R.*
+FROM (
+ SELECT
+ a,
+ window_start,
+ window_end,
+ window_time,
+ count(*) as cnt,
+ count(distinct c) AS uv
+ FROM TABLE(
+ CUMULATE(
+ TABLE MyTable, DESCRIPTOR(proctime), INTERVAL '10' MINUTE, INTERVAL '1' HOUR))
+ GROUP BY a, window_start, window_end, window_time
+) L
+JOIN (
+ SELECT
+ a,
+ window_start,
+ window_end,
+ window_time,
+ count(*) as cnt,
+ count(distinct c) AS uv
+ FROM TABLE(
+ CUMULATE(
+ TABLE MyTable2, DESCRIPTOR(proctime), INTERVAL '10' MINUTE, INTERVAL '1' HOUR))
+ GROUP BY a, window_start, window_end, window_time
+) R
+ON L.window_start = R.window_start AND L.window_end = R.window_end AND L.a = R.a AND
+ CAST(L.window_start AS BIGINT) > R.uv
+ ]]>
+ </Resource>
+ <Resource name="ast">
+ <![CDATA[
+LogicalProject(a=[$0], window_start=[$1], window_end=[$2], window_time=[$3], cnt=[$4], uv=[$5], a0=[$6], window_start0=[$7], window_end0=[$8], window_time0=[$9], cnt0=[$10], uv0=[$11])
++- LogicalJoin(condition=[AND(=($1, $7), =($2, $8), =($0, $6), >(CAST($1):BIGINT NOT NULL, $11))], joinType=[inner])
+ :- LogicalAggregate(group=[{0, 1, 2, 3}], cnt=[COUNT()], uv=[COUNT(DISTINCT $4)])
+ : +- LogicalProject(a=[$0], window_start=[$5], window_end=[$6], window_time=[$7], c=[$2])
+ : +- LogicalTableFunctionScan(invocation=[CUMULATE($4, DESCRIPTOR($4), 600000:INTERVAL MINUTE, 3600000:INTERVAL HOUR)], rowType=[RecordType(INTEGER a, VARCHAR(2147483647) b, BIGINT c, TIME ATTRIBUTE(ROWTIME) rowtime, TIME ATTRIBUTE(PROCTIME) proctime, TIMESTAMP(3) window_start, TIMESTAMP(3) window_end, TIME ATTRIBUTE(PROCTIME) window_time)])
+ : +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4])
+ : +- LogicalWatermarkAssigner(rowtime=[rowtime], watermark=[-($3, 1000:INTERVAL SECOND)])
+ : +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[PROCTIME()])
+ : +- LogicalTableScan(table=[[default_catalog, default_database, MyTable]])
+ +- LogicalAggregate(group=[{0, 1, 2, 3}], cnt=[COUNT()], uv=[COUNT(DISTINCT $4)])
+ +- LogicalProject(a=[$0], window_start=[$5], window_end=[$6], window_time=[$7], c=[$2])
+ +- LogicalTableFunctionScan(invocation=[CUMULATE($4, DESCRIPTOR($4), 600000:INTERVAL MINUTE, 3600000:INTERVAL HOUR)], rowType=[RecordType(INTEGER a, VARCHAR(2147483647) b, BIGINT c, TIME ATTRIBUTE(ROWTIME) rowtime, TIME ATTRIBUTE(PROCTIME) proctime, TIMESTAMP(3) window_start, TIMESTAMP(3) window_end, TIME ATTRIBUTE(PROCTIME) window_time)])
+ +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4])
+ +- LogicalWatermarkAssigner(rowtime=[rowtime], watermark=[-($3, 1000:INTERVAL SECOND)])
+ +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[PROCTIME()])
+ +- LogicalTableScan(table=[[default_catalog, default_database, MyTable2]])
+]]>
+ </Resource>
+ <Resource name="optimized rel plan">
+ <![CDATA[
+Calc(select=[a, window_start, window_end, PROCTIME_MATERIALIZE(window_time) AS window_time, cnt, uv, a0, window_start0, window_end0, PROCTIME_MATERIALIZE(window_time0) AS window_time0, cnt0, uv0])
++- WindowJoin(leftWindow=[CUMULATE(win_start=[window_start], win_end=[window_end], max_size=[1 h], step=[10 min])], rightWindow=[CUMULATE(win_start=[window_start], win_end=[window_end], max_size=[1 h], step=[10 min])], joinType=[InnerJoin], where=[AND(=(a, a0), >(CAST(window_start), uv0))], select=[a, window_start, window_end, window_time, cnt, uv, a0, window_start0, window_end0, window_time0, cnt0, uv0])
+ :- Exchange(distribution=[hash[a]])
+ : +- Calc(select=[a, window_start, window_end, window_time, cnt, uv])
+ : +- WindowAggregate(groupBy=[a], window=[CUMULATE(time_col=[proctime], max_size=[1 h], step=[10 min])], select=[a, COUNT(*) AS cnt, COUNT(DISTINCT c) AS uv, start('w$) AS window_start, end('w$) AS window_end, proctime('w$) AS window_time])
+ : +- Exchange(distribution=[hash[a]])
+ : +- Calc(select=[a, c, proctime])
+ : +- WatermarkAssigner(rowtime=[rowtime], watermark=[-(rowtime, 1000:INTERVAL SECOND)])
+ : +- Calc(select=[a, b, c, rowtime, PROCTIME() AS proctime])
+ : +- TableSourceScan(table=[[default_catalog, default_database, MyTable]], fields=[a, b, c, rowtime])
+ +- Exchange(distribution=[hash[a]])
+ +- Calc(select=[a, window_start, window_end, window_time, cnt, uv])
+ +- WindowAggregate(groupBy=[a], window=[CUMULATE(time_col=[proctime], max_size=[1 h], step=[10 min])], select=[a, COUNT(*) AS cnt, COUNT(DISTINCT c) AS uv, start('w$) AS window_start, end('w$) AS window_end, proctime('w$) AS window_time])
+ +- Exchange(distribution=[hash[a]])
+ +- Calc(select=[a, c, proctime])
+ +- WatermarkAssigner(rowtime=[rowtime], watermark=[-(rowtime, 1000:INTERVAL SECOND)])
+ +- Calc(select=[a, b, c, rowtime, PROCTIME() AS proctime])
+ +- TableSourceScan(table=[[default_catalog, default_database, MyTable2]], fields=[a, b, c, rowtime])
+]]>
+ </Resource>
+ </TestCase>
+ <TestCase name="testWindowPropertyPropagateForWindowJoin">
+ <Resource name="sql">
+ <![CDATA[
+SELECT * FROM
+(
+ SELECT *,
+ ROW_NUMBER() OVER(
+ PARTITION BY window_start, window_end ORDER BY l_cnt DESC) as rownum
+ FROM tmp2
+)
+WHERE rownum <= 3
+ ]]>
+ </Resource>
+ <Resource name="ast">
+ <![CDATA[
+LogicalProject(window_start=[$0], window_end=[$1], a=[$2], l_cnt=[$3], l_uv=[$4], r_cnt=[$5], r_uv=[$6], rownum=[$7])
++- LogicalFilter(condition=[<=($7, 3)])
+ +- LogicalProject(window_start=[$1], window_end=[$2], a=[$0], l_cnt=[$4], l_uv=[$5], r_cnt=[$10], r_uv=[$11], rownum=[ROW_NUMBER() OVER (PARTITION BY $1, $2 ORDER BY $4 DESC NULLS LAST)])
+ +- LogicalJoin(condition=[AND(=($1, $7), =($2, $8), =($0, $6))], joinType=[inner])
+ :- LogicalAggregate(group=[{0, 1, 2, 3}], cnt=[COUNT()], uv=[COUNT(DISTINCT $4)])
+ : +- LogicalProject(a=[$0], window_start=[$5], window_end=[$6], window_time=[$7], c=[$2])
+ : +- LogicalTableFunctionScan(invocation=[CUMULATE($4, DESCRIPTOR($3), 600000:INTERVAL MINUTE, 3600000:INTERVAL HOUR)], rowType=[RecordType(INTEGER a, VARCHAR(2147483647) b, BIGINT c, TIME ATTRIBUTE(ROWTIME) rowtime, TIME ATTRIBUTE(PROCTIME) proctime, TIMESTAMP(3) window_start, TIMESTAMP(3) window_end, TIME ATTRIBUTE(ROWTIME) window_time)])
+ : +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4])
+ : +- LogicalWatermarkAssigner(rowtime=[rowtime], watermark=[-($3, 1000:INTERVAL SECOND)])
+ : +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[PROCTIME()])
+ : +- LogicalTableScan(table=[[default_catalog, default_database, MyTable]])
+ +- LogicalAggregate(group=[{0, 1, 2, 3}], cnt=[COUNT()], uv=[COUNT(DISTINCT $4)])
+ +- LogicalProject(a=[$0], window_start=[$5], window_end=[$6], window_time=[$7], c=[$2])
+ +- LogicalTableFunctionScan(invocation=[CUMULATE($4, DESCRIPTOR($3), 600000:INTERVAL MINUTE, 3600000:INTERVAL HOUR)], rowType=[RecordType(INTEGER a, VARCHAR(2147483647) b, BIGINT c, TIME ATTRIBUTE(ROWTIME) rowtime, TIME ATTRIBUTE(PROCTIME) proctime, TIMESTAMP(3) window_start, TIMESTAMP(3) window_end, TIME ATTRIBUTE(ROWTIME) window_time)])
+ +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4])
+ +- LogicalWatermarkAssigner(rowtime=[rowtime], watermark=[-($3, 1000:INTERVAL SECOND)])
+ +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[PROCTIME()])
+ +- LogicalTableScan(table=[[default_catalog, default_database, MyTable2]])
+]]>
+ </Resource>
+ <Resource name="optimized rel plan">
+ <![CDATA[
+Calc(select=[window_start, window_end, a, cnt AS l_cnt, uv AS l_uv, cnt0 AS r_cnt, uv0 AS r_uv, rownum])
++- Rank(strategy=[AppendFastStrategy], rankType=[ROW_NUMBER], rankRange=[rankStart=1, rankEnd=3], partitionBy=[window_start, window_end], orderBy=[cnt DESC], select=[a, window_start, window_end, window_time, cnt, uv, a0, window_start0, window_end0, window_time0, cnt0, uv0, rownum])
Review comment:
Good catch, I missed windowProperties inference for `FlinkLogicalJoin` in `FlinkRelMdWindowProperties`.
----------------------------------------------------------------
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:
users@infra.apache.org
[GitHub] [flink] wuchong commented on a change in pull request #15195: [FLINK-19609][table-planner-blink] Support streaming window join in planner
Posted by GitBox <gi...@apache.org>.
wuchong commented on a change in pull request #15195:
URL: https://github.com/apache/flink/pull/15195#discussion_r594200757
##########
File path: flink-table/flink-table-planner-blink/src/main/scala/org/apache/flink/table/planner/plan/utils/WindowJoinUtil.scala
##########
@@ -0,0 +1,219 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.planner.plan.utils
+
+import org.apache.flink.table.api.TableException
+import org.apache.flink.table.planner.plan.metadata.FlinkRelMetadataQuery
+import org.apache.flink.table.planner.plan.nodes.logical.FlinkLogicalJoin
+import org.apache.flink.table.planner.plan.`trait`.RelWindowProperties
+
+import org.apache.calcite.rex.{RexInputRef, RexNode, RexUtil}
+import org.apache.calcite.sql.fun.SqlStdOperatorTable
+import org.apache.calcite.util.ImmutableIntList
+
+import scala.collection.JavaConversions._
+import scala.collection.mutable
+
+/**
+ * Util for window join.
+ */
+object WindowJoinUtil {
+
+ /**
+ * Get window properties of left and right child.
+ *
+ * @param join input join
+ * @return window properties of left and right child.
+ */
+ def getChildWindowProperties(
+ join: FlinkLogicalJoin): (RelWindowProperties, RelWindowProperties) = {
+ val fmq = FlinkRelMetadataQuery.reuseOrCreate(join.getCluster.getMetadataQuery)
+ (fmq.getRelWindowProperties(join.getLeft), fmq.getRelWindowProperties(join.getRight))
+ }
+
+ /**
+ * Checks whether join condition contains window starts equality of input tables or window
+ * ends equality of input tables.
+ *
+ * @param join input join
+ * @return True if join condition contains window starts equality of input tables and window
+ * ends equality of input tables. Else false.
+ */
+ def containsWindowStartEqualityOrEndEquality(join: FlinkLogicalJoin): Boolean = {
Review comment:
```suggestion
def containsWindowStartEqualityAndEndEquality(join: FlinkLogicalJoin): Boolean = {
```
##########
File path: flink-table/flink-table-planner-blink/src/main/scala/org/apache/flink/table/planner/plan/utils/WindowJoinUtil.scala
##########
@@ -0,0 +1,219 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.planner.plan.utils
+
+import org.apache.flink.table.api.TableException
+import org.apache.flink.table.planner.plan.metadata.FlinkRelMetadataQuery
+import org.apache.flink.table.planner.plan.nodes.logical.FlinkLogicalJoin
+import org.apache.flink.table.planner.plan.`trait`.RelWindowProperties
+
+import org.apache.calcite.rex.{RexInputRef, RexNode, RexUtil}
+import org.apache.calcite.sql.fun.SqlStdOperatorTable
+import org.apache.calcite.util.ImmutableIntList
+
+import scala.collection.JavaConversions._
+import scala.collection.mutable
+
+/**
+ * Util for window join.
+ */
+object WindowJoinUtil {
+
+ /**
+ * Get window properties of left and right child.
+ *
+ * @param join input join
+ * @return window properties of left and right child.
+ */
+ def getChildWindowProperties(
+ join: FlinkLogicalJoin): (RelWindowProperties, RelWindowProperties) = {
+ val fmq = FlinkRelMetadataQuery.reuseOrCreate(join.getCluster.getMetadataQuery)
+ (fmq.getRelWindowProperties(join.getLeft), fmq.getRelWindowProperties(join.getRight))
+ }
+
+ /**
+ * Checks whether join condition contains window starts equality of input tables or window
+ * ends equality of input tables.
+ *
+ * @param join input join
+ * @return True if join condition contains window starts equality of input tables and window
+ * ends equality of input tables. Else false.
+ */
+ def containsWindowStartEqualityOrEndEquality(join: FlinkLogicalJoin): Boolean = {
+ val (windowStartEqualityLeftKeys, windowEndEqualityLeftKeys, _, _) =
+ excludeWindowStartEqualityAndEndEqualityFromJoinInfoPairs(join)
+ windowStartEqualityLeftKeys.nonEmpty && windowEndEqualityLeftKeys.nonEmpty
+ }
+
+ /**
+ * Excludes window starts equality and window ends equality from join info.
+ *
+ * @param join input join
+ * @return Remain join information after excludes window starts equality and window ends
+ * equality from join.
+ * The first element is left join keys of window starts equality,
+ * the second element is left join keys of window ends equality,
+ * the third element is right join keys of window starts equality,
+ * the forth element is right join keys of window ends equality,
+ * the fifth element is remain left join keys,
+ * the sixth element is remain right join keys,
+ * the last element is remain join condition which includes remain equal condition and
+ * non-equal condition.
+ */
+ def excludeWindowStartEqualityAndEndEqualityFromJoinCondition(
+ join: FlinkLogicalJoin): (
+ ImmutableIntList,
+ ImmutableIntList,
+ ImmutableIntList,
+ ImmutableIntList,
+ ImmutableIntList,
+ ImmutableIntList,
+ RexNode) = {
+ val (
+ windowStartEqualityLeftKeys,
+ windowEndEqualityLeftKeys,
+ windowStartEqualityRightKeys,
+ windowEndEqualityRightKeys) =
+ excludeWindowStartEqualityAndEndEqualityFromJoinInfoPairs(join)
+
+ val joinInfo = join.analyzeCondition()
+ val (remainLeftKeys, remainRightKeys, remainCondition) = if (
+ windowStartEqualityLeftKeys.nonEmpty || windowEndEqualityLeftKeys.nonEmpty) {
+ val joinFieldsType = join.getRowType.getFieldList
+ val leftFieldCnt = join.getLeft.getRowType.getFieldCount
+ val rexBuilder = join.getCluster.getRexBuilder
+ val remainEquals = mutable.ArrayBuffer[RexNode]()
+ val remainLeftKeysArray = mutable.ArrayBuffer[Int]()
+ val remainRightKeysArray = mutable.ArrayBuffer[Int]()
+ // convert remain pairs to RexInputRef tuple for building SqlStdOperatorTable.EQUALS calls
+ joinInfo.pairs().foreach { p =>
+ if (!windowStartEqualityLeftKeys.contains(p.source) &&
+ !windowEndEqualityLeftKeys.contains(p.source)) {
+ val leftFieldType = joinFieldsType.get(p.source).getType
+ val leftInputRef = new RexInputRef(p.source, leftFieldType)
+ val rightIndex = leftFieldCnt + p.target
+ val rightFieldType = joinFieldsType.get(rightIndex).getType
+ val rightInputRef = new RexInputRef(rightIndex, rightFieldType)
+ val remainEqual = rexBuilder.makeCall(
+ SqlStdOperatorTable.EQUALS,
+ leftInputRef,
+ rightInputRef)
+ remainEquals.add(remainEqual)
+ remainLeftKeysArray.add(p.source)
+ remainRightKeysArray.add(p.target)
+ }
+ }
+ val remainAnds = remainEquals ++ joinInfo.nonEquiConditions
+ (
+ toImmutableIntList(remainLeftKeysArray),
+ toImmutableIntList(remainRightKeysArray),
+ // build a new condition
+ RexUtil.composeConjunction(rexBuilder, remainAnds.toList))
+ } else {
+ (joinInfo.leftKeys, joinInfo.rightKeys, join.getCondition)
+ }
+
+ (
+ windowStartEqualityLeftKeys,
+ windowEndEqualityLeftKeys,
+ windowStartEqualityRightKeys,
+ windowEndEqualityRightKeys,
+ remainLeftKeys,
+ remainRightKeys,
+ remainCondition)
+ }
+
+ /**
+ * Excludes window start equality and window end equality from JoinInfo pairs.
+ *
+ * @param join the join to split
+ * @return The remain part of JoinInfo pairs after excludes window start equality and window
+ * end equality from JoinInfo pairs.
+ * The first element is left join keys of window starts equality,
+ * the second element is left join keys of window ends equality,
+ * the third element is right join keys of window starts equality,
+ * the forth element is right join keys of window ends equality.
+ */
+ private def excludeWindowStartEqualityAndEndEqualityFromJoinInfoPairs(
+ join: FlinkLogicalJoin): (
+ ImmutableIntList, ImmutableIntList, ImmutableIntList, ImmutableIntList) = {
+ val joinInfo = join.analyzeCondition()
+ val (leftWindowProperties, rightWindowProperties) = getChildWindowProperties(join)
+
+ val windowStartEqualityLeftKeys = mutable.ArrayBuffer[Int]()
+ val windowEndEqualityLeftKeys = mutable.ArrayBuffer[Int]()
+ val windowStartEqualityRightKeys = mutable.ArrayBuffer[Int]()
+ val windowEndEqualityRightKeys = mutable.ArrayBuffer[Int]()
+
+ if (leftWindowProperties != null && rightWindowProperties != null) {
+ val leftWindowStartColumns = leftWindowProperties.getWindowStartColumns
+ val rightWindowStartColumns = rightWindowProperties.getWindowStartColumns
+ val leftWindowEndColumns = leftWindowProperties.getWindowEndColumns
+ val rightWindowEndColumns = rightWindowProperties.getWindowEndColumns
+
+ joinInfo.pairs().foreach { pair =>
+ val leftKey = pair.source
+ val rightKey = pair.target
+ if (leftWindowStartColumns.get(leftKey) && rightWindowStartColumns.get(rightKey)) {
+ windowStartEqualityLeftKeys.add(leftKey)
+ windowStartEqualityRightKeys.add(rightKey)
+ } else if (leftWindowEndColumns.get(leftKey) && rightWindowEndColumns.get(rightKey)) {
+ windowEndEqualityLeftKeys.add(leftKey)
+ windowEndEqualityRightKeys.add(rightKey)
+ }
+ }
+ }
+
+ // Validate join
+ if (windowStartEqualityLeftKeys.nonEmpty && windowEndEqualityLeftKeys.nonEmpty) {
+ if (
+ leftWindowProperties.getTimeAttributeType != rightWindowProperties.getTimeAttributeType) {
+ throw new TableException(
+ s"""
+ |Currently, time attribute type of left and right inputs should be both row-time or
+ |both proc-time. In the future, we could support different time attribute type.
+ |""".stripMargin)
+ } else if (leftWindowProperties.getWindowSpec != rightWindowProperties.getWindowSpec) {
+ throw new TableException(
+ s"""
+ |Currently, the windowing TVFs must be the same of left and right inputs.
+ |In the future, we could support different window TVFs, for example, tumbling windows
+ | join sliding windows with the same window size.
+ |""".stripMargin)
Review comment:
We should make it clear what's the current operator, and what's the difference.
> Currently, window join doesn't support different window table function of left and right inputs. The left window table function is %s, the right window table function is %s.
##########
File path: flink-table/flink-table-planner-blink/src/main/scala/org/apache/flink/table/planner/plan/utils/WindowJoinUtil.scala
##########
@@ -0,0 +1,219 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.planner.plan.utils
+
+import org.apache.flink.table.api.TableException
+import org.apache.flink.table.planner.plan.metadata.FlinkRelMetadataQuery
+import org.apache.flink.table.planner.plan.nodes.logical.FlinkLogicalJoin
+import org.apache.flink.table.planner.plan.`trait`.RelWindowProperties
+
+import org.apache.calcite.rex.{RexInputRef, RexNode, RexUtil}
+import org.apache.calcite.sql.fun.SqlStdOperatorTable
+import org.apache.calcite.util.ImmutableIntList
+
+import scala.collection.JavaConversions._
+import scala.collection.mutable
+
+/**
+ * Util for window join.
+ */
+object WindowJoinUtil {
+
+ /**
+ * Get window properties of left and right child.
+ *
+ * @param join input join
+ * @return window properties of left and right child.
+ */
+ def getChildWindowProperties(
+ join: FlinkLogicalJoin): (RelWindowProperties, RelWindowProperties) = {
+ val fmq = FlinkRelMetadataQuery.reuseOrCreate(join.getCluster.getMetadataQuery)
+ (fmq.getRelWindowProperties(join.getLeft), fmq.getRelWindowProperties(join.getRight))
+ }
+
+ /**
+ * Checks whether join condition contains window starts equality of input tables or window
+ * ends equality of input tables.
+ *
+ * @param join input join
+ * @return True if join condition contains window starts equality of input tables and window
+ * ends equality of input tables. Else false.
+ */
+ def containsWindowStartEqualityOrEndEquality(join: FlinkLogicalJoin): Boolean = {
+ val (windowStartEqualityLeftKeys, windowEndEqualityLeftKeys, _, _) =
+ excludeWindowStartEqualityAndEndEqualityFromJoinInfoPairs(join)
+ windowStartEqualityLeftKeys.nonEmpty && windowEndEqualityLeftKeys.nonEmpty
+ }
+
+ /**
+ * Excludes window starts equality and window ends equality from join info.
+ *
+ * @param join input join
+ * @return Remain join information after excludes window starts equality and window ends
+ * equality from join.
+ * The first element is left join keys of window starts equality,
+ * the second element is left join keys of window ends equality,
+ * the third element is right join keys of window starts equality,
+ * the forth element is right join keys of window ends equality,
+ * the fifth element is remain left join keys,
+ * the sixth element is remain right join keys,
+ * the last element is remain join condition which includes remain equal condition and
+ * non-equal condition.
+ */
+ def excludeWindowStartEqualityAndEndEqualityFromJoinCondition(
+ join: FlinkLogicalJoin): (
+ ImmutableIntList,
+ ImmutableIntList,
+ ImmutableIntList,
+ ImmutableIntList,
+ ImmutableIntList,
+ ImmutableIntList,
+ RexNode) = {
+ val (
+ windowStartEqualityLeftKeys,
+ windowEndEqualityLeftKeys,
+ windowStartEqualityRightKeys,
+ windowEndEqualityRightKeys) =
+ excludeWindowStartEqualityAndEndEqualityFromJoinInfoPairs(join)
+
+ val joinInfo = join.analyzeCondition()
+ val (remainLeftKeys, remainRightKeys, remainCondition) = if (
+ windowStartEqualityLeftKeys.nonEmpty || windowEndEqualityLeftKeys.nonEmpty) {
+ val joinFieldsType = join.getRowType.getFieldList
+ val leftFieldCnt = join.getLeft.getRowType.getFieldCount
+ val rexBuilder = join.getCluster.getRexBuilder
+ val remainEquals = mutable.ArrayBuffer[RexNode]()
+ val remainLeftKeysArray = mutable.ArrayBuffer[Int]()
+ val remainRightKeysArray = mutable.ArrayBuffer[Int]()
+ // convert remain pairs to RexInputRef tuple for building SqlStdOperatorTable.EQUALS calls
+ joinInfo.pairs().foreach { p =>
+ if (!windowStartEqualityLeftKeys.contains(p.source) &&
+ !windowEndEqualityLeftKeys.contains(p.source)) {
+ val leftFieldType = joinFieldsType.get(p.source).getType
+ val leftInputRef = new RexInputRef(p.source, leftFieldType)
+ val rightIndex = leftFieldCnt + p.target
+ val rightFieldType = joinFieldsType.get(rightIndex).getType
+ val rightInputRef = new RexInputRef(rightIndex, rightFieldType)
+ val remainEqual = rexBuilder.makeCall(
+ SqlStdOperatorTable.EQUALS,
+ leftInputRef,
+ rightInputRef)
+ remainEquals.add(remainEqual)
+ remainLeftKeysArray.add(p.source)
+ remainRightKeysArray.add(p.target)
+ }
+ }
+ val remainAnds = remainEquals ++ joinInfo.nonEquiConditions
+ (
+ toImmutableIntList(remainLeftKeysArray),
+ toImmutableIntList(remainRightKeysArray),
+ // build a new condition
+ RexUtil.composeConjunction(rexBuilder, remainAnds.toList))
+ } else {
+ (joinInfo.leftKeys, joinInfo.rightKeys, join.getCondition)
+ }
+
+ (
+ windowStartEqualityLeftKeys,
+ windowEndEqualityLeftKeys,
+ windowStartEqualityRightKeys,
+ windowEndEqualityRightKeys,
+ remainLeftKeys,
+ remainRightKeys,
+ remainCondition)
+ }
+
+ /**
+ * Excludes window start equality and window end equality from JoinInfo pairs.
+ *
+ * @param join the join to split
+ * @return The remain part of JoinInfo pairs after excludes window start equality and window
+ * end equality from JoinInfo pairs.
+ * The first element is left join keys of window starts equality,
+ * the second element is left join keys of window ends equality,
+ * the third element is right join keys of window starts equality,
+ * the forth element is right join keys of window ends equality.
+ */
+ private def excludeWindowStartEqualityAndEndEqualityFromJoinInfoPairs(
+ join: FlinkLogicalJoin): (
+ ImmutableIntList, ImmutableIntList, ImmutableIntList, ImmutableIntList) = {
+ val joinInfo = join.analyzeCondition()
+ val (leftWindowProperties, rightWindowProperties) = getChildWindowProperties(join)
+
+ val windowStartEqualityLeftKeys = mutable.ArrayBuffer[Int]()
+ val windowEndEqualityLeftKeys = mutable.ArrayBuffer[Int]()
+ val windowStartEqualityRightKeys = mutable.ArrayBuffer[Int]()
+ val windowEndEqualityRightKeys = mutable.ArrayBuffer[Int]()
+
+ if (leftWindowProperties != null && rightWindowProperties != null) {
+ val leftWindowStartColumns = leftWindowProperties.getWindowStartColumns
+ val rightWindowStartColumns = rightWindowProperties.getWindowStartColumns
+ val leftWindowEndColumns = leftWindowProperties.getWindowEndColumns
+ val rightWindowEndColumns = rightWindowProperties.getWindowEndColumns
+
+ joinInfo.pairs().foreach { pair =>
+ val leftKey = pair.source
+ val rightKey = pair.target
+ if (leftWindowStartColumns.get(leftKey) && rightWindowStartColumns.get(rightKey)) {
+ windowStartEqualityLeftKeys.add(leftKey)
+ windowStartEqualityRightKeys.add(rightKey)
+ } else if (leftWindowEndColumns.get(leftKey) && rightWindowEndColumns.get(rightKey)) {
+ windowEndEqualityLeftKeys.add(leftKey)
+ windowEndEqualityRightKeys.add(rightKey)
+ }
+ }
+ }
+
+ // Validate join
+ if (windowStartEqualityLeftKeys.nonEmpty && windowEndEqualityLeftKeys.nonEmpty) {
+ if (
+ leftWindowProperties.getTimeAttributeType != rightWindowProperties.getTimeAttributeType) {
+ throw new TableException(
+ s"""
+ |Currently, time attribute type of left and right inputs should be both row-time or
+ |both proc-time. In the future, we could support different time attribute type.
+ |""".stripMargin)
+ } else if (leftWindowProperties.getWindowSpec != rightWindowProperties.getWindowSpec) {
+ throw new TableException(
+ s"""
+ |Currently, the windowing TVFs must be the same of left and right inputs.
+ |In the future, we could support different window TVFs, for example, tumbling windows
+ | join sliding windows with the same window size.
+ |""".stripMargin)
+ }
+ } else if (windowStartEqualityLeftKeys.nonEmpty || windowEndEqualityLeftKeys.nonEmpty) {
+ throw new TableException(
+ s"""
+ |Currently, window starts equality and window ends equality are both required for
+ |window join. In the future, we could support join clause which only includes window
+ |starts equality or window ends equality for TUMBLE or HOP window.
+ |""".stripMargin)
Review comment:
> Currently, window join requires JOIN ON condition must contain both window starts equality of input tables and window ends equality of input tables. But the current JOIN ON condition is %s.
##########
File path: flink-table/flink-table-planner-blink/src/main/scala/org/apache/flink/table/planner/plan/utils/WindowJoinUtil.scala
##########
@@ -0,0 +1,219 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.planner.plan.utils
+
+import org.apache.flink.table.api.TableException
+import org.apache.flink.table.planner.plan.metadata.FlinkRelMetadataQuery
+import org.apache.flink.table.planner.plan.nodes.logical.FlinkLogicalJoin
+import org.apache.flink.table.planner.plan.`trait`.RelWindowProperties
+
+import org.apache.calcite.rex.{RexInputRef, RexNode, RexUtil}
+import org.apache.calcite.sql.fun.SqlStdOperatorTable
+import org.apache.calcite.util.ImmutableIntList
+
+import scala.collection.JavaConversions._
+import scala.collection.mutable
+
+/**
+ * Util for window join.
+ */
+object WindowJoinUtil {
+
+ /**
+ * Get window properties of left and right child.
+ *
+ * @param join input join
+ * @return window properties of left and right child.
+ */
+ def getChildWindowProperties(
+ join: FlinkLogicalJoin): (RelWindowProperties, RelWindowProperties) = {
+ val fmq = FlinkRelMetadataQuery.reuseOrCreate(join.getCluster.getMetadataQuery)
+ (fmq.getRelWindowProperties(join.getLeft), fmq.getRelWindowProperties(join.getRight))
+ }
+
+ /**
+ * Checks whether join condition contains window starts equality of input tables or window
+ * ends equality of input tables.
+ *
+ * @param join input join
+ * @return True if join condition contains window starts equality of input tables and window
+ * ends equality of input tables. Else false.
+ */
+ def containsWindowStartEqualityOrEndEquality(join: FlinkLogicalJoin): Boolean = {
+ val (windowStartEqualityLeftKeys, windowEndEqualityLeftKeys, _, _) =
+ excludeWindowStartEqualityAndEndEqualityFromJoinInfoPairs(join)
+ windowStartEqualityLeftKeys.nonEmpty && windowEndEqualityLeftKeys.nonEmpty
+ }
+
+ /**
+ * Excludes window starts equality and window ends equality from join info.
+ *
+ * @param join input join
+ * @return Remain join information after excludes window starts equality and window ends
+ * equality from join.
+ * The first element is left join keys of window starts equality,
+ * the second element is left join keys of window ends equality,
+ * the third element is right join keys of window starts equality,
+ * the forth element is right join keys of window ends equality,
+ * the fifth element is remain left join keys,
+ * the sixth element is remain right join keys,
+ * the last element is remain join condition which includes remain equal condition and
+ * non-equal condition.
+ */
+ def excludeWindowStartEqualityAndEndEqualityFromJoinCondition(
+ join: FlinkLogicalJoin): (
+ ImmutableIntList,
+ ImmutableIntList,
+ ImmutableIntList,
+ ImmutableIntList,
+ ImmutableIntList,
+ ImmutableIntList,
+ RexNode) = {
+ val (
+ windowStartEqualityLeftKeys,
+ windowEndEqualityLeftKeys,
+ windowStartEqualityRightKeys,
+ windowEndEqualityRightKeys) =
+ excludeWindowStartEqualityAndEndEqualityFromJoinInfoPairs(join)
+
+ val joinInfo = join.analyzeCondition()
+ val (remainLeftKeys, remainRightKeys, remainCondition) = if (
+ windowStartEqualityLeftKeys.nonEmpty || windowEndEqualityLeftKeys.nonEmpty) {
+ val joinFieldsType = join.getRowType.getFieldList
+ val leftFieldCnt = join.getLeft.getRowType.getFieldCount
+ val rexBuilder = join.getCluster.getRexBuilder
+ val remainEquals = mutable.ArrayBuffer[RexNode]()
+ val remainLeftKeysArray = mutable.ArrayBuffer[Int]()
+ val remainRightKeysArray = mutable.ArrayBuffer[Int]()
+ // convert remain pairs to RexInputRef tuple for building SqlStdOperatorTable.EQUALS calls
+ joinInfo.pairs().foreach { p =>
+ if (!windowStartEqualityLeftKeys.contains(p.source) &&
+ !windowEndEqualityLeftKeys.contains(p.source)) {
+ val leftFieldType = joinFieldsType.get(p.source).getType
+ val leftInputRef = new RexInputRef(p.source, leftFieldType)
+ val rightIndex = leftFieldCnt + p.target
+ val rightFieldType = joinFieldsType.get(rightIndex).getType
+ val rightInputRef = new RexInputRef(rightIndex, rightFieldType)
+ val remainEqual = rexBuilder.makeCall(
+ SqlStdOperatorTable.EQUALS,
+ leftInputRef,
+ rightInputRef)
+ remainEquals.add(remainEqual)
+ remainLeftKeysArray.add(p.source)
+ remainRightKeysArray.add(p.target)
+ }
+ }
+ val remainAnds = remainEquals ++ joinInfo.nonEquiConditions
+ (
+ toImmutableIntList(remainLeftKeysArray),
+ toImmutableIntList(remainRightKeysArray),
+ // build a new condition
+ RexUtil.composeConjunction(rexBuilder, remainAnds.toList))
+ } else {
+ (joinInfo.leftKeys, joinInfo.rightKeys, join.getCondition)
+ }
+
+ (
+ windowStartEqualityLeftKeys,
+ windowEndEqualityLeftKeys,
+ windowStartEqualityRightKeys,
+ windowEndEqualityRightKeys,
+ remainLeftKeys,
+ remainRightKeys,
+ remainCondition)
+ }
+
+ /**
+ * Excludes window start equality and window end equality from JoinInfo pairs.
+ *
+ * @param join the join to split
+ * @return The remain part of JoinInfo pairs after excludes window start equality and window
+ * end equality from JoinInfo pairs.
+ * The first element is left join keys of window starts equality,
+ * the second element is left join keys of window ends equality,
+ * the third element is right join keys of window starts equality,
+ * the forth element is right join keys of window ends equality.
+ */
+ private def excludeWindowStartEqualityAndEndEqualityFromJoinInfoPairs(
+ join: FlinkLogicalJoin): (
+ ImmutableIntList, ImmutableIntList, ImmutableIntList, ImmutableIntList) = {
+ val joinInfo = join.analyzeCondition()
+ val (leftWindowProperties, rightWindowProperties) = getChildWindowProperties(join)
+
+ val windowStartEqualityLeftKeys = mutable.ArrayBuffer[Int]()
+ val windowEndEqualityLeftKeys = mutable.ArrayBuffer[Int]()
+ val windowStartEqualityRightKeys = mutable.ArrayBuffer[Int]()
+ val windowEndEqualityRightKeys = mutable.ArrayBuffer[Int]()
+
+ if (leftWindowProperties != null && rightWindowProperties != null) {
+ val leftWindowStartColumns = leftWindowProperties.getWindowStartColumns
+ val rightWindowStartColumns = rightWindowProperties.getWindowStartColumns
+ val leftWindowEndColumns = leftWindowProperties.getWindowEndColumns
+ val rightWindowEndColumns = rightWindowProperties.getWindowEndColumns
+
+ joinInfo.pairs().foreach { pair =>
+ val leftKey = pair.source
+ val rightKey = pair.target
+ if (leftWindowStartColumns.get(leftKey) && rightWindowStartColumns.get(rightKey)) {
+ windowStartEqualityLeftKeys.add(leftKey)
+ windowStartEqualityRightKeys.add(rightKey)
+ } else if (leftWindowEndColumns.get(leftKey) && rightWindowEndColumns.get(rightKey)) {
+ windowEndEqualityLeftKeys.add(leftKey)
+ windowEndEqualityRightKeys.add(rightKey)
+ }
+ }
+ }
+
+ // Validate join
+ if (windowStartEqualityLeftKeys.nonEmpty && windowEndEqualityLeftKeys.nonEmpty) {
+ if (
+ leftWindowProperties.getTimeAttributeType != rightWindowProperties.getTimeAttributeType) {
+ throw new TableException(
+ s"""
+ |Currently, time attribute type of left and right inputs should be both row-time or
+ |both proc-time. In the future, we could support different time attribute type.
+ |""".stripMargin)
Review comment:
> Currently, window join doesn't support different time attribute type of left and right inputs. The left time attribute type is %s, the right time attribute type is %s.
----------------------------------------------------------------
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:
users@infra.apache.org
[GitHub] [flink] flinkbot edited a comment on pull request #15195: [FLINK-19609][table-planner-blink] Support streaming window join in planner
Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #15195:
URL: https://github.com/apache/flink/pull/15195#issuecomment-798871942
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "8f844ec2c7ace18f8d6a78efbabea949dd7b9a8c",
"status" : "DELETED",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14614",
"triggerID" : "8f844ec2c7ace18f8d6a78efbabea949dd7b9a8c",
"triggerType" : "PUSH"
}, {
"hash" : "c7a1c712fc6f803918ab49a8e07994e1bc590652",
"status" : "CANCELED",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14663",
"triggerID" : "c7a1c712fc6f803918ab49a8e07994e1bc590652",
"triggerType" : "PUSH"
}, {
"hash" : "162ca63148a9c1c924936bc17743f830082d800e",
"status" : "PENDING",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14668",
"triggerID" : "162ca63148a9c1c924936bc17743f830082d800e",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* c7a1c712fc6f803918ab49a8e07994e1bc590652 Azure: [CANCELED](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14663)
* 162ca63148a9c1c924936bc17743f830082d800e Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14668)
<details>
<summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot run travis` re-run the last Travis build
- `@flinkbot run azure` re-run the last Azure build
</details>
----------------------------------------------------------------
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:
users@infra.apache.org
[GitHub] [flink] beyond1920 commented on a change in pull request #15195: [FLINK-19609][table-planner-blink] Support streaming window join in planner
Posted by GitBox <gi...@apache.org>.
beyond1920 commented on a change in pull request #15195:
URL: https://github.com/apache/flink/pull/15195#discussion_r594017064
##########
File path: flink-table/flink-table-planner-blink/src/main/scala/org/apache/flink/table/planner/plan/metadata/FlinkRelMdWindowProperties.scala
##########
@@ -315,6 +315,38 @@ class FlinkRelMdWindowProperties private extends MetadataHandler[FlinkMetadata.W
fmq.getRelWindowProperties(rel.getLeft)
}
+ def getWindowProperties(
+ rel: StreamPhysicalWindowJoin,
+ mq: RelMetadataQuery): RelWindowProperties = {
+ val leftFieldCnt = rel.getLeft.getRowType.getFieldCount
+ val rightFieldCnt = rel.getRight.getRowType.getFieldCount
+
+ def inferWindowPropertyAfterWindowJoin(
+ leftWindowProperty: ImmutableBitSet,
+ rightWindowProperty: ImmutableBitSet): ImmutableBitSet = {
+ val fieldMapping = new JHashMap[Integer, Integer]()
+ (0 until rightFieldCnt).foreach(idx => fieldMapping.put(idx, leftFieldCnt + idx))
+ val rightWindowPropertyAfterWindowJoin = rightWindowProperty.permute(fieldMapping)
+ leftWindowProperty.union(rightWindowPropertyAfterWindowJoin)
+ }
+
+ val fmq = FlinkRelMetadataQuery.reuseOrCreate(mq)
+ val leftWindowProperties = fmq.getRelWindowProperties(rel.getLeft)
+ val rightWindowProperties = fmq.getRelWindowProperties(rel.getRight)
+ assert(leftWindowProperties.getWindowSpec == rightWindowProperties.getWindowSpec)
Review comment:
The case will not happen because the node will not be translated to WindowJoin if `WindowSpec` is different.
----------------------------------------------------------------
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:
users@infra.apache.org
[GitHub] [flink] flinkbot edited a comment on pull request #15195: [FLINK-19609][table-planner-blink] Support streaming window join in planner
Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #15195:
URL: https://github.com/apache/flink/pull/15195#issuecomment-798871942
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "8f844ec2c7ace18f8d6a78efbabea949dd7b9a8c",
"status" : "DELETED",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14614",
"triggerID" : "8f844ec2c7ace18f8d6a78efbabea949dd7b9a8c",
"triggerType" : "PUSH"
}, {
"hash" : "c7a1c712fc6f803918ab49a8e07994e1bc590652",
"status" : "CANCELED",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14663",
"triggerID" : "c7a1c712fc6f803918ab49a8e07994e1bc590652",
"triggerType" : "PUSH"
}, {
"hash" : "162ca63148a9c1c924936bc17743f830082d800e",
"status" : "PENDING",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14668",
"triggerID" : "162ca63148a9c1c924936bc17743f830082d800e",
"triggerType" : "PUSH"
}, {
"hash" : "0a79f7d2655ee39ce1bb193bde327b1121b80ff4",
"status" : "UNKNOWN",
"url" : "TBD",
"triggerID" : "0a79f7d2655ee39ce1bb193bde327b1121b80ff4",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* c7a1c712fc6f803918ab49a8e07994e1bc590652 Azure: [CANCELED](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14663)
* 162ca63148a9c1c924936bc17743f830082d800e Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14668)
* 0a79f7d2655ee39ce1bb193bde327b1121b80ff4 UNKNOWN
<details>
<summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot run travis` re-run the last Travis build
- `@flinkbot run azure` re-run the last Azure build
</details>
----------------------------------------------------------------
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:
users@infra.apache.org
[GitHub] [flink] flinkbot edited a comment on pull request #15195: [FLINK-19609][table-planner-blink] Support streaming window join in planner
Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #15195:
URL: https://github.com/apache/flink/pull/15195#issuecomment-798871942
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "8f844ec2c7ace18f8d6a78efbabea949dd7b9a8c",
"status" : "FAILURE",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14614",
"triggerID" : "8f844ec2c7ace18f8d6a78efbabea949dd7b9a8c",
"triggerType" : "PUSH"
}, {
"hash" : "c7a1c712fc6f803918ab49a8e07994e1bc590652",
"status" : "PENDING",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14663",
"triggerID" : "c7a1c712fc6f803918ab49a8e07994e1bc590652",
"triggerType" : "PUSH"
}, {
"hash" : "162ca63148a9c1c924936bc17743f830082d800e",
"status" : "PENDING",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14668",
"triggerID" : "162ca63148a9c1c924936bc17743f830082d800e",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* 8f844ec2c7ace18f8d6a78efbabea949dd7b9a8c Azure: [FAILURE](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14614)
* c7a1c712fc6f803918ab49a8e07994e1bc590652 Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14663)
* 162ca63148a9c1c924936bc17743f830082d800e Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14668)
<details>
<summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot run travis` re-run the last Travis build
- `@flinkbot run azure` re-run the last Azure build
</details>
----------------------------------------------------------------
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:
users@infra.apache.org
[GitHub] [flink] flinkbot edited a comment on pull request #15195: [FLINK-19609][table-planner-blink] Support streaming window join in planner
Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #15195:
URL: https://github.com/apache/flink/pull/15195#issuecomment-798871942
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "8f844ec2c7ace18f8d6a78efbabea949dd7b9a8c",
"status" : "FAILURE",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14614",
"triggerID" : "8f844ec2c7ace18f8d6a78efbabea949dd7b9a8c",
"triggerType" : "PUSH"
}, {
"hash" : "c7a1c712fc6f803918ab49a8e07994e1bc590652",
"status" : "UNKNOWN",
"url" : "TBD",
"triggerID" : "c7a1c712fc6f803918ab49a8e07994e1bc590652",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* 8f844ec2c7ace18f8d6a78efbabea949dd7b9a8c Azure: [FAILURE](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14614)
* c7a1c712fc6f803918ab49a8e07994e1bc590652 UNKNOWN
<details>
<summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot run travis` re-run the last Travis build
- `@flinkbot run azure` re-run the last Azure build
</details>
----------------------------------------------------------------
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:
users@infra.apache.org
[GitHub] [flink] beyond1920 commented on a change in pull request #15195: [FLINK-19609][table-planner-blink] Support streaming window join in planner
Posted by GitBox <gi...@apache.org>.
beyond1920 commented on a change in pull request #15195:
URL: https://github.com/apache/flink/pull/15195#discussion_r594057275
##########
File path: flink-table/flink-table-planner-blink/src/main/scala/org/apache/flink/table/planner/plan/utils/WindowJoinUtil.scala
##########
@@ -0,0 +1,219 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.planner.plan.utils
+
+import org.apache.flink.table.api.TableException
+import org.apache.flink.table.planner.plan.metadata.FlinkRelMetadataQuery
+import org.apache.flink.table.planner.plan.nodes.logical.FlinkLogicalJoin
+import org.apache.flink.table.planner.plan.`trait`.RelWindowProperties
+
+import org.apache.calcite.rex.{RexInputRef, RexNode, RexUtil}
+import org.apache.calcite.sql.fun.SqlStdOperatorTable
+import org.apache.calcite.util.ImmutableIntList
+
+import scala.collection.JavaConversions._
+import scala.collection.mutable
+
+/**
+ * Util for window join.
+ */
+object WindowJoinUtil {
+
+ /**
+ * Get window properties of left and right child.
+ *
+ * @param join input join
+ * @return window properties of left and right child.
+ */
+ def getChildWindowProperties(
+ join: FlinkLogicalJoin): (RelWindowProperties, RelWindowProperties) = {
+ val fmq = FlinkRelMetadataQuery.reuseOrCreate(join.getCluster.getMetadataQuery)
+ (fmq.getRelWindowProperties(join.getLeft), fmq.getRelWindowProperties(join.getRight))
+ }
+
+ /**
+ * Checks whether join condition contains window starts equality of input tables or window
+ * ends equality of input tables.
+ *
+ * @param join input join
+ * @return True if join condition contains window starts equality of input tables and window
+ * ends equality of input tables. Else false.
+ */
+ def containsWindowStartEqualityOrEndEquality(join: FlinkLogicalJoin): Boolean = {
+ val (windowStartEqualityLeftKeys, windowEndEqualityLeftKeys, _, _) =
+ excludeWindowStartEqualityAndEndEqualityFromJoinInfoPairs(join)
+ windowStartEqualityLeftKeys.nonEmpty || windowEndEqualityLeftKeys.nonEmpty
+ }
+
+ /**
+ * Excludes window starts equality and window ends equality from join info.
+ *
+ * @param join input join
+ * @return Remain join information after excludes window starts equality and window ends
+ * equality from join.
+ * The first element is left join keys of window starts equality,
+ * the second element is left join keys of window ends equality,
+ * the third element is right join keys of window starts equality,
+ * the forth element is right join keys of window ends equality,
+ * the fifth element is remain left join keys,
+ * the sixth element is remain right join keys,
+ * the last element is remain join condition which includes remain equal condition and
+ * non-equal condition.
+ */
+ def excludeWindowStartEqualityAndEndEqualityFromJoinCondition(
+ join: FlinkLogicalJoin): (
+ ImmutableIntList,
+ ImmutableIntList,
+ ImmutableIntList,
+ ImmutableIntList,
+ ImmutableIntList,
+ ImmutableIntList,
+ RexNode) = {
+ val (
+ windowStartEqualityLeftKeys,
+ windowEndEqualityLeftKeys,
+ windowStartEqualityRightKeys,
+ windowEndEqualityRightKeys) =
+ excludeWindowStartEqualityAndEndEqualityFromJoinInfoPairs(join)
+
+ val joinInfo = join.analyzeCondition()
+ val (remainLeftKeys, remainRightKeys, remainCondition) = if (
+ windowStartEqualityLeftKeys.nonEmpty || windowEndEqualityLeftKeys.nonEmpty) {
+ val joinFieldsType = join.getRowType.getFieldList
+ val leftFieldCnt = join.getLeft.getRowType.getFieldCount
+ val rexBuilder = join.getCluster.getRexBuilder
+ val remainEquals = mutable.ArrayBuffer[RexNode]()
+ val remainLeftKeysArray = mutable.ArrayBuffer[Int]()
+ val remainRightKeysArray = mutable.ArrayBuffer[Int]()
+ // convert remain pairs to RexInputRef tuple for building SqlStdOperatorTable.EQUALS calls
+ joinInfo.pairs().foreach { p =>
+ if (!windowStartEqualityLeftKeys.contains(p.source) &&
+ !windowEndEqualityLeftKeys.contains(p.source)) {
+ val leftFieldType = joinFieldsType.get(p.source).getType
+ val leftInputRef = new RexInputRef(p.source, leftFieldType)
+ val rightIndex = leftFieldCnt + p.target
+ val rightFieldType = joinFieldsType.get(rightIndex).getType
+ val rightInputRef = new RexInputRef(rightIndex, rightFieldType)
+ val remainEqual = rexBuilder.makeCall(
+ SqlStdOperatorTable.EQUALS,
Review comment:
@wuchong Thanks, the solution you mentioned works well of course. However I prefer let `StreamPhysicalWindowJoin` extends `CommonPhysicalJoin`, so a complete condition which contains equal condition and non-equal condition is required, JoinInfo would be inferred in the `Join` node. What do you think?
----------------------------------------------------------------
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:
users@infra.apache.org
[GitHub] [flink] wuchong commented on pull request #15195: [FLINK-19609][table-planner-blink] Support streaming window join in planner
Posted by GitBox <gi...@apache.org>.
wuchong commented on pull request #15195:
URL: https://github.com/apache/flink/pull/15195#issuecomment-800812750
I appended a commit to improve the exception message. And also rebased the branch. If there is no objections, I will merge it once the build is passed.
----------------------------------------------------------------
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:
users@infra.apache.org
[GitHub] [flink] wuchong commented on a change in pull request #15195: [FLINK-19609][table-planner-blink] Support streaming window join in planner
Posted by GitBox <gi...@apache.org>.
wuchong commented on a change in pull request #15195:
URL: https://github.com/apache/flink/pull/15195#discussion_r593905932
##########
File path: flink-table/flink-table-planner-blink/src/main/scala/org/apache/flink/table/planner/plan/metadata/FlinkRelMdWindowProperties.scala
##########
@@ -315,6 +315,38 @@ class FlinkRelMdWindowProperties private extends MetadataHandler[FlinkMetadata.W
fmq.getRelWindowProperties(rel.getLeft)
}
+ def getWindowProperties(
+ rel: StreamPhysicalWindowJoin,
+ mq: RelMetadataQuery): RelWindowProperties = {
+ val leftFieldCnt = rel.getLeft.getRowType.getFieldCount
+ val rightFieldCnt = rel.getRight.getRowType.getFieldCount
+
+ def inferWindowPropertyAfterWindowJoin(
+ leftWindowProperty: ImmutableBitSet,
+ rightWindowProperty: ImmutableBitSet): ImmutableBitSet = {
+ val fieldMapping = new JHashMap[Integer, Integer]()
+ (0 until rightFieldCnt).foreach(idx => fieldMapping.put(idx, leftFieldCnt + idx))
+ val rightWindowPropertyAfterWindowJoin = rightWindowProperty.permute(fieldMapping)
+ leftWindowProperty.union(rightWindowPropertyAfterWindowJoin)
+ }
+
+ val fmq = FlinkRelMetadataQuery.reuseOrCreate(mq)
+ val leftWindowProperties = fmq.getRelWindowProperties(rel.getLeft)
+ val rightWindowProperties = fmq.getRelWindowProperties(rel.getRight)
+ assert(leftWindowProperties.getWindowSpec == rightWindowProperties.getWindowSpec)
Review comment:
Do we need to use `assert` here? I think the query is still valid, we just can't infer the window properties. I think we can return null in this case.
##########
File path: flink-table/flink-table-planner-blink/src/main/scala/org/apache/flink/table/planner/plan/optimize/program/FlinkChangelogModeInferenceProgram.scala
##########
@@ -266,6 +266,12 @@ class FlinkChangelogModeInferenceProgram extends FlinkOptimizeProgram[StreamOpti
}
createNewNode(join, children, providedTrait, requiredTrait, requester)
+ case windowJoin: StreamPhysicalWindowJoin =>
+ // window join support all changes in input
+ val children = visitChildren(rel, ModifyKindSetTrait.ALL_CHANGES)
Review comment:
I would suggest to use `INSERT_ONLY` here (and we don't add any tests for this). We can
##########
File path: flink-table/flink-table-planner-blink/src/main/scala/org/apache/flink/table/planner/plan/utils/WindowJoinUtil.scala
##########
@@ -0,0 +1,219 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.planner.plan.utils
+
+import org.apache.flink.table.api.TableException
+import org.apache.flink.table.planner.plan.metadata.FlinkRelMetadataQuery
+import org.apache.flink.table.planner.plan.nodes.logical.FlinkLogicalJoin
+import org.apache.flink.table.planner.plan.`trait`.RelWindowProperties
+
+import org.apache.calcite.rex.{RexInputRef, RexNode, RexUtil}
+import org.apache.calcite.sql.fun.SqlStdOperatorTable
+import org.apache.calcite.util.ImmutableIntList
+
+import scala.collection.JavaConversions._
+import scala.collection.mutable
+
+/**
+ * Util for window join.
+ */
+object WindowJoinUtil {
+
+ /**
+ * Get window properties of left and right child.
+ *
+ * @param join input join
+ * @return window properties of left and right child.
+ */
+ def getChildWindowProperties(
+ join: FlinkLogicalJoin): (RelWindowProperties, RelWindowProperties) = {
+ val fmq = FlinkRelMetadataQuery.reuseOrCreate(join.getCluster.getMetadataQuery)
+ (fmq.getRelWindowProperties(join.getLeft), fmq.getRelWindowProperties(join.getRight))
+ }
+
+ /**
+ * Checks whether join condition contains window starts equality of input tables or window
+ * ends equality of input tables.
+ *
+ * @param join input join
+ * @return True if join condition contains window starts equality of input tables and window
+ * ends equality of input tables. Else false.
+ */
+ def containsWindowStartEqualityOrEndEquality(join: FlinkLogicalJoin): Boolean = {
+ val (windowStartEqualityLeftKeys, windowEndEqualityLeftKeys, _, _) =
+ excludeWindowStartEqualityAndEndEqualityFromJoinInfoPairs(join)
+ windowStartEqualityLeftKeys.nonEmpty || windowEndEqualityLeftKeys.nonEmpty
+ }
+
+ /**
+ * Excludes window starts equality and window ends equality from join info.
+ *
+ * @param join input join
+ * @return Remain join information after excludes window starts equality and window ends
+ * equality from join.
+ * The first element is left join keys of window starts equality,
+ * the second element is left join keys of window ends equality,
+ * the third element is right join keys of window starts equality,
+ * the forth element is right join keys of window ends equality,
+ * the fifth element is remain left join keys,
+ * the sixth element is remain right join keys,
+ * the last element is remain join condition which includes remain equal condition and
+ * non-equal condition.
+ */
+ def excludeWindowStartEqualityAndEndEqualityFromJoinCondition(
+ join: FlinkLogicalJoin): (
+ ImmutableIntList,
+ ImmutableIntList,
+ ImmutableIntList,
+ ImmutableIntList,
+ ImmutableIntList,
+ ImmutableIntList,
+ RexNode) = {
+ val (
+ windowStartEqualityLeftKeys,
+ windowEndEqualityLeftKeys,
+ windowStartEqualityRightKeys,
+ windowEndEqualityRightKeys) =
+ excludeWindowStartEqualityAndEndEqualityFromJoinInfoPairs(join)
+
+ val joinInfo = join.analyzeCondition()
+ val (remainLeftKeys, remainRightKeys, remainCondition) = if (
+ windowStartEqualityLeftKeys.nonEmpty || windowEndEqualityLeftKeys.nonEmpty) {
+ val joinFieldsType = join.getRowType.getFieldList
+ val leftFieldCnt = join.getLeft.getRowType.getFieldCount
+ val rexBuilder = join.getCluster.getRexBuilder
+ val remainEquals = mutable.ArrayBuffer[RexNode]()
+ val remainLeftKeysArray = mutable.ArrayBuffer[Int]()
+ val remainRightKeysArray = mutable.ArrayBuffer[Int]()
+ // convert remain pairs to RexInputRef tuple for building SqlStdOperatorTable.EQUALS calls
+ joinInfo.pairs().foreach { p =>
+ if (!windowStartEqualityLeftKeys.contains(p.source) &&
+ !windowEndEqualityLeftKeys.contains(p.source)) {
+ val leftFieldType = joinFieldsType.get(p.source).getType
+ val leftInputRef = new RexInputRef(p.source, leftFieldType)
+ val rightIndex = leftFieldCnt + p.target
+ val rightFieldType = joinFieldsType.get(rightIndex).getType
+ val rightInputRef = new RexInputRef(rightIndex, rightFieldType)
+ val remainEqual = rexBuilder.makeCall(
+ SqlStdOperatorTable.EQUALS,
Review comment:
Why the `remainCondition` should contain the join key equality?
##########
File path: flink-table/flink-table-planner-blink/src/test/resources/org/apache/flink/table/planner/plan/stream/sql/join/WindowJoinTest.xml
##########
@@ -0,0 +1,1041 @@
+<?xml version="1.0" ?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to you under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+-->
+<Root>
+ <TestCase name="testCantMergeWindowTVF_Cumulate">
+ <Resource name="sql">
+ <![CDATA[
+SELECT L.a, L.b, L.c, R.a, R.b, R.c
+FROM (
+ SELECT *
+ FROM TABLE(
+ CUMULATE(TABLE MyTable, DESCRIPTOR(rowtime), INTERVAL '10' MINUTE, INTERVAL '1' HOUR))
+) L
+JOIN (
+ SELECT *
+ FROM TABLE(
+ CUMULATE(TABLE MyTable2, DESCRIPTOR(rowtime), INTERVAL '10' MINUTE, INTERVAL '1' HOUR))
+) R
+ON L.window_start = R.window_start AND L.window_end = R.window_end AND L.a = R.a
+ ]]>
+ </Resource>
+ <Resource name="ast">
+ <![CDATA[
+LogicalProject(a=[$0], b=[$1], c=[$2], a0=[$8], b0=[$9], c0=[$10])
++- LogicalJoin(condition=[AND(=($5, $13), =($6, $14), =($0, $8))], joinType=[inner])
+ :- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4], window_start=[$5], window_end=[$6], window_time=[$7])
+ : +- LogicalTableFunctionScan(invocation=[CUMULATE($4, DESCRIPTOR($3), 600000:INTERVAL MINUTE, 3600000:INTERVAL HOUR)], rowType=[RecordType(INTEGER a, VARCHAR(2147483647) b, BIGINT c, TIME ATTRIBUTE(ROWTIME) rowtime, TIME ATTRIBUTE(PROCTIME) proctime, TIMESTAMP(3) window_start, TIMESTAMP(3) window_end, TIME ATTRIBUTE(ROWTIME) window_time)])
+ : +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4])
+ : +- LogicalWatermarkAssigner(rowtime=[rowtime], watermark=[-($3, 1000:INTERVAL SECOND)])
+ : +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[PROCTIME()])
+ : +- LogicalTableScan(table=[[default_catalog, default_database, MyTable]])
+ +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4], window_start=[$5], window_end=[$6], window_time=[$7])
+ +- LogicalTableFunctionScan(invocation=[CUMULATE($4, DESCRIPTOR($3), 600000:INTERVAL MINUTE, 3600000:INTERVAL HOUR)], rowType=[RecordType(INTEGER a, VARCHAR(2147483647) b, BIGINT c, TIME ATTRIBUTE(ROWTIME) rowtime, TIME ATTRIBUTE(PROCTIME) proctime, TIMESTAMP(3) window_start, TIMESTAMP(3) window_end, TIME ATTRIBUTE(ROWTIME) window_time)])
+ +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4])
+ +- LogicalWatermarkAssigner(rowtime=[rowtime], watermark=[-($3, 1000:INTERVAL SECOND)])
+ +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[PROCTIME()])
+ +- LogicalTableScan(table=[[default_catalog, default_database, MyTable2]])
+]]>
+ </Resource>
+ <Resource name="optimized rel plan">
+ <![CDATA[
+Calc(select=[a, b, c, a0, b0, c0])
++- WindowJoin(leftWindow=[CUMULATE(win_start=[window_start], win_end=[window_end], max_size=[1 h], step=[10 min])], rightWindow=[CUMULATE(win_start=[window_start], win_end=[window_end], max_size=[1 h], step=[10 min])], joinType=[InnerJoin], where=[=(a, a0)], select=[a, b, c, window_start, window_end, a0, b0, c0, window_start0, window_end0])
Review comment:
Note: when implementing window join operator, we can't support proctime window join for now, becuase the window assigner is in an separate operator, that means we don't know when to trigger the processing-time window (we don't have something like watermark for proctime). We need to merge window assigner into window join to support proctime window join, but this can be a future work.
##########
File path: flink-table/flink-table-planner-blink/src/main/scala/org/apache/flink/table/planner/plan/utils/WindowJoinUtil.scala
##########
@@ -0,0 +1,219 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.planner.plan.utils
+
+import org.apache.flink.table.api.TableException
+import org.apache.flink.table.planner.plan.metadata.FlinkRelMetadataQuery
+import org.apache.flink.table.planner.plan.nodes.logical.FlinkLogicalJoin
+import org.apache.flink.table.planner.plan.`trait`.RelWindowProperties
+
+import org.apache.calcite.rex.{RexInputRef, RexNode, RexUtil}
+import org.apache.calcite.sql.fun.SqlStdOperatorTable
+import org.apache.calcite.util.ImmutableIntList
+
+import scala.collection.JavaConversions._
+import scala.collection.mutable
+
+/**
+ * Util for window join.
+ */
+object WindowJoinUtil {
+
+ /**
+ * Get window properties of left and right child.
+ *
+ * @param join input join
+ * @return window properties of left and right child.
+ */
+ def getChildWindowProperties(
+ join: FlinkLogicalJoin): (RelWindowProperties, RelWindowProperties) = {
+ val fmq = FlinkRelMetadataQuery.reuseOrCreate(join.getCluster.getMetadataQuery)
+ (fmq.getRelWindowProperties(join.getLeft), fmq.getRelWindowProperties(join.getRight))
+ }
+
+ /**
+ * Checks whether join condition contains window starts equality of input tables or window
+ * ends equality of input tables.
+ *
+ * @param join input join
+ * @return True if join condition contains window starts equality of input tables and window
+ * ends equality of input tables. Else false.
+ */
+ def containsWindowStartEqualityOrEndEquality(join: FlinkLogicalJoin): Boolean = {
+ val (windowStartEqualityLeftKeys, windowEndEqualityLeftKeys, _, _) =
+ excludeWindowStartEqualityAndEndEqualityFromJoinInfoPairs(join)
+ windowStartEqualityLeftKeys.nonEmpty || windowEndEqualityLeftKeys.nonEmpty
Review comment:
I think it would be better to use `&&`, because we don't allow start OR end for now in `excludeWindowStartEqualityAndEndEqualityFromJoinInfoPairs`.
##########
File path: flink-table/flink-table-planner-blink/src/test/resources/org/apache/flink/table/planner/plan/stream/sql/join/WindowJoinTest.xml
##########
@@ -0,0 +1,1041 @@
+<?xml version="1.0" ?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to you under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+-->
+<Root>
+ <TestCase name="testCantMergeWindowTVF_Cumulate">
+ <Resource name="sql">
+ <![CDATA[
+SELECT L.a, L.b, L.c, R.a, R.b, R.c
+FROM (
+ SELECT *
+ FROM TABLE(
+ CUMULATE(TABLE MyTable, DESCRIPTOR(rowtime), INTERVAL '10' MINUTE, INTERVAL '1' HOUR))
+) L
+JOIN (
+ SELECT *
+ FROM TABLE(
+ CUMULATE(TABLE MyTable2, DESCRIPTOR(rowtime), INTERVAL '10' MINUTE, INTERVAL '1' HOUR))
+) R
+ON L.window_start = R.window_start AND L.window_end = R.window_end AND L.a = R.a
+ ]]>
+ </Resource>
+ <Resource name="ast">
+ <![CDATA[
+LogicalProject(a=[$0], b=[$1], c=[$2], a0=[$8], b0=[$9], c0=[$10])
++- LogicalJoin(condition=[AND(=($5, $13), =($6, $14), =($0, $8))], joinType=[inner])
+ :- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4], window_start=[$5], window_end=[$6], window_time=[$7])
+ : +- LogicalTableFunctionScan(invocation=[CUMULATE($4, DESCRIPTOR($3), 600000:INTERVAL MINUTE, 3600000:INTERVAL HOUR)], rowType=[RecordType(INTEGER a, VARCHAR(2147483647) b, BIGINT c, TIME ATTRIBUTE(ROWTIME) rowtime, TIME ATTRIBUTE(PROCTIME) proctime, TIMESTAMP(3) window_start, TIMESTAMP(3) window_end, TIME ATTRIBUTE(ROWTIME) window_time)])
+ : +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4])
+ : +- LogicalWatermarkAssigner(rowtime=[rowtime], watermark=[-($3, 1000:INTERVAL SECOND)])
+ : +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[PROCTIME()])
+ : +- LogicalTableScan(table=[[default_catalog, default_database, MyTable]])
+ +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4], window_start=[$5], window_end=[$6], window_time=[$7])
+ +- LogicalTableFunctionScan(invocation=[CUMULATE($4, DESCRIPTOR($3), 600000:INTERVAL MINUTE, 3600000:INTERVAL HOUR)], rowType=[RecordType(INTEGER a, VARCHAR(2147483647) b, BIGINT c, TIME ATTRIBUTE(ROWTIME) rowtime, TIME ATTRIBUTE(PROCTIME) proctime, TIMESTAMP(3) window_start, TIMESTAMP(3) window_end, TIME ATTRIBUTE(ROWTIME) window_time)])
+ +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4])
+ +- LogicalWatermarkAssigner(rowtime=[rowtime], watermark=[-($3, 1000:INTERVAL SECOND)])
+ +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[PROCTIME()])
+ +- LogicalTableScan(table=[[default_catalog, default_database, MyTable2]])
+]]>
+ </Resource>
+ <Resource name="optimized rel plan">
+ <![CDATA[
+Calc(select=[a, b, c, a0, b0, c0])
++- WindowJoin(leftWindow=[CUMULATE(win_start=[window_start], win_end=[window_end], max_size=[1 h], step=[10 min])], rightWindow=[CUMULATE(win_start=[window_start], win_end=[window_end], max_size=[1 h], step=[10 min])], joinType=[InnerJoin], where=[=(a, a0)], select=[a, b, c, window_start, window_end, a0, b0, c0, window_start0, window_end0])
+ :- Exchange(distribution=[hash[a]])
+ : +- Calc(select=[a, b, c, window_start, window_end])
+ : +- WindowTableFunction(window=[CUMULATE(time_col=[rowtime], max_size=[1 h], step=[10 min])])
+ : +- WatermarkAssigner(rowtime=[rowtime], watermark=[-(rowtime, 1000:INTERVAL SECOND)])
+ : +- Calc(select=[a, b, c, rowtime, PROCTIME() AS proctime])
+ : +- TableSourceScan(table=[[default_catalog, default_database, MyTable]], fields=[a, b, c, rowtime])
+ +- Exchange(distribution=[hash[a]])
+ +- Calc(select=[a, b, c, window_start, window_end])
+ +- WindowTableFunction(window=[CUMULATE(time_col=[rowtime], max_size=[1 h], step=[10 min])])
+ +- WatermarkAssigner(rowtime=[rowtime], watermark=[-(rowtime, 1000:INTERVAL SECOND)])
+ +- Calc(select=[a, b, c, rowtime, PROCTIME() AS proctime])
+ +- TableSourceScan(table=[[default_catalog, default_database, MyTable2]], fields=[a, b, c, rowtime])
+]]>
+ </Resource>
+ </TestCase>
+ <TestCase name="testCantMergeWindowTVF_CumulateOnProctime">
+ <Resource name="sql">
+ <![CDATA[
+SELECT L.a, L.b, L.c, R.a, R.b, R.c
+FROM (
+ SELECT *
+ FROM TABLE(
+ CUMULATE(TABLE MyTable, DESCRIPTOR(proctime), INTERVAL '10' MINUTE, INTERVAL '1' HOUR))
+) L
+JOIN (
+ SELECT *
+ FROM TABLE(
+ CUMULATE(TABLE MyTable2, DESCRIPTOR(proctime), INTERVAL '10' MINUTE, INTERVAL '1' HOUR))
+) R
+ON L.window_start = R.window_start AND L.window_end = R.window_end AND L.a = R.a
+ ]]>
+ </Resource>
+ <Resource name="ast">
+ <![CDATA[
+LogicalProject(a=[$0], b=[$1], c=[$2], a0=[$8], b0=[$9], c0=[$10])
++- LogicalJoin(condition=[AND(=($5, $13), =($6, $14), =($0, $8))], joinType=[inner])
+ :- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4], window_start=[$5], window_end=[$6], window_time=[$7])
+ : +- LogicalTableFunctionScan(invocation=[CUMULATE($4, DESCRIPTOR($4), 600000:INTERVAL MINUTE, 3600000:INTERVAL HOUR)], rowType=[RecordType(INTEGER a, VARCHAR(2147483647) b, BIGINT c, TIME ATTRIBUTE(ROWTIME) rowtime, TIME ATTRIBUTE(PROCTIME) proctime, TIMESTAMP(3) window_start, TIMESTAMP(3) window_end, TIME ATTRIBUTE(PROCTIME) window_time)])
+ : +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4])
+ : +- LogicalWatermarkAssigner(rowtime=[rowtime], watermark=[-($3, 1000:INTERVAL SECOND)])
+ : +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[PROCTIME()])
+ : +- LogicalTableScan(table=[[default_catalog, default_database, MyTable]])
+ +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4], window_start=[$5], window_end=[$6], window_time=[$7])
+ +- LogicalTableFunctionScan(invocation=[CUMULATE($4, DESCRIPTOR($4), 600000:INTERVAL MINUTE, 3600000:INTERVAL HOUR)], rowType=[RecordType(INTEGER a, VARCHAR(2147483647) b, BIGINT c, TIME ATTRIBUTE(ROWTIME) rowtime, TIME ATTRIBUTE(PROCTIME) proctime, TIMESTAMP(3) window_start, TIMESTAMP(3) window_end, TIME ATTRIBUTE(PROCTIME) window_time)])
+ +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4])
+ +- LogicalWatermarkAssigner(rowtime=[rowtime], watermark=[-($3, 1000:INTERVAL SECOND)])
+ +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[PROCTIME()])
+ +- LogicalTableScan(table=[[default_catalog, default_database, MyTable2]])
+]]>
+ </Resource>
+ <Resource name="optimized rel plan">
+ <![CDATA[
+Calc(select=[a, b, c, a0, b0, c0])
++- WindowJoin(leftWindow=[CUMULATE(win_start=[window_start], win_end=[window_end], max_size=[1 h], step=[10 min])], rightWindow=[CUMULATE(win_start=[window_start], win_end=[window_end], max_size=[1 h], step=[10 min])], joinType=[InnerJoin], where=[=(a, a0)], select=[a, b, c, window_start, window_end, a0, b0, c0, window_start0, window_end0])
+ :- Exchange(distribution=[hash[a]])
+ : +- Calc(select=[a, b, c, window_start, window_end])
+ : +- WindowTableFunction(window=[CUMULATE(time_col=[proctime], max_size=[1 h], step=[10 min])])
+ : +- WatermarkAssigner(rowtime=[rowtime], watermark=[-(rowtime, 1000:INTERVAL SECOND)])
+ : +- Calc(select=[a, b, c, rowtime, PROCTIME() AS proctime])
+ : +- TableSourceScan(table=[[default_catalog, default_database, MyTable]], fields=[a, b, c, rowtime])
+ +- Exchange(distribution=[hash[a]])
+ +- Calc(select=[a, b, c, window_start, window_end])
+ +- WindowTableFunction(window=[CUMULATE(time_col=[proctime], max_size=[1 h], step=[10 min])])
+ +- WatermarkAssigner(rowtime=[rowtime], watermark=[-(rowtime, 1000:INTERVAL SECOND)])
+ +- Calc(select=[a, b, c, rowtime, PROCTIME() AS proctime])
+ +- TableSourceScan(table=[[default_catalog, default_database, MyTable2]], fields=[a, b, c, rowtime])
+]]>
+ </Resource>
+ </TestCase>
+ <TestCase name="testCantMergeWindowTVF_Hop">
+ <Resource name="sql">
+ <![CDATA[
+SELECT L.a, L.b, L.c, R.a, R.b, R.c
+FROM (
+ SELECT *
+ FROM TABLE(
+ HOP(TABLE MyTable, DESCRIPTOR(rowtime), INTERVAL '5' MINUTE, INTERVAL '10' MINUTE))
+) L
+JOIN (
+ SELECT *
+ FROM TABLE(
+ HOP(TABLE MyTable2, DESCRIPTOR(rowtime), INTERVAL '5' MINUTE, INTERVAL '10' MINUTE))
+) R
+ON L.window_start = R.window_start AND L.window_end = R.window_end AND L.a = R.a
+ ]]>
+ </Resource>
+ <Resource name="ast">
+ <![CDATA[
+LogicalProject(a=[$0], b=[$1], c=[$2], a0=[$8], b0=[$9], c0=[$10])
++- LogicalJoin(condition=[AND(=($5, $13), =($6, $14), =($0, $8))], joinType=[inner])
+ :- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4], window_start=[$5], window_end=[$6], window_time=[$7])
+ : +- LogicalTableFunctionScan(invocation=[HOP($4, DESCRIPTOR($3), 300000:INTERVAL MINUTE, 600000:INTERVAL MINUTE)], rowType=[RecordType(INTEGER a, VARCHAR(2147483647) b, BIGINT c, TIME ATTRIBUTE(ROWTIME) rowtime, TIME ATTRIBUTE(PROCTIME) proctime, TIMESTAMP(3) window_start, TIMESTAMP(3) window_end, TIME ATTRIBUTE(ROWTIME) window_time)])
+ : +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4])
+ : +- LogicalWatermarkAssigner(rowtime=[rowtime], watermark=[-($3, 1000:INTERVAL SECOND)])
+ : +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[PROCTIME()])
+ : +- LogicalTableScan(table=[[default_catalog, default_database, MyTable]])
+ +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4], window_start=[$5], window_end=[$6], window_time=[$7])
+ +- LogicalTableFunctionScan(invocation=[HOP($4, DESCRIPTOR($3), 300000:INTERVAL MINUTE, 600000:INTERVAL MINUTE)], rowType=[RecordType(INTEGER a, VARCHAR(2147483647) b, BIGINT c, TIME ATTRIBUTE(ROWTIME) rowtime, TIME ATTRIBUTE(PROCTIME) proctime, TIMESTAMP(3) window_start, TIMESTAMP(3) window_end, TIME ATTRIBUTE(ROWTIME) window_time)])
+ +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4])
+ +- LogicalWatermarkAssigner(rowtime=[rowtime], watermark=[-($3, 1000:INTERVAL SECOND)])
+ +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[PROCTIME()])
+ +- LogicalTableScan(table=[[default_catalog, default_database, MyTable2]])
+]]>
+ </Resource>
+ <Resource name="optimized rel plan">
+ <![CDATA[
+Calc(select=[a, b, c, a0, b0, c0])
++- WindowJoin(leftWindow=[HOP(win_start=[window_start], win_end=[window_end], size=[10 min], slide=[5 min])], rightWindow=[HOP(win_start=[window_start], win_end=[window_end], size=[10 min], slide=[5 min])], joinType=[InnerJoin], where=[=(a, a0)], select=[a, b, c, window_start, window_end, a0, b0, c0, window_start0, window_end0])
+ :- Exchange(distribution=[hash[a]])
+ : +- Calc(select=[a, b, c, window_start, window_end])
+ : +- WindowTableFunction(window=[HOP(time_col=[rowtime], size=[10 min], slide=[5 min])])
+ : +- WatermarkAssigner(rowtime=[rowtime], watermark=[-(rowtime, 1000:INTERVAL SECOND)])
+ : +- Calc(select=[a, b, c, rowtime, PROCTIME() AS proctime])
+ : +- TableSourceScan(table=[[default_catalog, default_database, MyTable]], fields=[a, b, c, rowtime])
+ +- Exchange(distribution=[hash[a]])
+ +- Calc(select=[a, b, c, window_start, window_end])
+ +- WindowTableFunction(window=[HOP(time_col=[rowtime], size=[10 min], slide=[5 min])])
+ +- WatermarkAssigner(rowtime=[rowtime], watermark=[-(rowtime, 1000:INTERVAL SECOND)])
+ +- Calc(select=[a, b, c, rowtime, PROCTIME() AS proctime])
+ +- TableSourceScan(table=[[default_catalog, default_database, MyTable2]], fields=[a, b, c, rowtime])
+]]>
+ </Resource>
+ </TestCase>
+ <TestCase name="testCantMergeWindowTVF_HopOnProctime">
+ <Resource name="sql">
+ <![CDATA[
+SELECT L.a, L.b, L.c, R.a, R.b, R.c
+FROM (
+ SELECT *
+ FROM TABLE(
+ HOP(TABLE MyTable, DESCRIPTOR(proctime), INTERVAL '5' MINUTE, INTERVAL '10' MINUTE))
+) L
+JOIN (
+ SELECT *
+ FROM TABLE(
+ HOP(TABLE MyTable2, DESCRIPTOR(proctime), INTERVAL '5' MINUTE, INTERVAL '10' MINUTE))
+) R
+ON L.window_start = R.window_start AND L.window_end = R.window_end AND L.a = R.a
+ ]]>
+ </Resource>
+ <Resource name="ast">
+ <![CDATA[
+LogicalProject(a=[$0], b=[$1], c=[$2], a0=[$8], b0=[$9], c0=[$10])
++- LogicalJoin(condition=[AND(=($5, $13), =($6, $14), =($0, $8))], joinType=[inner])
+ :- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4], window_start=[$5], window_end=[$6], window_time=[$7])
+ : +- LogicalTableFunctionScan(invocation=[HOP($4, DESCRIPTOR($4), 300000:INTERVAL MINUTE, 600000:INTERVAL MINUTE)], rowType=[RecordType(INTEGER a, VARCHAR(2147483647) b, BIGINT c, TIME ATTRIBUTE(ROWTIME) rowtime, TIME ATTRIBUTE(PROCTIME) proctime, TIMESTAMP(3) window_start, TIMESTAMP(3) window_end, TIME ATTRIBUTE(PROCTIME) window_time)])
+ : +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4])
+ : +- LogicalWatermarkAssigner(rowtime=[rowtime], watermark=[-($3, 1000:INTERVAL SECOND)])
+ : +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[PROCTIME()])
+ : +- LogicalTableScan(table=[[default_catalog, default_database, MyTable]])
+ +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4], window_start=[$5], window_end=[$6], window_time=[$7])
+ +- LogicalTableFunctionScan(invocation=[HOP($4, DESCRIPTOR($4), 300000:INTERVAL MINUTE, 600000:INTERVAL MINUTE)], rowType=[RecordType(INTEGER a, VARCHAR(2147483647) b, BIGINT c, TIME ATTRIBUTE(ROWTIME) rowtime, TIME ATTRIBUTE(PROCTIME) proctime, TIMESTAMP(3) window_start, TIMESTAMP(3) window_end, TIME ATTRIBUTE(PROCTIME) window_time)])
+ +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4])
+ +- LogicalWatermarkAssigner(rowtime=[rowtime], watermark=[-($3, 1000:INTERVAL SECOND)])
+ +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[PROCTIME()])
+ +- LogicalTableScan(table=[[default_catalog, default_database, MyTable2]])
+]]>
+ </Resource>
+ <Resource name="optimized rel plan">
+ <![CDATA[
+Calc(select=[a, b, c, a0, b0, c0])
++- WindowJoin(leftWindow=[HOP(win_start=[window_start], win_end=[window_end], size=[10 min], slide=[5 min])], rightWindow=[HOP(win_start=[window_start], win_end=[window_end], size=[10 min], slide=[5 min])], joinType=[InnerJoin], where=[=(a, a0)], select=[a, b, c, window_start, window_end, a0, b0, c0, window_start0, window_end0])
+ :- Exchange(distribution=[hash[a]])
+ : +- Calc(select=[a, b, c, window_start, window_end])
+ : +- WindowTableFunction(window=[HOP(time_col=[proctime], size=[10 min], slide=[5 min])])
+ : +- WatermarkAssigner(rowtime=[rowtime], watermark=[-(rowtime, 1000:INTERVAL SECOND)])
+ : +- Calc(select=[a, b, c, rowtime, PROCTIME() AS proctime])
+ : +- TableSourceScan(table=[[default_catalog, default_database, MyTable]], fields=[a, b, c, rowtime])
+ +- Exchange(distribution=[hash[a]])
+ +- Calc(select=[a, b, c, window_start, window_end])
+ +- WindowTableFunction(window=[HOP(time_col=[proctime], size=[10 min], slide=[5 min])])
+ +- WatermarkAssigner(rowtime=[rowtime], watermark=[-(rowtime, 1000:INTERVAL SECOND)])
+ +- Calc(select=[a, b, c, rowtime, PROCTIME() AS proctime])
+ +- TableSourceScan(table=[[default_catalog, default_database, MyTable2]], fields=[a, b, c, rowtime])
+]]>
+ </Resource>
+ </TestCase>
+ <TestCase name="testCantMergeWindowTVF_Tumble">
+ <Resource name="sql">
+ <![CDATA[
+SELECT L.a, L.b, L.c, R.a, R.b, R.c
+FROM (
+ SELECT *
+ FROM TABLE(TUMBLE(TABLE MyTable, DESCRIPTOR(rowtime), INTERVAL '15' MINUTE))
+) L
+JOIN (
+ SELECT *
+ FROM TABLE(TUMBLE(TABLE MyTable2, DESCRIPTOR(rowtime), INTERVAL '15' MINUTE))
+) R
+ON L.window_start = R.window_start AND L.window_end = R.window_end AND L.a = R.a
+ ]]>
+ </Resource>
+ <Resource name="ast">
+ <![CDATA[
+LogicalProject(a=[$0], b=[$1], c=[$2], a0=[$8], b0=[$9], c0=[$10])
++- LogicalJoin(condition=[AND(=($5, $13), =($6, $14), =($0, $8))], joinType=[inner])
+ :- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4], window_start=[$5], window_end=[$6], window_time=[$7])
+ : +- LogicalTableFunctionScan(invocation=[TUMBLE($4, DESCRIPTOR($3), 900000:INTERVAL MINUTE)], rowType=[RecordType(INTEGER a, VARCHAR(2147483647) b, BIGINT c, TIME ATTRIBUTE(ROWTIME) rowtime, TIME ATTRIBUTE(PROCTIME) proctime, TIMESTAMP(3) window_start, TIMESTAMP(3) window_end, TIME ATTRIBUTE(ROWTIME) window_time)])
+ : +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4])
+ : +- LogicalWatermarkAssigner(rowtime=[rowtime], watermark=[-($3, 1000:INTERVAL SECOND)])
+ : +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[PROCTIME()])
+ : +- LogicalTableScan(table=[[default_catalog, default_database, MyTable]])
+ +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4], window_start=[$5], window_end=[$6], window_time=[$7])
+ +- LogicalTableFunctionScan(invocation=[TUMBLE($4, DESCRIPTOR($3), 900000:INTERVAL MINUTE)], rowType=[RecordType(INTEGER a, VARCHAR(2147483647) b, BIGINT c, TIME ATTRIBUTE(ROWTIME) rowtime, TIME ATTRIBUTE(PROCTIME) proctime, TIMESTAMP(3) window_start, TIMESTAMP(3) window_end, TIME ATTRIBUTE(ROWTIME) window_time)])
+ +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4])
+ +- LogicalWatermarkAssigner(rowtime=[rowtime], watermark=[-($3, 1000:INTERVAL SECOND)])
+ +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[PROCTIME()])
+ +- LogicalTableScan(table=[[default_catalog, default_database, MyTable2]])
+]]>
+ </Resource>
+ <Resource name="optimized rel plan">
+ <![CDATA[
+Calc(select=[a, b, c, a0, b0, c0])
++- WindowJoin(leftWindow=[TUMBLE(win_start=[window_start], win_end=[window_end], size=[15 min])], rightWindow=[TUMBLE(win_start=[window_start], win_end=[window_end], size=[15 min])], joinType=[InnerJoin], where=[=(a, a0)], select=[a, b, c, window_start, window_end, a0, b0, c0, window_start0, window_end0])
+ :- Exchange(distribution=[hash[a]])
+ : +- Calc(select=[a, b, c, window_start, window_end])
+ : +- WindowTableFunction(window=[TUMBLE(time_col=[rowtime], size=[15 min])])
+ : +- WatermarkAssigner(rowtime=[rowtime], watermark=[-(rowtime, 1000:INTERVAL SECOND)])
+ : +- Calc(select=[a, b, c, rowtime, PROCTIME() AS proctime])
+ : +- TableSourceScan(table=[[default_catalog, default_database, MyTable]], fields=[a, b, c, rowtime])
+ +- Exchange(distribution=[hash[a]])
+ +- Calc(select=[a, b, c, window_start, window_end])
+ +- WindowTableFunction(window=[TUMBLE(time_col=[rowtime], size=[15 min])])
+ +- WatermarkAssigner(rowtime=[rowtime], watermark=[-(rowtime, 1000:INTERVAL SECOND)])
+ +- Calc(select=[a, b, c, rowtime, PROCTIME() AS proctime])
+ +- TableSourceScan(table=[[default_catalog, default_database, MyTable2]], fields=[a, b, c, rowtime])
+]]>
+ </Resource>
+ </TestCase>
+ <TestCase name="testCantMergeWindowTVF_TumbleOnProctime">
+ <Resource name="sql">
+ <![CDATA[
+SELECT L.a, L.b, L.c, R.a, R.b, R.c
+FROM (
+ SELECT *
+ FROM TABLE(TUMBLE(TABLE MyTable, DESCRIPTOR(proctime), INTERVAL '15' MINUTE))
+) L
+JOIN (
+ SELECT *
+ FROM TABLE(TUMBLE(TABLE MyTable2, DESCRIPTOR(proctime), INTERVAL '15' MINUTE))
+) R
+ON L.window_start = R.window_start AND L.window_end = R.window_end AND L.a = R.a
+ ]]>
+ </Resource>
+ <Resource name="ast">
+ <![CDATA[
+LogicalProject(a=[$0], b=[$1], c=[$2], a0=[$8], b0=[$9], c0=[$10])
++- LogicalJoin(condition=[AND(=($5, $13), =($6, $14), =($0, $8))], joinType=[inner])
+ :- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4], window_start=[$5], window_end=[$6], window_time=[$7])
+ : +- LogicalTableFunctionScan(invocation=[TUMBLE($4, DESCRIPTOR($4), 900000:INTERVAL MINUTE)], rowType=[RecordType(INTEGER a, VARCHAR(2147483647) b, BIGINT c, TIME ATTRIBUTE(ROWTIME) rowtime, TIME ATTRIBUTE(PROCTIME) proctime, TIMESTAMP(3) window_start, TIMESTAMP(3) window_end, TIME ATTRIBUTE(PROCTIME) window_time)])
+ : +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4])
+ : +- LogicalWatermarkAssigner(rowtime=[rowtime], watermark=[-($3, 1000:INTERVAL SECOND)])
+ : +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[PROCTIME()])
+ : +- LogicalTableScan(table=[[default_catalog, default_database, MyTable]])
+ +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4], window_start=[$5], window_end=[$6], window_time=[$7])
+ +- LogicalTableFunctionScan(invocation=[TUMBLE($4, DESCRIPTOR($4), 900000:INTERVAL MINUTE)], rowType=[RecordType(INTEGER a, VARCHAR(2147483647) b, BIGINT c, TIME ATTRIBUTE(ROWTIME) rowtime, TIME ATTRIBUTE(PROCTIME) proctime, TIMESTAMP(3) window_start, TIMESTAMP(3) window_end, TIME ATTRIBUTE(PROCTIME) window_time)])
+ +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4])
+ +- LogicalWatermarkAssigner(rowtime=[rowtime], watermark=[-($3, 1000:INTERVAL SECOND)])
+ +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[PROCTIME()])
+ +- LogicalTableScan(table=[[default_catalog, default_database, MyTable2]])
+]]>
+ </Resource>
+ <Resource name="optimized rel plan">
+ <![CDATA[
+Calc(select=[a, b, c, a0, b0, c0])
++- WindowJoin(leftWindow=[TUMBLE(win_start=[window_start], win_end=[window_end], size=[15 min])], rightWindow=[TUMBLE(win_start=[window_start], win_end=[window_end], size=[15 min])], joinType=[InnerJoin], where=[=(a, a0)], select=[a, b, c, window_start, window_end, a0, b0, c0, window_start0, window_end0])
+ :- Exchange(distribution=[hash[a]])
+ : +- Calc(select=[a, b, c, window_start, window_end])
+ : +- WindowTableFunction(window=[TUMBLE(time_col=[proctime], size=[15 min])])
+ : +- WatermarkAssigner(rowtime=[rowtime], watermark=[-(rowtime, 1000:INTERVAL SECOND)])
+ : +- Calc(select=[a, b, c, rowtime, PROCTIME() AS proctime])
+ : +- TableSourceScan(table=[[default_catalog, default_database, MyTable]], fields=[a, b, c, rowtime])
+ +- Exchange(distribution=[hash[a]])
+ +- Calc(select=[a, b, c, window_start, window_end])
+ +- WindowTableFunction(window=[TUMBLE(time_col=[proctime], size=[15 min])])
+ +- WatermarkAssigner(rowtime=[rowtime], watermark=[-(rowtime, 1000:INTERVAL SECOND)])
+ +- Calc(select=[a, b, c, rowtime, PROCTIME() AS proctime])
+ +- TableSourceScan(table=[[default_catalog, default_database, MyTable2]], fields=[a, b, c, rowtime])
+]]>
+ </Resource>
+ </TestCase>
+ <TestCase name="testOnCumulateWindowAggregate">
+ <Resource name="sql">
+ <![CDATA[
+SELECT L.*, R.*
+FROM (
+ SELECT
+ a,
+ window_start,
+ window_end,
+ window_time,
+ count(*) as cnt,
+ count(distinct c) AS uv
+ FROM TABLE(
+ CUMULATE(
+ TABLE MyTable, DESCRIPTOR(rowtime), INTERVAL '10' MINUTE, INTERVAL '1' HOUR))
+ GROUP BY a, window_start, window_end, window_time
+) L
+JOIN (
+ SELECT
+ a,
+ window_start,
+ window_end,
+ window_time,
+ count(*) as cnt,
+ count(distinct c) AS uv
+ FROM TABLE(
+ CUMULATE(
+ TABLE MyTable2, DESCRIPTOR(rowtime), INTERVAL '10' MINUTE, INTERVAL '1' HOUR))
+ GROUP BY a, window_start, window_end, window_time
+) R
+ON L.window_start = R.window_start AND L.window_end = R.window_end AND L.a = R.a
+ ]]>
+ </Resource>
+ <Resource name="ast">
+ <![CDATA[
+LogicalProject(a=[$0], window_start=[$1], window_end=[$2], window_time=[$3], cnt=[$4], uv=[$5], a0=[$6], window_start0=[$7], window_end0=[$8], window_time0=[$9], cnt0=[$10], uv0=[$11])
++- LogicalJoin(condition=[AND(=($1, $7), =($2, $8), =($0, $6))], joinType=[inner])
+ :- LogicalAggregate(group=[{0, 1, 2, 3}], cnt=[COUNT()], uv=[COUNT(DISTINCT $4)])
+ : +- LogicalProject(a=[$0], window_start=[$5], window_end=[$6], window_time=[$7], c=[$2])
+ : +- LogicalTableFunctionScan(invocation=[CUMULATE($4, DESCRIPTOR($3), 600000:INTERVAL MINUTE, 3600000:INTERVAL HOUR)], rowType=[RecordType(INTEGER a, VARCHAR(2147483647) b, BIGINT c, TIME ATTRIBUTE(ROWTIME) rowtime, TIME ATTRIBUTE(PROCTIME) proctime, TIMESTAMP(3) window_start, TIMESTAMP(3) window_end, TIME ATTRIBUTE(ROWTIME) window_time)])
+ : +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4])
+ : +- LogicalWatermarkAssigner(rowtime=[rowtime], watermark=[-($3, 1000:INTERVAL SECOND)])
+ : +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[PROCTIME()])
+ : +- LogicalTableScan(table=[[default_catalog, default_database, MyTable]])
+ +- LogicalAggregate(group=[{0, 1, 2, 3}], cnt=[COUNT()], uv=[COUNT(DISTINCT $4)])
+ +- LogicalProject(a=[$0], window_start=[$5], window_end=[$6], window_time=[$7], c=[$2])
+ +- LogicalTableFunctionScan(invocation=[CUMULATE($4, DESCRIPTOR($3), 600000:INTERVAL MINUTE, 3600000:INTERVAL HOUR)], rowType=[RecordType(INTEGER a, VARCHAR(2147483647) b, BIGINT c, TIME ATTRIBUTE(ROWTIME) rowtime, TIME ATTRIBUTE(PROCTIME) proctime, TIMESTAMP(3) window_start, TIMESTAMP(3) window_end, TIME ATTRIBUTE(ROWTIME) window_time)])
+ +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4])
+ +- LogicalWatermarkAssigner(rowtime=[rowtime], watermark=[-($3, 1000:INTERVAL SECOND)])
+ +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[PROCTIME()])
+ +- LogicalTableScan(table=[[default_catalog, default_database, MyTable2]])
+]]>
+ </Resource>
+ <Resource name="optimized rel plan">
+ <![CDATA[
+WindowJoin(leftWindow=[CUMULATE(win_start=[window_start], win_end=[window_end], max_size=[1 h], step=[10 min])], rightWindow=[CUMULATE(win_start=[window_start], win_end=[window_end], max_size=[1 h], step=[10 min])], joinType=[InnerJoin], where=[=(a, a0)], select=[a, window_start, window_end, window_time, cnt, uv, a0, window_start0, window_end0, window_time0, cnt0, uv0])
+:- Exchange(distribution=[hash[a]])
+: +- Calc(select=[a, window_start, window_end, window_time, cnt, uv])
+: +- WindowAggregate(groupBy=[a], window=[CUMULATE(time_col=[rowtime], max_size=[1 h], step=[10 min])], select=[a, COUNT(*) AS cnt, COUNT(DISTINCT c) AS uv, start('w$) AS window_start, end('w$) AS window_end, rowtime('w$) AS window_time])
+: +- Exchange(distribution=[hash[a]])
+: +- Calc(select=[a, c, rowtime])
+: +- WatermarkAssigner(rowtime=[rowtime], watermark=[-(rowtime, 1000:INTERVAL SECOND)])
+: +- Calc(select=[a, b, c, rowtime, PROCTIME() AS proctime])
+: +- TableSourceScan(table=[[default_catalog, default_database, MyTable]], fields=[a, b, c, rowtime])
++- Exchange(distribution=[hash[a]])
+ +- Calc(select=[a, window_start, window_end, window_time, cnt, uv])
+ +- WindowAggregate(groupBy=[a], window=[CUMULATE(time_col=[rowtime], max_size=[1 h], step=[10 min])], select=[a, COUNT(*) AS cnt, COUNT(DISTINCT c) AS uv, start('w$) AS window_start, end('w$) AS window_end, rowtime('w$) AS window_time])
+ +- Exchange(distribution=[hash[a]])
+ +- Calc(select=[a, c, rowtime])
+ +- WatermarkAssigner(rowtime=[rowtime], watermark=[-(rowtime, 1000:INTERVAL SECOND)])
+ +- Calc(select=[a, b, c, rowtime, PROCTIME() AS proctime])
+ +- TableSourceScan(table=[[default_catalog, default_database, MyTable2]], fields=[a, b, c, rowtime])
+]]>
+ </Resource>
+ </TestCase>
+ <TestCase name="testTimeAttributePropagateForWindowJoin1">
+ <Resource name="sql">
+ <![CDATA[
+SELECT tmp1.*, MyTable4.* FROM tmp1 JOIN MyTable4 ON
+ tmp1.a = MyTable4.a AND
+ tmp1.rowtime BETWEEN
+ MyTable4.rowtime - INTERVAL '10' SECOND AND
+ MyTable4.rowtime + INTERVAL '1' HOUR
+]]>
+ </Resource>
+ <Resource name="ast">
+ <![CDATA[
+LogicalProject(rowtime=[$0], a=[$1], l_cnt=[$2], l_uv=[$3], r_cnt=[$4], r_uv=[$5], a0=[$6], b=[$7], c=[$8], rowtime0=[$9], proctime=[$10])
++- LogicalJoin(condition=[AND(=($1, $6), >=($0, -($9, 10000:INTERVAL SECOND)), <=($0, +($9, 3600000:INTERVAL HOUR)))], joinType=[inner])
+ :- LogicalProject(rowtime=[$3], a=[$0], l_cnt=[$4], l_uv=[$5], r_cnt=[$10], r_uv=[$11])
+ : +- LogicalJoin(condition=[AND(=($1, $7), =($2, $8), =($0, $6))], joinType=[inner])
+ : :- LogicalAggregate(group=[{0, 1, 2, 3}], cnt=[COUNT()], uv=[COUNT(DISTINCT $4)])
+ : : +- LogicalProject(a=[$0], window_start=[$5], window_end=[$6], window_time=[$7], c=[$2])
+ : : +- LogicalTableFunctionScan(invocation=[CUMULATE($4, DESCRIPTOR($3), 600000:INTERVAL MINUTE, 3600000:INTERVAL HOUR)], rowType=[RecordType(INTEGER a, VARCHAR(2147483647) b, BIGINT c, TIME ATTRIBUTE(ROWTIME) rowtime, TIME ATTRIBUTE(PROCTIME) proctime, TIMESTAMP(3) window_start, TIMESTAMP(3) window_end, TIME ATTRIBUTE(ROWTIME) window_time)])
+ : : +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4])
+ : : +- LogicalWatermarkAssigner(rowtime=[rowtime], watermark=[-($3, 1000:INTERVAL SECOND)])
+ : : +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[PROCTIME()])
+ : : +- LogicalTableScan(table=[[default_catalog, default_database, MyTable]])
+ : +- LogicalAggregate(group=[{0, 1, 2, 3}], cnt=[COUNT()], uv=[COUNT(DISTINCT $4)])
+ : +- LogicalProject(a=[$0], window_start=[$5], window_end=[$6], window_time=[$7], c=[$2])
+ : +- LogicalTableFunctionScan(invocation=[CUMULATE($4, DESCRIPTOR($3), 600000:INTERVAL MINUTE, 3600000:INTERVAL HOUR)], rowType=[RecordType(INTEGER a, VARCHAR(2147483647) b, BIGINT c, TIME ATTRIBUTE(ROWTIME) rowtime, TIME ATTRIBUTE(PROCTIME) proctime, TIMESTAMP(3) window_start, TIMESTAMP(3) window_end, TIME ATTRIBUTE(ROWTIME) window_time)])
+ : +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4])
+ : +- LogicalWatermarkAssigner(rowtime=[rowtime], watermark=[-($3, 1000:INTERVAL SECOND)])
+ : +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[PROCTIME()])
+ : +- LogicalTableScan(table=[[default_catalog, default_database, MyTable2]])
+ +- LogicalWatermarkAssigner(rowtime=[rowtime], watermark=[-($3, 1000:INTERVAL SECOND)])
+ +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[PROCTIME()])
+ +- LogicalTableScan(table=[[default_catalog, default_database, MyTable4]])
+]]>
+ </Resource>
+ <Resource name="optimized rel plan">
+ <![CDATA[
+Calc(select=[rowtime, a, l_cnt, l_uv, r_cnt, r_uv, a0, b, c, rowtime0, PROCTIME_MATERIALIZE(proctime) AS proctime])
++- IntervalJoin(joinType=[InnerJoin], windowBounds=[isRowTime=true, leftLowerBound=-10000, leftUpperBound=3600000, leftTimeIndex=0, rightTimeIndex=3], where=[AND(=(a, a0), >=(rowtime, -(rowtime0, 10000:INTERVAL SECOND)), <=(rowtime, +(rowtime0, 3600000:INTERVAL HOUR)))], select=[rowtime, a, l_cnt, l_uv, r_cnt, r_uv, a0, b, c, rowtime0, proctime])
+ :- Exchange(distribution=[hash[a]])
+ : +- Calc(select=[window_time AS rowtime, a, cnt AS l_cnt, uv AS l_uv, cnt0 AS r_cnt, uv0 AS r_uv])
+ : +- WindowJoin(leftWindow=[CUMULATE(win_start=[window_start], win_end=[window_end], max_size=[1 h], step=[10 min])], rightWindow=[CUMULATE(win_start=[window_start], win_end=[window_end], max_size=[1 h], step=[10 min])], joinType=[InnerJoin], where=[=(a, a0)], select=[a, window_start, window_end, window_time, cnt, uv, a0, window_start0, window_end0, cnt0, uv0])
+ : :- Exchange(distribution=[hash[a]])
+ : : +- Calc(select=[a, window_start, window_end, window_time, cnt, uv])
+ : : +- WindowAggregate(groupBy=[a], window=[CUMULATE(time_col=[rowtime], max_size=[1 h], step=[10 min])], select=[a, COUNT(*) AS cnt, COUNT(DISTINCT c) AS uv, start('w$) AS window_start, end('w$) AS window_end, rowtime('w$) AS window_time])
+ : : +- Exchange(distribution=[hash[a]])
+ : : +- Calc(select=[a, c, rowtime])
+ : : +- WatermarkAssigner(rowtime=[rowtime], watermark=[-(rowtime, 1000:INTERVAL SECOND)])
+ : : +- Calc(select=[a, b, c, rowtime, PROCTIME() AS proctime])
+ : : +- TableSourceScan(table=[[default_catalog, default_database, MyTable]], fields=[a, b, c, rowtime])
+ : +- Exchange(distribution=[hash[a]])
+ : +- Calc(select=[a, window_start, window_end, cnt, uv])
+ : +- WindowAggregate(groupBy=[a], window=[CUMULATE(time_col=[rowtime], max_size=[1 h], step=[10 min])], select=[a, COUNT(*) AS cnt, COUNT(DISTINCT c) AS uv, start('w$) AS window_start, end('w$) AS window_end, rowtime('w$) AS window_time])
+ : +- Exchange(distribution=[hash[a]])
+ : +- Calc(select=[a, c, rowtime])
+ : +- WatermarkAssigner(rowtime=[rowtime], watermark=[-(rowtime, 1000:INTERVAL SECOND)])
+ : +- Calc(select=[a, b, c, rowtime, PROCTIME() AS proctime])
+ : +- TableSourceScan(table=[[default_catalog, default_database, MyTable2]], fields=[a, b, c, rowtime])
+ +- Exchange(distribution=[hash[a]])
+ +- WatermarkAssigner(rowtime=[rowtime], watermark=[-(rowtime, 1000:INTERVAL SECOND)])
+ +- Calc(select=[a, b, c, rowtime, PROCTIME() AS proctime])
+ +- TableSourceScan(table=[[default_catalog, default_database, MyTable4]], fields=[a, b, c, rowtime])
+]]>
+ </Resource>
+ </TestCase>
+ <TestCase name="testOnCumulateWindowAggregateOnProctime">
+ <Resource name="sql">
+ <![CDATA[
+SELECT L.*, R.*
+FROM (
+ SELECT
+ a,
+ window_start,
+ window_end,
+ window_time,
+ count(*) as cnt,
+ count(distinct c) AS uv
+ FROM TABLE(
+ CUMULATE(
+ TABLE MyTable, DESCRIPTOR(proctime), INTERVAL '10' MINUTE, INTERVAL '1' HOUR))
+ GROUP BY a, window_start, window_end, window_time
+) L
+JOIN (
+ SELECT
+ a,
+ window_start,
+ window_end,
+ window_time,
+ count(*) as cnt,
+ count(distinct c) AS uv
+ FROM TABLE(
+ CUMULATE(
+ TABLE MyTable2, DESCRIPTOR(proctime), INTERVAL '10' MINUTE, INTERVAL '1' HOUR))
+ GROUP BY a, window_start, window_end, window_time
+) R
+ON L.window_start = R.window_start AND L.window_end = R.window_end AND L.a = R.a
+ ]]>
+ </Resource>
+ <Resource name="ast">
+ <![CDATA[
+LogicalProject(a=[$0], window_start=[$1], window_end=[$2], window_time=[$3], cnt=[$4], uv=[$5], a0=[$6], window_start0=[$7], window_end0=[$8], window_time0=[$9], cnt0=[$10], uv0=[$11])
++- LogicalJoin(condition=[AND(=($1, $7), =($2, $8), =($0, $6))], joinType=[inner])
+ :- LogicalAggregate(group=[{0, 1, 2, 3}], cnt=[COUNT()], uv=[COUNT(DISTINCT $4)])
+ : +- LogicalProject(a=[$0], window_start=[$5], window_end=[$6], window_time=[$7], c=[$2])
+ : +- LogicalTableFunctionScan(invocation=[CUMULATE($4, DESCRIPTOR($4), 600000:INTERVAL MINUTE, 3600000:INTERVAL HOUR)], rowType=[RecordType(INTEGER a, VARCHAR(2147483647) b, BIGINT c, TIME ATTRIBUTE(ROWTIME) rowtime, TIME ATTRIBUTE(PROCTIME) proctime, TIMESTAMP(3) window_start, TIMESTAMP(3) window_end, TIME ATTRIBUTE(PROCTIME) window_time)])
+ : +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4])
+ : +- LogicalWatermarkAssigner(rowtime=[rowtime], watermark=[-($3, 1000:INTERVAL SECOND)])
+ : +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[PROCTIME()])
+ : +- LogicalTableScan(table=[[default_catalog, default_database, MyTable]])
+ +- LogicalAggregate(group=[{0, 1, 2, 3}], cnt=[COUNT()], uv=[COUNT(DISTINCT $4)])
+ +- LogicalProject(a=[$0], window_start=[$5], window_end=[$6], window_time=[$7], c=[$2])
+ +- LogicalTableFunctionScan(invocation=[CUMULATE($4, DESCRIPTOR($4), 600000:INTERVAL MINUTE, 3600000:INTERVAL HOUR)], rowType=[RecordType(INTEGER a, VARCHAR(2147483647) b, BIGINT c, TIME ATTRIBUTE(ROWTIME) rowtime, TIME ATTRIBUTE(PROCTIME) proctime, TIMESTAMP(3) window_start, TIMESTAMP(3) window_end, TIME ATTRIBUTE(PROCTIME) window_time)])
+ +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4])
+ +- LogicalWatermarkAssigner(rowtime=[rowtime], watermark=[-($3, 1000:INTERVAL SECOND)])
+ +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[PROCTIME()])
+ +- LogicalTableScan(table=[[default_catalog, default_database, MyTable2]])
+]]>
+ </Resource>
+ <Resource name="optimized rel plan">
+ <![CDATA[
+Calc(select=[a, window_start, window_end, PROCTIME_MATERIALIZE(window_time) AS window_time, cnt, uv, a0, window_start0, window_end0, PROCTIME_MATERIALIZE(window_time0) AS window_time0, cnt0, uv0])
++- WindowJoin(leftWindow=[CUMULATE(win_start=[window_start], win_end=[window_end], max_size=[1 h], step=[10 min])], rightWindow=[CUMULATE(win_start=[window_start], win_end=[window_end], max_size=[1 h], step=[10 min])], joinType=[InnerJoin], where=[=(a, a0)], select=[a, window_start, window_end, window_time, cnt, uv, a0, window_start0, window_end0, window_time0, cnt0, uv0])
+ :- Exchange(distribution=[hash[a]])
+ : +- Calc(select=[a, window_start, window_end, window_time, cnt, uv])
+ : +- WindowAggregate(groupBy=[a], window=[CUMULATE(time_col=[proctime], max_size=[1 h], step=[10 min])], select=[a, COUNT(*) AS cnt, COUNT(DISTINCT c) AS uv, start('w$) AS window_start, end('w$) AS window_end, proctime('w$) AS window_time])
+ : +- Exchange(distribution=[hash[a]])
+ : +- Calc(select=[a, c, proctime])
+ : +- WatermarkAssigner(rowtime=[rowtime], watermark=[-(rowtime, 1000:INTERVAL SECOND)])
+ : +- Calc(select=[a, b, c, rowtime, PROCTIME() AS proctime])
+ : +- TableSourceScan(table=[[default_catalog, default_database, MyTable]], fields=[a, b, c, rowtime])
+ +- Exchange(distribution=[hash[a]])
+ +- Calc(select=[a, window_start, window_end, window_time, cnt, uv])
+ +- WindowAggregate(groupBy=[a], window=[CUMULATE(time_col=[proctime], max_size=[1 h], step=[10 min])], select=[a, COUNT(*) AS cnt, COUNT(DISTINCT c) AS uv, start('w$) AS window_start, end('w$) AS window_end, proctime('w$) AS window_time])
+ +- Exchange(distribution=[hash[a]])
+ +- Calc(select=[a, c, proctime])
+ +- WatermarkAssigner(rowtime=[rowtime], watermark=[-(rowtime, 1000:INTERVAL SECOND)])
+ +- Calc(select=[a, b, c, rowtime, PROCTIME() AS proctime])
+ +- TableSourceScan(table=[[default_catalog, default_database, MyTable2]], fields=[a, b, c, rowtime])
+]]>
+ </Resource>
+ </TestCase>
+ <TestCase name="testOnHopWindowAggregate">
+ <Resource name="sql">
+ <![CDATA[
+SELECT L.*, R.*
+FROM (
+ SELECT
+ a,
+ window_start,
+ window_end,
+ window_time,
+ count(*) as cnt,
+ count(distinct c) AS uv
+ FROM TABLE(
+ HOP(TABLE MyTable, DESCRIPTOR(rowtime), INTERVAL '5' MINUTE, INTERVAL '10' MINUTE))
+ GROUP BY a, window_start, window_end, window_time
+) L
+JOIN (
+ SELECT
+ a,
+ window_start,
+ window_end,
+ window_time,
+ count(*) as cnt,
+ count(distinct c) AS uv
+ FROM TABLE(
+ HOP(TABLE MyTable2, DESCRIPTOR(rowtime), INTERVAL '5' MINUTE, INTERVAL '10' MINUTE))
+ GROUP BY a, window_start, window_end, window_time
+) R
+ON L.window_start = R.window_start AND L.window_end = R.window_end AND L.a = R.a
+ ]]>
+ </Resource>
+ <Resource name="ast">
+ <![CDATA[
+LogicalProject(a=[$0], window_start=[$1], window_end=[$2], window_time=[$3], cnt=[$4], uv=[$5], a0=[$6], window_start0=[$7], window_end0=[$8], window_time0=[$9], cnt0=[$10], uv0=[$11])
++- LogicalJoin(condition=[AND(=($1, $7), =($2, $8), =($0, $6))], joinType=[inner])
+ :- LogicalAggregate(group=[{0, 1, 2, 3}], cnt=[COUNT()], uv=[COUNT(DISTINCT $4)])
+ : +- LogicalProject(a=[$0], window_start=[$5], window_end=[$6], window_time=[$7], c=[$2])
+ : +- LogicalTableFunctionScan(invocation=[HOP($4, DESCRIPTOR($3), 300000:INTERVAL MINUTE, 600000:INTERVAL MINUTE)], rowType=[RecordType(INTEGER a, VARCHAR(2147483647) b, BIGINT c, TIME ATTRIBUTE(ROWTIME) rowtime, TIME ATTRIBUTE(PROCTIME) proctime, TIMESTAMP(3) window_start, TIMESTAMP(3) window_end, TIME ATTRIBUTE(ROWTIME) window_time)])
+ : +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4])
+ : +- LogicalWatermarkAssigner(rowtime=[rowtime], watermark=[-($3, 1000:INTERVAL SECOND)])
+ : +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[PROCTIME()])
+ : +- LogicalTableScan(table=[[default_catalog, default_database, MyTable]])
+ +- LogicalAggregate(group=[{0, 1, 2, 3}], cnt=[COUNT()], uv=[COUNT(DISTINCT $4)])
+ +- LogicalProject(a=[$0], window_start=[$5], window_end=[$6], window_time=[$7], c=[$2])
+ +- LogicalTableFunctionScan(invocation=[HOP($4, DESCRIPTOR($3), 300000:INTERVAL MINUTE, 600000:INTERVAL MINUTE)], rowType=[RecordType(INTEGER a, VARCHAR(2147483647) b, BIGINT c, TIME ATTRIBUTE(ROWTIME) rowtime, TIME ATTRIBUTE(PROCTIME) proctime, TIMESTAMP(3) window_start, TIMESTAMP(3) window_end, TIME ATTRIBUTE(ROWTIME) window_time)])
+ +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4])
+ +- LogicalWatermarkAssigner(rowtime=[rowtime], watermark=[-($3, 1000:INTERVAL SECOND)])
+ +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[PROCTIME()])
+ +- LogicalTableScan(table=[[default_catalog, default_database, MyTable2]])
+]]>
+ </Resource>
+ <Resource name="optimized rel plan">
+ <![CDATA[
+WindowJoin(leftWindow=[HOP(win_start=[window_start], win_end=[window_end], size=[10 min], slide=[5 min])], rightWindow=[HOP(win_start=[window_start], win_end=[window_end], size=[10 min], slide=[5 min])], joinType=[InnerJoin], where=[=(a, a0)], select=[a, window_start, window_end, window_time, cnt, uv, a0, window_start0, window_end0, window_time0, cnt0, uv0])
+:- Exchange(distribution=[hash[a]])
+: +- Calc(select=[a, window_start, window_end, window_time, cnt, uv])
+: +- WindowAggregate(groupBy=[a], window=[HOP(time_col=[rowtime], size=[10 min], slide=[5 min])], select=[a, COUNT(*) AS cnt, COUNT(DISTINCT c) AS uv, start('w$) AS window_start, end('w$) AS window_end, rowtime('w$) AS window_time])
+: +- Exchange(distribution=[hash[a]])
+: +- Calc(select=[a, c, rowtime])
+: +- WatermarkAssigner(rowtime=[rowtime], watermark=[-(rowtime, 1000:INTERVAL SECOND)])
+: +- Calc(select=[a, b, c, rowtime, PROCTIME() AS proctime])
+: +- TableSourceScan(table=[[default_catalog, default_database, MyTable]], fields=[a, b, c, rowtime])
++- Exchange(distribution=[hash[a]])
+ +- Calc(select=[a, window_start, window_end, window_time, cnt, uv])
+ +- WindowAggregate(groupBy=[a], window=[HOP(time_col=[rowtime], size=[10 min], slide=[5 min])], select=[a, COUNT(*) AS cnt, COUNT(DISTINCT c) AS uv, start('w$) AS window_start, end('w$) AS window_end, rowtime('w$) AS window_time])
+ +- Exchange(distribution=[hash[a]])
+ +- Calc(select=[a, c, rowtime])
+ +- WatermarkAssigner(rowtime=[rowtime], watermark=[-(rowtime, 1000:INTERVAL SECOND)])
+ +- Calc(select=[a, b, c, rowtime, PROCTIME() AS proctime])
+ +- TableSourceScan(table=[[default_catalog, default_database, MyTable2]], fields=[a, b, c, rowtime])
+]]>
+ </Resource>
+ </TestCase>
+ <TestCase name="testOnHopWindowAggregateOnProctime">
+ <Resource name="sql">
+ <![CDATA[
+SELECT L.*, R.*
+FROM (
+ SELECT
+ a,
+ window_start,
+ window_end,
+ window_time,
+ count(*) as cnt,
+ count(distinct c) AS uv
+ FROM TABLE(
+ HOP(TABLE MyTable, DESCRIPTOR(proctime), INTERVAL '5' MINUTE, INTERVAL '10' MINUTE))
+ GROUP BY a, window_start, window_end, window_time
+) L
+JOIN (
+ SELECT
+ a,
+ window_start,
+ window_end,
+ window_time,
+ count(*) as cnt,
+ count(distinct c) AS uv
+ FROM TABLE(
+ HOP(TABLE MyTable2, DESCRIPTOR(proctime), INTERVAL '5' MINUTE, INTERVAL '10' MINUTE))
+ GROUP BY a, window_start, window_end, window_time
+) R
+ON L.window_start = R.window_start AND L.window_end = R.window_end AND L.a = R.a
+ ]]>
+ </Resource>
+ <Resource name="ast">
+ <![CDATA[
+LogicalProject(a=[$0], window_start=[$1], window_end=[$2], window_time=[$3], cnt=[$4], uv=[$5], a0=[$6], window_start0=[$7], window_end0=[$8], window_time0=[$9], cnt0=[$10], uv0=[$11])
++- LogicalJoin(condition=[AND(=($1, $7), =($2, $8), =($0, $6))], joinType=[inner])
+ :- LogicalAggregate(group=[{0, 1, 2, 3}], cnt=[COUNT()], uv=[COUNT(DISTINCT $4)])
+ : +- LogicalProject(a=[$0], window_start=[$5], window_end=[$6], window_time=[$7], c=[$2])
+ : +- LogicalTableFunctionScan(invocation=[HOP($4, DESCRIPTOR($4), 300000:INTERVAL MINUTE, 600000:INTERVAL MINUTE)], rowType=[RecordType(INTEGER a, VARCHAR(2147483647) b, BIGINT c, TIME ATTRIBUTE(ROWTIME) rowtime, TIME ATTRIBUTE(PROCTIME) proctime, TIMESTAMP(3) window_start, TIMESTAMP(3) window_end, TIME ATTRIBUTE(PROCTIME) window_time)])
+ : +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4])
+ : +- LogicalWatermarkAssigner(rowtime=[rowtime], watermark=[-($3, 1000:INTERVAL SECOND)])
+ : +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[PROCTIME()])
+ : +- LogicalTableScan(table=[[default_catalog, default_database, MyTable]])
+ +- LogicalAggregate(group=[{0, 1, 2, 3}], cnt=[COUNT()], uv=[COUNT(DISTINCT $4)])
+ +- LogicalProject(a=[$0], window_start=[$5], window_end=[$6], window_time=[$7], c=[$2])
+ +- LogicalTableFunctionScan(invocation=[HOP($4, DESCRIPTOR($4), 300000:INTERVAL MINUTE, 600000:INTERVAL MINUTE)], rowType=[RecordType(INTEGER a, VARCHAR(2147483647) b, BIGINT c, TIME ATTRIBUTE(ROWTIME) rowtime, TIME ATTRIBUTE(PROCTIME) proctime, TIMESTAMP(3) window_start, TIMESTAMP(3) window_end, TIME ATTRIBUTE(PROCTIME) window_time)])
+ +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4])
+ +- LogicalWatermarkAssigner(rowtime=[rowtime], watermark=[-($3, 1000:INTERVAL SECOND)])
+ +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[PROCTIME()])
+ +- LogicalTableScan(table=[[default_catalog, default_database, MyTable2]])
+]]>
+ </Resource>
+ <Resource name="optimized rel plan">
+ <![CDATA[
+Calc(select=[a, window_start, window_end, PROCTIME_MATERIALIZE(window_time) AS window_time, cnt, uv, a0, window_start0, window_end0, PROCTIME_MATERIALIZE(window_time0) AS window_time0, cnt0, uv0])
++- WindowJoin(leftWindow=[HOP(win_start=[window_start], win_end=[window_end], size=[10 min], slide=[5 min])], rightWindow=[HOP(win_start=[window_start], win_end=[window_end], size=[10 min], slide=[5 min])], joinType=[InnerJoin], where=[=(a, a0)], select=[a, window_start, window_end, window_time, cnt, uv, a0, window_start0, window_end0, window_time0, cnt0, uv0])
+ :- Exchange(distribution=[hash[a]])
+ : +- Calc(select=[a, window_start, window_end, window_time, cnt, uv])
+ : +- WindowAggregate(groupBy=[a], window=[HOP(time_col=[proctime], size=[10 min], slide=[5 min])], select=[a, COUNT(*) AS cnt, COUNT(DISTINCT c) AS uv, start('w$) AS window_start, end('w$) AS window_end, proctime('w$) AS window_time])
+ : +- Exchange(distribution=[hash[a]])
+ : +- Calc(select=[a, c, proctime])
+ : +- WatermarkAssigner(rowtime=[rowtime], watermark=[-(rowtime, 1000:INTERVAL SECOND)])
+ : +- Calc(select=[a, b, c, rowtime, PROCTIME() AS proctime])
+ : +- TableSourceScan(table=[[default_catalog, default_database, MyTable]], fields=[a, b, c, rowtime])
+ +- Exchange(distribution=[hash[a]])
+ +- Calc(select=[a, window_start, window_end, window_time, cnt, uv])
+ +- WindowAggregate(groupBy=[a], window=[HOP(time_col=[proctime], size=[10 min], slide=[5 min])], select=[a, COUNT(*) AS cnt, COUNT(DISTINCT c) AS uv, start('w$) AS window_start, end('w$) AS window_end, proctime('w$) AS window_time])
+ +- Exchange(distribution=[hash[a]])
+ +- Calc(select=[a, c, proctime])
+ +- WatermarkAssigner(rowtime=[rowtime], watermark=[-(rowtime, 1000:INTERVAL SECOND)])
+ +- Calc(select=[a, b, c, rowtime, PROCTIME() AS proctime])
+ +- TableSourceScan(table=[[default_catalog, default_database, MyTable2]], fields=[a, b, c, rowtime])
+]]>
+ </Resource>
+ </TestCase>
+ <TestCase name="testOnTumbleWindowAggregate">
+ <Resource name="sql">
+ <![CDATA[
+SELECT L.*, R.*
+FROM (
+ SELECT
+ a,
+ window_start,
+ window_end,
+ window_time,
+ count(*) as cnt,
+ count(distinct c) AS uv
+ FROM TABLE(TUMBLE(TABLE MyTable, DESCRIPTOR(rowtime), INTERVAL '15' MINUTE))
+ GROUP BY a, window_start, window_end, window_time
+) L
+JOIN (
+ SELECT
+ a,
+ window_start,
+ window_end,
+ window_time,
+ count(*) as cnt,
+ count(distinct c) AS uv
+ FROM TABLE(TUMBLE(TABLE MyTable2, DESCRIPTOR(rowtime), INTERVAL '15' MINUTE))
+ GROUP BY a, window_start, window_end, window_time
+) R
+ON L.window_start = R.window_start AND L.window_end = R.window_end AND L.a = R.a
+ ]]>
+ </Resource>
+ <Resource name="ast">
+ <![CDATA[
+LogicalProject(a=[$0], window_start=[$1], window_end=[$2], window_time=[$3], cnt=[$4], uv=[$5], a0=[$6], window_start0=[$7], window_end0=[$8], window_time0=[$9], cnt0=[$10], uv0=[$11])
++- LogicalJoin(condition=[AND(=($1, $7), =($2, $8), =($0, $6))], joinType=[inner])
+ :- LogicalAggregate(group=[{0, 1, 2, 3}], cnt=[COUNT()], uv=[COUNT(DISTINCT $4)])
+ : +- LogicalProject(a=[$0], window_start=[$5], window_end=[$6], window_time=[$7], c=[$2])
+ : +- LogicalTableFunctionScan(invocation=[TUMBLE($4, DESCRIPTOR($3), 900000:INTERVAL MINUTE)], rowType=[RecordType(INTEGER a, VARCHAR(2147483647) b, BIGINT c, TIME ATTRIBUTE(ROWTIME) rowtime, TIME ATTRIBUTE(PROCTIME) proctime, TIMESTAMP(3) window_start, TIMESTAMP(3) window_end, TIME ATTRIBUTE(ROWTIME) window_time)])
+ : +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4])
+ : +- LogicalWatermarkAssigner(rowtime=[rowtime], watermark=[-($3, 1000:INTERVAL SECOND)])
+ : +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[PROCTIME()])
+ : +- LogicalTableScan(table=[[default_catalog, default_database, MyTable]])
+ +- LogicalAggregate(group=[{0, 1, 2, 3}], cnt=[COUNT()], uv=[COUNT(DISTINCT $4)])
+ +- LogicalProject(a=[$0], window_start=[$5], window_end=[$6], window_time=[$7], c=[$2])
+ +- LogicalTableFunctionScan(invocation=[TUMBLE($4, DESCRIPTOR($3), 900000:INTERVAL MINUTE)], rowType=[RecordType(INTEGER a, VARCHAR(2147483647) b, BIGINT c, TIME ATTRIBUTE(ROWTIME) rowtime, TIME ATTRIBUTE(PROCTIME) proctime, TIMESTAMP(3) window_start, TIMESTAMP(3) window_end, TIME ATTRIBUTE(ROWTIME) window_time)])
+ +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4])
+ +- LogicalWatermarkAssigner(rowtime=[rowtime], watermark=[-($3, 1000:INTERVAL SECOND)])
+ +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[PROCTIME()])
+ +- LogicalTableScan(table=[[default_catalog, default_database, MyTable2]])
+]]>
+ </Resource>
+ <Resource name="optimized rel plan">
+ <![CDATA[
+WindowJoin(leftWindow=[TUMBLE(win_start=[window_start], win_end=[window_end], size=[15 min])], rightWindow=[TUMBLE(win_start=[window_start], win_end=[window_end], size=[15 min])], joinType=[InnerJoin], where=[=(a, a0)], select=[a, window_start, window_end, window_time, cnt, uv, a0, window_start0, window_end0, window_time0, cnt0, uv0])
+:- Exchange(distribution=[hash[a]])
+: +- Calc(select=[a, window_start, window_end, window_time, cnt, uv])
+: +- WindowAggregate(groupBy=[a], window=[TUMBLE(time_col=[rowtime], size=[15 min])], select=[a, COUNT(*) AS cnt, COUNT(DISTINCT c) AS uv, start('w$) AS window_start, end('w$) AS window_end, rowtime('w$) AS window_time])
+: +- Exchange(distribution=[hash[a]])
+: +- Calc(select=[a, c, rowtime])
+: +- WatermarkAssigner(rowtime=[rowtime], watermark=[-(rowtime, 1000:INTERVAL SECOND)])
+: +- Calc(select=[a, b, c, rowtime, PROCTIME() AS proctime])
+: +- TableSourceScan(table=[[default_catalog, default_database, MyTable]], fields=[a, b, c, rowtime])
++- Exchange(distribution=[hash[a]])
+ +- Calc(select=[a, window_start, window_end, window_time, cnt, uv])
+ +- WindowAggregate(groupBy=[a], window=[TUMBLE(time_col=[rowtime], size=[15 min])], select=[a, COUNT(*) AS cnt, COUNT(DISTINCT c) AS uv, start('w$) AS window_start, end('w$) AS window_end, rowtime('w$) AS window_time])
+ +- Exchange(distribution=[hash[a]])
+ +- Calc(select=[a, c, rowtime])
+ +- WatermarkAssigner(rowtime=[rowtime], watermark=[-(rowtime, 1000:INTERVAL SECOND)])
+ +- Calc(select=[a, b, c, rowtime, PROCTIME() AS proctime])
+ +- TableSourceScan(table=[[default_catalog, default_database, MyTable2]], fields=[a, b, c, rowtime])
+]]>
+ </Resource>
+ </TestCase>
+ <TestCase name="testOnTumbleWindowAggregateOnProctime">
+ <Resource name="sql">
+ <![CDATA[
+SELECT L.*, R.*
+FROM (
+ SELECT
+ a,
+ window_start,
+ window_end,
+ window_time,
+ count(*) as cnt,
+ count(distinct c) AS uv
+ FROM TABLE(TUMBLE(TABLE MyTable, DESCRIPTOR(proctime), INTERVAL '15' MINUTE))
+ GROUP BY a, window_start, window_end, window_time
+) L
+JOIN (
+ SELECT
+ a,
+ window_start,
+ window_end,
+ window_time,
+ count(*) as cnt,
+ count(distinct c) AS uv
+ FROM TABLE(TUMBLE(TABLE MyTable2, DESCRIPTOR(proctime), INTERVAL '15' MINUTE))
+ GROUP BY a, window_start, window_end, window_time
+) R
+ON L.window_start = R.window_start AND L.window_end = R.window_end AND L.a = R.a
+ ]]>
+ </Resource>
+ <Resource name="ast">
+ <![CDATA[
+LogicalProject(a=[$0], window_start=[$1], window_end=[$2], window_time=[$3], cnt=[$4], uv=[$5], a0=[$6], window_start0=[$7], window_end0=[$8], window_time0=[$9], cnt0=[$10], uv0=[$11])
++- LogicalJoin(condition=[AND(=($1, $7), =($2, $8), =($0, $6))], joinType=[inner])
+ :- LogicalAggregate(group=[{0, 1, 2, 3}], cnt=[COUNT()], uv=[COUNT(DISTINCT $4)])
+ : +- LogicalProject(a=[$0], window_start=[$5], window_end=[$6], window_time=[$7], c=[$2])
+ : +- LogicalTableFunctionScan(invocation=[TUMBLE($4, DESCRIPTOR($4), 900000:INTERVAL MINUTE)], rowType=[RecordType(INTEGER a, VARCHAR(2147483647) b, BIGINT c, TIME ATTRIBUTE(ROWTIME) rowtime, TIME ATTRIBUTE(PROCTIME) proctime, TIMESTAMP(3) window_start, TIMESTAMP(3) window_end, TIME ATTRIBUTE(PROCTIME) window_time)])
+ : +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4])
+ : +- LogicalWatermarkAssigner(rowtime=[rowtime], watermark=[-($3, 1000:INTERVAL SECOND)])
+ : +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[PROCTIME()])
+ : +- LogicalTableScan(table=[[default_catalog, default_database, MyTable]])
+ +- LogicalAggregate(group=[{0, 1, 2, 3}], cnt=[COUNT()], uv=[COUNT(DISTINCT $4)])
+ +- LogicalProject(a=[$0], window_start=[$5], window_end=[$6], window_time=[$7], c=[$2])
+ +- LogicalTableFunctionScan(invocation=[TUMBLE($4, DESCRIPTOR($4), 900000:INTERVAL MINUTE)], rowType=[RecordType(INTEGER a, VARCHAR(2147483647) b, BIGINT c, TIME ATTRIBUTE(ROWTIME) rowtime, TIME ATTRIBUTE(PROCTIME) proctime, TIMESTAMP(3) window_start, TIMESTAMP(3) window_end, TIME ATTRIBUTE(PROCTIME) window_time)])
+ +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4])
+ +- LogicalWatermarkAssigner(rowtime=[rowtime], watermark=[-($3, 1000:INTERVAL SECOND)])
+ +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[PROCTIME()])
+ +- LogicalTableScan(table=[[default_catalog, default_database, MyTable2]])
+]]>
+ </Resource>
+ <Resource name="optimized rel plan">
+ <![CDATA[
+Calc(select=[a, window_start, window_end, PROCTIME_MATERIALIZE(window_time) AS window_time, cnt, uv, a0, window_start0, window_end0, PROCTIME_MATERIALIZE(window_time0) AS window_time0, cnt0, uv0])
++- WindowJoin(leftWindow=[TUMBLE(win_start=[window_start], win_end=[window_end], size=[15 min])], rightWindow=[TUMBLE(win_start=[window_start], win_end=[window_end], size=[15 min])], joinType=[InnerJoin], where=[=(a, a0)], select=[a, window_start, window_end, window_time, cnt, uv, a0, window_start0, window_end0, window_time0, cnt0, uv0])
+ :- Exchange(distribution=[hash[a]])
+ : +- Calc(select=[a, window_start, window_end, window_time, cnt, uv])
+ : +- WindowAggregate(groupBy=[a], window=[TUMBLE(time_col=[proctime], size=[15 min])], select=[a, COUNT(*) AS cnt, COUNT(DISTINCT c) AS uv, start('w$) AS window_start, end('w$) AS window_end, proctime('w$) AS window_time])
+ : +- Exchange(distribution=[hash[a]])
+ : +- Calc(select=[a, c, proctime])
+ : +- WatermarkAssigner(rowtime=[rowtime], watermark=[-(rowtime, 1000:INTERVAL SECOND)])
+ : +- Calc(select=[a, b, c, rowtime, PROCTIME() AS proctime])
+ : +- TableSourceScan(table=[[default_catalog, default_database, MyTable]], fields=[a, b, c, rowtime])
+ +- Exchange(distribution=[hash[a]])
+ +- Calc(select=[a, window_start, window_end, window_time, cnt, uv])
+ +- WindowAggregate(groupBy=[a], window=[TUMBLE(time_col=[proctime], size=[15 min])], select=[a, COUNT(*) AS cnt, COUNT(DISTINCT c) AS uv, start('w$) AS window_start, end('w$) AS window_end, proctime('w$) AS window_time])
+ +- Exchange(distribution=[hash[a]])
+ +- Calc(select=[a, c, proctime])
+ +- WatermarkAssigner(rowtime=[rowtime], watermark=[-(rowtime, 1000:INTERVAL SECOND)])
+ +- Calc(select=[a, b, c, rowtime, PROCTIME() AS proctime])
+ +- TableSourceScan(table=[[default_catalog, default_database, MyTable2]], fields=[a, b, c, rowtime])
+]]>
+ </Resource>
+ </TestCase>
+ <TestCase name="testTimeAttributePropagateForWindowJoin">
+ <Resource name="sql">
+ <![CDATA[
+SELECT tmp.*, MyTable3.* FROM tmp JOIN MyTable3 ON
+ tmp.a = MyTable3.a AND
+ tmp.rowtime BETWEEN
+ MyTable3.rowtime - INTERVAL '10' SECOND AND
+ MyTable3.rowtime + INTERVAL '1' HOUR
+]]>
+ </Resource>
+ <Resource name="ast">
+ <![CDATA[
+LogicalProject(rowtime=[$0], a=[$1], l_b=[$2], l_c=[$3], r_b=[$4], r_c=[$5], a0=[$6], b=[$7], c=[$8], rowtime0=[$9], proctime=[$10])
++- LogicalJoin(condition=[AND(=($1, $6), >=($0, -($9, 10000:INTERVAL SECOND)), <=($0, +($9, 3600000:INTERVAL HOUR)))], joinType=[inner])
+ :- LogicalProject(rowtime=[$7], a=[$0], l_b=[$1], l_c=[$2], r_b=[$9], r_c=[$10])
+ : +- LogicalJoin(condition=[AND(=($5, $13), =($6, $14), =($0, $8))], joinType=[inner])
+ : :- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4], window_start=[$5], window_end=[$6], window_time=[$7])
+ : : +- LogicalTableFunctionScan(invocation=[TUMBLE($4, DESCRIPTOR($3), 900000:INTERVAL MINUTE)], rowType=[RecordType(INTEGER a, VARCHAR(2147483647) b, BIGINT c, TIME ATTRIBUTE(ROWTIME) rowtime, TIME ATTRIBUTE(PROCTIME) proctime, TIMESTAMP(3) window_start, TIMESTAMP(3) window_end, TIME ATTRIBUTE(ROWTIME) window_time)])
+ : : +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4])
+ : : +- LogicalWatermarkAssigner(rowtime=[rowtime], watermark=[-($3, 1000:INTERVAL SECOND)])
+ : : +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[PROCTIME()])
+ : : +- LogicalTableScan(table=[[default_catalog, default_database, MyTable]])
+ : +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4], window_start=[$5], window_end=[$6], window_time=[$7])
+ : +- LogicalTableFunctionScan(invocation=[TUMBLE($4, DESCRIPTOR($3), 900000:INTERVAL MINUTE)], rowType=[RecordType(INTEGER a, VARCHAR(2147483647) b, BIGINT c, TIME ATTRIBUTE(ROWTIME) rowtime, TIME ATTRIBUTE(PROCTIME) proctime, TIMESTAMP(3) window_start, TIMESTAMP(3) window_end, TIME ATTRIBUTE(ROWTIME) window_time)])
+ : +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4])
+ : +- LogicalWatermarkAssigner(rowtime=[rowtime], watermark=[-($3, 1000:INTERVAL SECOND)])
+ : +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[PROCTIME()])
+ : +- LogicalTableScan(table=[[default_catalog, default_database, MyTable2]])
+ +- LogicalWatermarkAssigner(rowtime=[rowtime], watermark=[-($3, 1000:INTERVAL SECOND)])
+ +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[PROCTIME()])
+ +- LogicalTableScan(table=[[default_catalog, default_database, MyTable3]])
+]]>
+ </Resource>
+ <Resource name="optimized rel plan">
+ <![CDATA[
+Calc(select=[rowtime, a, l_b, l_c, r_b, r_c, a0, b, c, rowtime0, PROCTIME_MATERIALIZE(proctime) AS proctime])
++- IntervalJoin(joinType=[InnerJoin], windowBounds=[isRowTime=true, leftLowerBound=-10000, leftUpperBound=3600000, leftTimeIndex=0, rightTimeIndex=3], where=[AND(=(a, a0), >=(rowtime, -(rowtime0, 10000:INTERVAL SECOND)), <=(rowtime, +(rowtime0, 3600000:INTERVAL HOUR)))], select=[rowtime, a, l_b, l_c, r_b, r_c, a0, b, c, rowtime0, proctime])
+ :- Exchange(distribution=[hash[a]])
+ : +- Calc(select=[window_time AS rowtime, a, b AS l_b, c AS l_c, b0 AS r_b, c0 AS r_c])
+ : +- WindowJoin(leftWindow=[TUMBLE(win_start=[window_start], win_end=[window_end], size=[15 min])], rightWindow=[TUMBLE(win_start=[window_start], win_end=[window_end], size=[15 min])], joinType=[InnerJoin], where=[=(a, a0)], select=[a, b, c, window_start, window_end, window_time, a0, b0, c0, window_start0, window_end0])
+ : :- Exchange(distribution=[hash[a]])
+ : : +- Calc(select=[a, b, c, window_start, window_end, window_time])
+ : : +- WindowTableFunction(window=[TUMBLE(time_col=[rowtime], size=[15 min])])
+ : : +- WatermarkAssigner(rowtime=[rowtime], watermark=[-(rowtime, 1000:INTERVAL SECOND)])
+ : : +- Calc(select=[a, b, c, rowtime, PROCTIME() AS proctime])
+ : : +- TableSourceScan(table=[[default_catalog, default_database, MyTable]], fields=[a, b, c, rowtime])
+ : +- Exchange(distribution=[hash[a]])
+ : +- Calc(select=[a, b, c, window_start, window_end])
+ : +- WindowTableFunction(window=[TUMBLE(time_col=[rowtime], size=[15 min])])
+ : +- WatermarkAssigner(rowtime=[rowtime], watermark=[-(rowtime, 1000:INTERVAL SECOND)])
+ : +- Calc(select=[a, b, c, rowtime, PROCTIME() AS proctime])
+ : +- TableSourceScan(table=[[default_catalog, default_database, MyTable2]], fields=[a, b, c, rowtime])
+ +- Exchange(distribution=[hash[a]])
+ +- WatermarkAssigner(rowtime=[rowtime], watermark=[-(rowtime, 1000:INTERVAL SECOND)])
+ +- Calc(select=[a, b, c, rowtime, PROCTIME() AS proctime])
+ +- TableSourceScan(table=[[default_catalog, default_database, MyTable3]], fields=[a, b, c, rowtime])
+]]>
+ </Resource>
+ </TestCase>
+ <TestCase name="testWindowJoinWithNonEqui">
+ <Resource name="sql">
+ <![CDATA[
+SELECT L.*, R.*
+FROM (
+ SELECT
+ a,
+ window_start,
+ window_end,
+ window_time,
+ count(*) as cnt,
+ count(distinct c) AS uv
+ FROM TABLE(
+ CUMULATE(
+ TABLE MyTable, DESCRIPTOR(proctime), INTERVAL '10' MINUTE, INTERVAL '1' HOUR))
+ GROUP BY a, window_start, window_end, window_time
+) L
+JOIN (
+ SELECT
+ a,
+ window_start,
+ window_end,
+ window_time,
+ count(*) as cnt,
+ count(distinct c) AS uv
+ FROM TABLE(
+ CUMULATE(
+ TABLE MyTable2, DESCRIPTOR(proctime), INTERVAL '10' MINUTE, INTERVAL '1' HOUR))
+ GROUP BY a, window_start, window_end, window_time
+) R
+ON L.window_start = R.window_start AND L.window_end = R.window_end AND L.a = R.a AND
+ CAST(L.window_start AS BIGINT) > R.uv
+ ]]>
+ </Resource>
+ <Resource name="ast">
+ <![CDATA[
+LogicalProject(a=[$0], window_start=[$1], window_end=[$2], window_time=[$3], cnt=[$4], uv=[$5], a0=[$6], window_start0=[$7], window_end0=[$8], window_time0=[$9], cnt0=[$10], uv0=[$11])
++- LogicalJoin(condition=[AND(=($1, $7), =($2, $8), =($0, $6), >(CAST($1):BIGINT NOT NULL, $11))], joinType=[inner])
+ :- LogicalAggregate(group=[{0, 1, 2, 3}], cnt=[COUNT()], uv=[COUNT(DISTINCT $4)])
+ : +- LogicalProject(a=[$0], window_start=[$5], window_end=[$6], window_time=[$7], c=[$2])
+ : +- LogicalTableFunctionScan(invocation=[CUMULATE($4, DESCRIPTOR($4), 600000:INTERVAL MINUTE, 3600000:INTERVAL HOUR)], rowType=[RecordType(INTEGER a, VARCHAR(2147483647) b, BIGINT c, TIME ATTRIBUTE(ROWTIME) rowtime, TIME ATTRIBUTE(PROCTIME) proctime, TIMESTAMP(3) window_start, TIMESTAMP(3) window_end, TIME ATTRIBUTE(PROCTIME) window_time)])
+ : +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4])
+ : +- LogicalWatermarkAssigner(rowtime=[rowtime], watermark=[-($3, 1000:INTERVAL SECOND)])
+ : +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[PROCTIME()])
+ : +- LogicalTableScan(table=[[default_catalog, default_database, MyTable]])
+ +- LogicalAggregate(group=[{0, 1, 2, 3}], cnt=[COUNT()], uv=[COUNT(DISTINCT $4)])
+ +- LogicalProject(a=[$0], window_start=[$5], window_end=[$6], window_time=[$7], c=[$2])
+ +- LogicalTableFunctionScan(invocation=[CUMULATE($4, DESCRIPTOR($4), 600000:INTERVAL MINUTE, 3600000:INTERVAL HOUR)], rowType=[RecordType(INTEGER a, VARCHAR(2147483647) b, BIGINT c, TIME ATTRIBUTE(ROWTIME) rowtime, TIME ATTRIBUTE(PROCTIME) proctime, TIMESTAMP(3) window_start, TIMESTAMP(3) window_end, TIME ATTRIBUTE(PROCTIME) window_time)])
+ +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4])
+ +- LogicalWatermarkAssigner(rowtime=[rowtime], watermark=[-($3, 1000:INTERVAL SECOND)])
+ +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[PROCTIME()])
+ +- LogicalTableScan(table=[[default_catalog, default_database, MyTable2]])
+]]>
+ </Resource>
+ <Resource name="optimized rel plan">
+ <![CDATA[
+Calc(select=[a, window_start, window_end, PROCTIME_MATERIALIZE(window_time) AS window_time, cnt, uv, a0, window_start0, window_end0, PROCTIME_MATERIALIZE(window_time0) AS window_time0, cnt0, uv0])
++- WindowJoin(leftWindow=[CUMULATE(win_start=[window_start], win_end=[window_end], max_size=[1 h], step=[10 min])], rightWindow=[CUMULATE(win_start=[window_start], win_end=[window_end], max_size=[1 h], step=[10 min])], joinType=[InnerJoin], where=[AND(=(a, a0), >(CAST(window_start), uv0))], select=[a, window_start, window_end, window_time, cnt, uv, a0, window_start0, window_end0, window_time0, cnt0, uv0])
+ :- Exchange(distribution=[hash[a]])
+ : +- Calc(select=[a, window_start, window_end, window_time, cnt, uv])
+ : +- WindowAggregate(groupBy=[a], window=[CUMULATE(time_col=[proctime], max_size=[1 h], step=[10 min])], select=[a, COUNT(*) AS cnt, COUNT(DISTINCT c) AS uv, start('w$) AS window_start, end('w$) AS window_end, proctime('w$) AS window_time])
+ : +- Exchange(distribution=[hash[a]])
+ : +- Calc(select=[a, c, proctime])
+ : +- WatermarkAssigner(rowtime=[rowtime], watermark=[-(rowtime, 1000:INTERVAL SECOND)])
+ : +- Calc(select=[a, b, c, rowtime, PROCTIME() AS proctime])
+ : +- TableSourceScan(table=[[default_catalog, default_database, MyTable]], fields=[a, b, c, rowtime])
+ +- Exchange(distribution=[hash[a]])
+ +- Calc(select=[a, window_start, window_end, window_time, cnt, uv])
+ +- WindowAggregate(groupBy=[a], window=[CUMULATE(time_col=[proctime], max_size=[1 h], step=[10 min])], select=[a, COUNT(*) AS cnt, COUNT(DISTINCT c) AS uv, start('w$) AS window_start, end('w$) AS window_end, proctime('w$) AS window_time])
+ +- Exchange(distribution=[hash[a]])
+ +- Calc(select=[a, c, proctime])
+ +- WatermarkAssigner(rowtime=[rowtime], watermark=[-(rowtime, 1000:INTERVAL SECOND)])
+ +- Calc(select=[a, b, c, rowtime, PROCTIME() AS proctime])
+ +- TableSourceScan(table=[[default_catalog, default_database, MyTable2]], fields=[a, b, c, rowtime])
+]]>
+ </Resource>
+ </TestCase>
+ <TestCase name="testWindowPropertyPropagateForWindowJoin">
+ <Resource name="sql">
+ <![CDATA[
+SELECT * FROM
+(
+ SELECT *,
+ ROW_NUMBER() OVER(
+ PARTITION BY window_start, window_end ORDER BY l_cnt DESC) as rownum
+ FROM tmp2
+)
+WHERE rownum <= 3
+ ]]>
+ </Resource>
+ <Resource name="ast">
+ <![CDATA[
+LogicalProject(window_start=[$0], window_end=[$1], a=[$2], l_cnt=[$3], l_uv=[$4], r_cnt=[$5], r_uv=[$6], rownum=[$7])
++- LogicalFilter(condition=[<=($7, 3)])
+ +- LogicalProject(window_start=[$1], window_end=[$2], a=[$0], l_cnt=[$4], l_uv=[$5], r_cnt=[$10], r_uv=[$11], rownum=[ROW_NUMBER() OVER (PARTITION BY $1, $2 ORDER BY $4 DESC NULLS LAST)])
+ +- LogicalJoin(condition=[AND(=($1, $7), =($2, $8), =($0, $6))], joinType=[inner])
+ :- LogicalAggregate(group=[{0, 1, 2, 3}], cnt=[COUNT()], uv=[COUNT(DISTINCT $4)])
+ : +- LogicalProject(a=[$0], window_start=[$5], window_end=[$6], window_time=[$7], c=[$2])
+ : +- LogicalTableFunctionScan(invocation=[CUMULATE($4, DESCRIPTOR($3), 600000:INTERVAL MINUTE, 3600000:INTERVAL HOUR)], rowType=[RecordType(INTEGER a, VARCHAR(2147483647) b, BIGINT c, TIME ATTRIBUTE(ROWTIME) rowtime, TIME ATTRIBUTE(PROCTIME) proctime, TIMESTAMP(3) window_start, TIMESTAMP(3) window_end, TIME ATTRIBUTE(ROWTIME) window_time)])
+ : +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4])
+ : +- LogicalWatermarkAssigner(rowtime=[rowtime], watermark=[-($3, 1000:INTERVAL SECOND)])
+ : +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[PROCTIME()])
+ : +- LogicalTableScan(table=[[default_catalog, default_database, MyTable]])
+ +- LogicalAggregate(group=[{0, 1, 2, 3}], cnt=[COUNT()], uv=[COUNT(DISTINCT $4)])
+ +- LogicalProject(a=[$0], window_start=[$5], window_end=[$6], window_time=[$7], c=[$2])
+ +- LogicalTableFunctionScan(invocation=[CUMULATE($4, DESCRIPTOR($3), 600000:INTERVAL MINUTE, 3600000:INTERVAL HOUR)], rowType=[RecordType(INTEGER a, VARCHAR(2147483647) b, BIGINT c, TIME ATTRIBUTE(ROWTIME) rowtime, TIME ATTRIBUTE(PROCTIME) proctime, TIMESTAMP(3) window_start, TIMESTAMP(3) window_end, TIME ATTRIBUTE(ROWTIME) window_time)])
+ +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4])
+ +- LogicalWatermarkAssigner(rowtime=[rowtime], watermark=[-($3, 1000:INTERVAL SECOND)])
+ +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[PROCTIME()])
+ +- LogicalTableScan(table=[[default_catalog, default_database, MyTable2]])
+]]>
+ </Resource>
+ <Resource name="optimized rel plan">
+ <![CDATA[
+Calc(select=[window_start, window_end, a, cnt AS l_cnt, uv AS l_uv, cnt0 AS r_cnt, uv0 AS r_uv, rownum])
++- Rank(strategy=[AppendFastStrategy], rankType=[ROW_NUMBER], rankRange=[rankStart=1, rankEnd=3], partitionBy=[window_start, window_end], orderBy=[cnt DESC], select=[a, window_start, window_end, window_time, cnt, uv, a0, window_start0, window_end0, window_time0, cnt0, uv0, rownum])
Review comment:
Does it mean window properties are not propagated? Because here is `Rank` instead of `WindowRank`.
##########
File path: flink-table/flink-table-planner-blink/src/test/scala/org/apache/flink/table/planner/plan/stream/sql/join/WindowJoinTest.scala
##########
@@ -0,0 +1,922 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.planner.plan.stream.sql.join
+
+import org.apache.flink.table.api._
+import org.apache.flink.table.planner.utils.{StreamTableTestUtil, TableTestBase}
+
+import org.junit.Test
+
+/**
+ * Tests for window join.
+ */
+class WindowJoinTest extends TableTestBase {
+
+ private val util: StreamTableTestUtil = streamTestUtil()
+ util.tableEnv.executeSql(
+ s"""
+ |CREATE TABLE MyTable (
+ | a INT,
+ | b STRING NOT NULL,
+ | c BIGINT,
+ | rowtime TIMESTAMP(3),
+ | proctime as PROCTIME(),
+ | WATERMARK FOR rowtime AS rowtime - INTERVAL '1' SECOND
+ |) with (
+ | 'connector' = 'values'
+ |)
+ |""".stripMargin)
+
+ util.tableEnv.executeSql(
+ s"""
+ |CREATE TABLE MyTable2 (
+ | a INT,
+ | b STRING NOT NULL,
+ | c BIGINT,
+ | rowtime TIMESTAMP(3),
+ | proctime as PROCTIME(),
+ | WATERMARK FOR rowtime AS rowtime - INTERVAL '1' SECOND
+ |) with (
+ | 'connector' = 'values'
+ |)
+ |""".stripMargin)
+
+ // ----------------------------------------------------------------------------------------
+ // Tests for queries Join on window TVF
+ // Current does not support merge Window TVF into WindowJoin.
+ // ----------------------------------------------------------------------------------------
+
+ @Test
+ def testCantMergeWindowTVF_Tumble(): Unit = {
+ val sql =
+ """
+ |SELECT L.a, L.b, L.c, R.a, R.b, R.c
+ |FROM (
+ | SELECT *
+ | FROM TABLE(TUMBLE(TABLE MyTable, DESCRIPTOR(rowtime), INTERVAL '15' MINUTE))
+ |) L
+ |JOIN (
+ | SELECT *
+ | FROM TABLE(TUMBLE(TABLE MyTable2, DESCRIPTOR(rowtime), INTERVAL '15' MINUTE))
+ |) R
+ |ON L.window_start = R.window_start AND L.window_end = R.window_end AND L.a = R.a
+ """.stripMargin
+ util.verifyRelPlan(sql)
+ }
+
+ @Test
+ def testCantMergeWindowTVF_TumbleOnProctime(): Unit = {
+ val sql =
+ """
+ |SELECT L.a, L.b, L.c, R.a, R.b, R.c
+ |FROM (
+ | SELECT *
+ | FROM TABLE(TUMBLE(TABLE MyTable, DESCRIPTOR(proctime), INTERVAL '15' MINUTE))
+ |) L
+ |JOIN (
+ | SELECT *
+ | FROM TABLE(TUMBLE(TABLE MyTable2, DESCRIPTOR(proctime), INTERVAL '15' MINUTE))
+ |) R
+ |ON L.window_start = R.window_start AND L.window_end = R.window_end AND L.a = R.a
+ """.stripMargin
+ util.verifyRelPlan(sql)
+ }
+
+ @Test
+ def testCantMergeWindowTVF_Hop(): Unit = {
+ val sql =
+ """
+ |SELECT L.a, L.b, L.c, R.a, R.b, R.c
+ |FROM (
+ | SELECT *
+ | FROM TABLE(
+ | HOP(TABLE MyTable, DESCRIPTOR(rowtime), INTERVAL '5' MINUTE, INTERVAL '10' MINUTE))
+ |) L
+ |JOIN (
+ | SELECT *
+ | FROM TABLE(
+ | HOP(TABLE MyTable2, DESCRIPTOR(rowtime), INTERVAL '5' MINUTE, INTERVAL '10' MINUTE))
+ |) R
+ |ON L.window_start = R.window_start AND L.window_end = R.window_end AND L.a = R.a
+ """.stripMargin
+ util.verifyRelPlan(sql)
+ }
+
+ @Test
+ def testCantMergeWindowTVF_HopOnProctime(): Unit = {
+ val sql =
+ """
+ |SELECT L.a, L.b, L.c, R.a, R.b, R.c
+ |FROM (
+ | SELECT *
+ | FROM TABLE(
+ | HOP(TABLE MyTable, DESCRIPTOR(proctime), INTERVAL '5' MINUTE, INTERVAL '10' MINUTE))
+ |) L
+ |JOIN (
+ | SELECT *
+ | FROM TABLE(
+ | HOP(TABLE MyTable2, DESCRIPTOR(proctime), INTERVAL '5' MINUTE, INTERVAL '10' MINUTE))
+ |) R
+ |ON L.window_start = R.window_start AND L.window_end = R.window_end AND L.a = R.a
+ """.stripMargin
+ util.verifyRelPlan(sql)
+ }
+
+ @Test
+ def testCantMergeWindowTVF_Cumulate(): Unit = {
+ val sql =
+ """
+ |SELECT L.a, L.b, L.c, R.a, R.b, R.c
+ |FROM (
+ | SELECT *
+ | FROM TABLE(
+ | CUMULATE(TABLE MyTable, DESCRIPTOR(rowtime), INTERVAL '10' MINUTE, INTERVAL '1' HOUR))
+ |) L
+ |JOIN (
+ | SELECT *
+ | FROM TABLE(
+ | CUMULATE(TABLE MyTable2, DESCRIPTOR(rowtime), INTERVAL '10' MINUTE, INTERVAL '1' HOUR))
+ |) R
+ |ON L.window_start = R.window_start AND L.window_end = R.window_end AND L.a = R.a
+ """.stripMargin
+ util.verifyRelPlan(sql)
+ }
+
+ @Test
+ def testCantMergeWindowTVF_CumulateOnProctime(): Unit = {
+ val sql =
+ """
+ |SELECT L.a, L.b, L.c, R.a, R.b, R.c
+ |FROM (
+ | SELECT *
+ | FROM TABLE(
+ | CUMULATE(TABLE MyTable, DESCRIPTOR(proctime), INTERVAL '10' MINUTE, INTERVAL '1' HOUR))
+ |) L
+ |JOIN (
+ | SELECT *
+ | FROM TABLE(
+ | CUMULATE(TABLE MyTable2, DESCRIPTOR(proctime), INTERVAL '10' MINUTE, INTERVAL '1' HOUR))
+ |) R
+ |ON L.window_start = R.window_start AND L.window_end = R.window_end AND L.a = R.a
+ """.stripMargin
+ util.verifyRelPlan(sql)
+ }
+
+ // ----------------------------------------------------------------------------------------
+ // Tests for invalid queries Join on window Aggregate
+ // because left window strategy is not equals to right window strategy.
+ // ----------------------------------------------------------------------------------------
+
+ /** Window type in left and right child should be same **/
+ @Test(expected = classOf[TableException])
Review comment:
Use `thrown.expect(...)` and `thrown.expectMessage(..)` to assert exception and error message.
##########
File path: flink-table/flink-table-planner-blink/src/main/scala/org/apache/flink/table/planner/plan/nodes/physical/stream/StreamPhysicalWindowJoin.scala
##########
@@ -0,0 +1,91 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.flink.table.planner.plan.nodes.physical.stream
+
+import org.apache.flink.table.api.TableException
+import org.apache.flink.table.planner.plan.logical.WindowingStrategy
+import org.apache.flink.table.planner.plan.nodes.exec.ExecNode
+import org.apache.flink.table.planner.plan.nodes.physical.common.CommonPhysicalJoin
+import org.apache.flink.table.planner.plan.utils.PythonUtil.containsPythonCall
+import org.apache.flink.table.planner.plan.utils.RelExplainUtil.preferExpressionFormat
+
+import org.apache.calcite.plan.{RelOptCluster, RelTraitSet}
+import org.apache.calcite.rel._
+import org.apache.calcite.rel.core.{Join, JoinRelType}
+import org.apache.calcite.rex.RexNode
+
+import scala.collection.JavaConversions._
+import scala.collection.JavaConverters._
+
+/**
+ * The window join requires the join condition contains window starts equality of
+ * input tables and window ends equality of input tables.
+ * The semantic of window join is the same to the DataStream window join.
+ */
+class StreamPhysicalWindowJoin(
+ cluster: RelOptCluster,
+ traitSet: RelTraitSet,
+ leftRel: RelNode,
+ rightRel: RelNode,
+ joinType: JoinRelType,
+ // remaining join condition contains all of join condition except window starts equality
+ // and window end equality
+ remainingCondition: RexNode,
+ val leftWindowing: WindowingStrategy,
+ val rightWindowing: WindowingStrategy)
Review comment:
It seems that we do not allow different window strategy for left and right input. I think we can simplify the design to only have a single window strategy. We can evolve it in the future.
----------------------------------------------------------------
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:
users@infra.apache.org
[GitHub] [flink] flinkbot edited a comment on pull request #15195: [FLINK-19609][table-planner-blink] Support streaming window join in planner
Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #15195:
URL: https://github.com/apache/flink/pull/15195#issuecomment-798871942
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "8f844ec2c7ace18f8d6a78efbabea949dd7b9a8c",
"status" : "DELETED",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14614",
"triggerID" : "8f844ec2c7ace18f8d6a78efbabea949dd7b9a8c",
"triggerType" : "PUSH"
}, {
"hash" : "c7a1c712fc6f803918ab49a8e07994e1bc590652",
"status" : "DELETED",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14663",
"triggerID" : "c7a1c712fc6f803918ab49a8e07994e1bc590652",
"triggerType" : "PUSH"
}, {
"hash" : "162ca63148a9c1c924936bc17743f830082d800e",
"status" : "DELETED",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14668",
"triggerID" : "162ca63148a9c1c924936bc17743f830082d800e",
"triggerType" : "PUSH"
}, {
"hash" : "0a79f7d2655ee39ce1bb193bde327b1121b80ff4",
"status" : "DELETED",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14683",
"triggerID" : "0a79f7d2655ee39ce1bb193bde327b1121b80ff4",
"triggerType" : "PUSH"
}, {
"hash" : "7de577188142578d0ed819e2623aedbcb1baccc5",
"status" : "DELETED",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14689",
"triggerID" : "7de577188142578d0ed819e2623aedbcb1baccc5",
"triggerType" : "PUSH"
}, {
"hash" : "44281b2314b6c5bf6b2cfc3387164b9aa7efcc74",
"status" : "SUCCESS",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14706",
"triggerID" : "44281b2314b6c5bf6b2cfc3387164b9aa7efcc74",
"triggerType" : "PUSH"
}, {
"hash" : "693860368d8c271691f65cdd37644d99df7786a5",
"status" : "PENDING",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14861",
"triggerID" : "693860368d8c271691f65cdd37644d99df7786a5",
"triggerType" : "PUSH"
}, {
"hash" : "47ef3ba16e9a53261be1fd78014d1cab14bc0cf7",
"status" : "UNKNOWN",
"url" : "TBD",
"triggerID" : "47ef3ba16e9a53261be1fd78014d1cab14bc0cf7",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* 44281b2314b6c5bf6b2cfc3387164b9aa7efcc74 Azure: [SUCCESS](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14706)
* 693860368d8c271691f65cdd37644d99df7786a5 Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14861)
* 47ef3ba16e9a53261be1fd78014d1cab14bc0cf7 UNKNOWN
<details>
<summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot run travis` re-run the last Travis build
- `@flinkbot run azure` re-run the last Azure build
</details>
----------------------------------------------------------------
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:
users@infra.apache.org
[GitHub] [flink] wuchong commented on a change in pull request #15195: [FLINK-19609][table-planner-blink] Support streaming window join in planner
Posted by GitBox <gi...@apache.org>.
wuchong commented on a change in pull request #15195:
URL: https://github.com/apache/flink/pull/15195#discussion_r594020069
##########
File path: flink-table/flink-table-planner-blink/src/test/resources/org/apache/flink/table/planner/plan/stream/sql/join/WindowJoinTest.xml
##########
@@ -0,0 +1,1041 @@
+<?xml version="1.0" ?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to you under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+-->
+<Root>
+ <TestCase name="testCantMergeWindowTVF_Cumulate">
+ <Resource name="sql">
+ <![CDATA[
+SELECT L.a, L.b, L.c, R.a, R.b, R.c
+FROM (
+ SELECT *
+ FROM TABLE(
+ CUMULATE(TABLE MyTable, DESCRIPTOR(rowtime), INTERVAL '10' MINUTE, INTERVAL '1' HOUR))
+) L
+JOIN (
+ SELECT *
+ FROM TABLE(
+ CUMULATE(TABLE MyTable2, DESCRIPTOR(rowtime), INTERVAL '10' MINUTE, INTERVAL '1' HOUR))
+) R
+ON L.window_start = R.window_start AND L.window_end = R.window_end AND L.a = R.a
+ ]]>
+ </Resource>
+ <Resource name="ast">
+ <![CDATA[
+LogicalProject(a=[$0], b=[$1], c=[$2], a0=[$8], b0=[$9], c0=[$10])
++- LogicalJoin(condition=[AND(=($5, $13), =($6, $14), =($0, $8))], joinType=[inner])
+ :- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4], window_start=[$5], window_end=[$6], window_time=[$7])
+ : +- LogicalTableFunctionScan(invocation=[CUMULATE($4, DESCRIPTOR($3), 600000:INTERVAL MINUTE, 3600000:INTERVAL HOUR)], rowType=[RecordType(INTEGER a, VARCHAR(2147483647) b, BIGINT c, TIME ATTRIBUTE(ROWTIME) rowtime, TIME ATTRIBUTE(PROCTIME) proctime, TIMESTAMP(3) window_start, TIMESTAMP(3) window_end, TIME ATTRIBUTE(ROWTIME) window_time)])
+ : +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4])
+ : +- LogicalWatermarkAssigner(rowtime=[rowtime], watermark=[-($3, 1000:INTERVAL SECOND)])
+ : +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[PROCTIME()])
+ : +- LogicalTableScan(table=[[default_catalog, default_database, MyTable]])
+ +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4], window_start=[$5], window_end=[$6], window_time=[$7])
+ +- LogicalTableFunctionScan(invocation=[CUMULATE($4, DESCRIPTOR($3), 600000:INTERVAL MINUTE, 3600000:INTERVAL HOUR)], rowType=[RecordType(INTEGER a, VARCHAR(2147483647) b, BIGINT c, TIME ATTRIBUTE(ROWTIME) rowtime, TIME ATTRIBUTE(PROCTIME) proctime, TIMESTAMP(3) window_start, TIMESTAMP(3) window_end, TIME ATTRIBUTE(ROWTIME) window_time)])
+ +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4])
+ +- LogicalWatermarkAssigner(rowtime=[rowtime], watermark=[-($3, 1000:INTERVAL SECOND)])
+ +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[PROCTIME()])
+ +- LogicalTableScan(table=[[default_catalog, default_database, MyTable2]])
+]]>
+ </Resource>
+ <Resource name="optimized rel plan">
+ <![CDATA[
+Calc(select=[a, b, c, a0, b0, c0])
++- WindowJoin(leftWindow=[CUMULATE(win_start=[window_start], win_end=[window_end], max_size=[1 h], step=[10 min])], rightWindow=[CUMULATE(win_start=[window_start], win_end=[window_end], max_size=[1 h], step=[10 min])], joinType=[InnerJoin], where=[=(a, a0)], select=[a, b, c, window_start, window_end, a0, b0, c0, window_start0, window_end0])
Review comment:
Throwing in planner or when translating to exec node are both fine. But this can be done in the next PR.
----------------------------------------------------------------
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:
users@infra.apache.org
[GitHub] [flink] wuchong commented on a change in pull request #15195: [FLINK-19609][table-planner-blink] Support streaming window join in planner
Posted by GitBox <gi...@apache.org>.
wuchong commented on a change in pull request #15195:
URL: https://github.com/apache/flink/pull/15195#discussion_r594021595
##########
File path: flink-table/flink-table-planner-blink/src/main/scala/org/apache/flink/table/planner/plan/utils/WindowJoinUtil.scala
##########
@@ -0,0 +1,219 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.planner.plan.utils
+
+import org.apache.flink.table.api.TableException
+import org.apache.flink.table.planner.plan.metadata.FlinkRelMetadataQuery
+import org.apache.flink.table.planner.plan.nodes.logical.FlinkLogicalJoin
+import org.apache.flink.table.planner.plan.`trait`.RelWindowProperties
+
+import org.apache.calcite.rex.{RexInputRef, RexNode, RexUtil}
+import org.apache.calcite.sql.fun.SqlStdOperatorTable
+import org.apache.calcite.util.ImmutableIntList
+
+import scala.collection.JavaConversions._
+import scala.collection.mutable
+
+/**
+ * Util for window join.
+ */
+object WindowJoinUtil {
+
+ /**
+ * Get window properties of left and right child.
+ *
+ * @param join input join
+ * @return window properties of left and right child.
+ */
+ def getChildWindowProperties(
+ join: FlinkLogicalJoin): (RelWindowProperties, RelWindowProperties) = {
+ val fmq = FlinkRelMetadataQuery.reuseOrCreate(join.getCluster.getMetadataQuery)
+ (fmq.getRelWindowProperties(join.getLeft), fmq.getRelWindowProperties(join.getRight))
+ }
+
+ /**
+ * Checks whether join condition contains window starts equality of input tables or window
+ * ends equality of input tables.
+ *
+ * @param join input join
+ * @return True if join condition contains window starts equality of input tables and window
+ * ends equality of input tables. Else false.
+ */
+ def containsWindowStartEqualityOrEndEquality(join: FlinkLogicalJoin): Boolean = {
+ val (windowStartEqualityLeftKeys, windowEndEqualityLeftKeys, _, _) =
+ excludeWindowStartEqualityAndEndEqualityFromJoinInfoPairs(join)
+ windowStartEqualityLeftKeys.nonEmpty || windowEndEqualityLeftKeys.nonEmpty
+ }
+
+ /**
+ * Excludes window starts equality and window ends equality from join info.
+ *
+ * @param join input join
+ * @return Remain join information after excludes window starts equality and window ends
+ * equality from join.
+ * The first element is left join keys of window starts equality,
+ * the second element is left join keys of window ends equality,
+ * the third element is right join keys of window starts equality,
+ * the forth element is right join keys of window ends equality,
+ * the fifth element is remain left join keys,
+ * the sixth element is remain right join keys,
+ * the last element is remain join condition which includes remain equal condition and
+ * non-equal condition.
+ */
+ def excludeWindowStartEqualityAndEndEqualityFromJoinCondition(
+ join: FlinkLogicalJoin): (
+ ImmutableIntList,
+ ImmutableIntList,
+ ImmutableIntList,
+ ImmutableIntList,
+ ImmutableIntList,
+ ImmutableIntList,
+ RexNode) = {
+ val (
+ windowStartEqualityLeftKeys,
+ windowEndEqualityLeftKeys,
+ windowStartEqualityRightKeys,
+ windowEndEqualityRightKeys) =
+ excludeWindowStartEqualityAndEndEqualityFromJoinInfoPairs(join)
+
+ val joinInfo = join.analyzeCondition()
+ val (remainLeftKeys, remainRightKeys, remainCondition) = if (
+ windowStartEqualityLeftKeys.nonEmpty || windowEndEqualityLeftKeys.nonEmpty) {
+ val joinFieldsType = join.getRowType.getFieldList
+ val leftFieldCnt = join.getLeft.getRowType.getFieldCount
+ val rexBuilder = join.getCluster.getRexBuilder
+ val remainEquals = mutable.ArrayBuffer[RexNode]()
+ val remainLeftKeysArray = mutable.ArrayBuffer[Int]()
+ val remainRightKeysArray = mutable.ArrayBuffer[Int]()
+ // convert remain pairs to RexInputRef tuple for building SqlStdOperatorTable.EQUALS calls
+ joinInfo.pairs().foreach { p =>
+ if (!windowStartEqualityLeftKeys.contains(p.source) &&
+ !windowEndEqualityLeftKeys.contains(p.source)) {
+ val leftFieldType = joinFieldsType.get(p.source).getType
+ val leftInputRef = new RexInputRef(p.source, leftFieldType)
+ val rightIndex = leftFieldCnt + p.target
+ val rightFieldType = joinFieldsType.get(rightIndex).getType
+ val rightInputRef = new RexInputRef(rightIndex, rightFieldType)
+ val remainEqual = rexBuilder.makeCall(
+ SqlStdOperatorTable.EQUALS,
Review comment:
Why not put the join key equality (exclude window start & end) into join key paires? I mean construct a new `JoinInfo` instead of a `RexNode`.
----------------------------------------------------------------
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:
users@infra.apache.org
[GitHub] [flink] wuchong commented on a change in pull request #15195: [FLINK-19609][table-planner-blink] Support streaming window join in planner
Posted by GitBox <gi...@apache.org>.
wuchong commented on a change in pull request #15195:
URL: https://github.com/apache/flink/pull/15195#discussion_r595727043
##########
File path: flink-table/flink-table-planner-blink/src/main/scala/org/apache/flink/table/planner/plan/utils/WindowJoinUtil.scala
##########
@@ -182,26 +183,65 @@ object WindowJoinUtil {
}
// Validate join
+ def getLeftFieldNames() = join.getLeft.getRowType.getFieldNames.toList
+
+ def getRightFieldNames() = join.getRight.getRowType.getFieldNames.toList
+
if (windowStartEqualityLeftKeys.nonEmpty && windowEndEqualityLeftKeys.nonEmpty) {
if (
leftWindowProperties.getTimeAttributeType != rightWindowProperties.getTimeAttributeType) {
+
+ def timeAttributeTypeStr(isRowTime: Boolean): String = {
+ if (isRowTime) "ROWTIME" else "PROCTIME"
Review comment:
We can just print the logical type, because we will support TIMESTAMP_LTZ as time attribute soon, so the logical type maybe different.
##########
File path: flink-table/flink-table-planner-blink/src/main/scala/org/apache/flink/table/planner/plan/utils/WindowJoinUtil.scala
##########
@@ -182,26 +183,65 @@ object WindowJoinUtil {
}
// Validate join
+ def getLeftFieldNames() = join.getLeft.getRowType.getFieldNames.toList
+
+ def getRightFieldNames() = join.getRight.getRowType.getFieldNames.toList
+
if (windowStartEqualityLeftKeys.nonEmpty && windowEndEqualityLeftKeys.nonEmpty) {
if (
leftWindowProperties.getTimeAttributeType != rightWindowProperties.getTimeAttributeType) {
+
+ def timeAttributeTypeStr(isRowTime: Boolean): String = {
+ if (isRowTime) "ROWTIME" else "PROCTIME"
+ }
+
throw new TableException(
"Currently, window join doesn't support different time attribute type of left and " +
"right inputs.\n" +
- s"The left time attribute type is ${leftWindowProperties.getTimeAttributeType}.\n" +
- s"The right time attribute type is ${rightWindowProperties.getTimeAttributeType}.")
+ s"The left time attribute type is " +
+ s"${timeAttributeTypeStr(leftWindowProperties.isRowtime)}.\n" +
+ s"The right time attribute type is " +
+ s"${timeAttributeTypeStr(rightWindowProperties.isRowtime)}.")
} else if (leftWindowProperties.getWindowSpec != rightWindowProperties.getWindowSpec) {
+
+ def windowSpecToStr(
+ inputFieldNames: Seq[String],
+ windowStartIdx: Int,
+ windowEndIdx: Int,
+ windowSpec: WindowSpec): String = {
+ val windowing = s"win_start=[${inputFieldNames(windowStartIdx)}]" +
+ s", win_end=[${inputFieldNames(windowEndIdx)}]"
+ windowSpec.toSummaryString(windowing)
Review comment:
WindowSpec doesn't contain window_start and window_end column information, so I think we don't need to print them.
##########
File path: flink-table/flink-table-planner-blink/src/main/scala/org/apache/flink/table/planner/plan/utils/WindowJoinUtil.scala
##########
@@ -182,26 +183,65 @@ object WindowJoinUtil {
}
// Validate join
+ def getLeftFieldNames() = join.getLeft.getRowType.getFieldNames.toList
+
+ def getRightFieldNames() = join.getRight.getRowType.getFieldNames.toList
Review comment:
A local variable is enough?
----------------------------------------------------------------
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:
users@infra.apache.org
[GitHub] [flink] flinkbot edited a comment on pull request #15195: [FLINK-19609][table-planner-blink] Support streaming window join in planner
Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #15195:
URL: https://github.com/apache/flink/pull/15195#issuecomment-798871942
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "8f844ec2c7ace18f8d6a78efbabea949dd7b9a8c",
"status" : "DELETED",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14614",
"triggerID" : "8f844ec2c7ace18f8d6a78efbabea949dd7b9a8c",
"triggerType" : "PUSH"
}, {
"hash" : "c7a1c712fc6f803918ab49a8e07994e1bc590652",
"status" : "DELETED",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14663",
"triggerID" : "c7a1c712fc6f803918ab49a8e07994e1bc590652",
"triggerType" : "PUSH"
}, {
"hash" : "162ca63148a9c1c924936bc17743f830082d800e",
"status" : "DELETED",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14668",
"triggerID" : "162ca63148a9c1c924936bc17743f830082d800e",
"triggerType" : "PUSH"
}, {
"hash" : "0a79f7d2655ee39ce1bb193bde327b1121b80ff4",
"status" : "FAILURE",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14683",
"triggerID" : "0a79f7d2655ee39ce1bb193bde327b1121b80ff4",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* 0a79f7d2655ee39ce1bb193bde327b1121b80ff4 Azure: [FAILURE](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14683)
<details>
<summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot run travis` re-run the last Travis build
- `@flinkbot run azure` re-run the last Azure build
</details>
----------------------------------------------------------------
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:
users@infra.apache.org
[GitHub] [flink] flinkbot edited a comment on pull request #15195: [FLINK-19609][table-planner-blink] Support streaming window join in planner
Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #15195:
URL: https://github.com/apache/flink/pull/15195#issuecomment-798871942
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "8f844ec2c7ace18f8d6a78efbabea949dd7b9a8c",
"status" : "DELETED",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14614",
"triggerID" : "8f844ec2c7ace18f8d6a78efbabea949dd7b9a8c",
"triggerType" : "PUSH"
}, {
"hash" : "c7a1c712fc6f803918ab49a8e07994e1bc590652",
"status" : "DELETED",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14663",
"triggerID" : "c7a1c712fc6f803918ab49a8e07994e1bc590652",
"triggerType" : "PUSH"
}, {
"hash" : "162ca63148a9c1c924936bc17743f830082d800e",
"status" : "DELETED",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14668",
"triggerID" : "162ca63148a9c1c924936bc17743f830082d800e",
"triggerType" : "PUSH"
}, {
"hash" : "0a79f7d2655ee39ce1bb193bde327b1121b80ff4",
"status" : "FAILURE",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14683",
"triggerID" : "0a79f7d2655ee39ce1bb193bde327b1121b80ff4",
"triggerType" : "PUSH"
}, {
"hash" : "7de577188142578d0ed819e2623aedbcb1baccc5",
"status" : "PENDING",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14689",
"triggerID" : "7de577188142578d0ed819e2623aedbcb1baccc5",
"triggerType" : "PUSH"
}, {
"hash" : "44281b2314b6c5bf6b2cfc3387164b9aa7efcc74",
"status" : "UNKNOWN",
"url" : "TBD",
"triggerID" : "44281b2314b6c5bf6b2cfc3387164b9aa7efcc74",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* 0a79f7d2655ee39ce1bb193bde327b1121b80ff4 Azure: [FAILURE](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14683)
* 7de577188142578d0ed819e2623aedbcb1baccc5 Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14689)
* 44281b2314b6c5bf6b2cfc3387164b9aa7efcc74 UNKNOWN
<details>
<summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot run travis` re-run the last Travis build
- `@flinkbot run azure` re-run the last Azure build
</details>
----------------------------------------------------------------
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:
users@infra.apache.org
[GitHub] [flink] wuchong commented on a change in pull request #15195: [FLINK-19609][table-planner-blink] Support streaming window join in planner
Posted by GitBox <gi...@apache.org>.
wuchong commented on a change in pull request #15195:
URL: https://github.com/apache/flink/pull/15195#discussion_r594399049
##########
File path: flink-table/flink-table-planner-blink/src/test/scala/org/apache/flink/table/planner/plan/stream/sql/join/WindowJoinTest.scala
##########
@@ -562,11 +538,8 @@ class WindowJoinTest extends TableTestBase {
thrown.expect(classOf[TableException])
thrown.expectMessage(
- s"""
- |Currently, window starts equality and window ends equality are both required for
- |window join. In the future, we could support join clause which only includes window
- |starts equality or window ends equality for TUMBLE or HOP window.
- |""".stripMargin)
+ "Currently, window join requires JOIN ON condition must contain both window starts " +
+ "equality of input tables and window ends equality of input tables.")
Review comment:
Please also verify the full exception message.
##########
File path: flink-table/flink-table-planner-blink/src/main/scala/org/apache/flink/table/planner/plan/utils/WindowJoinUtil.scala
##########
@@ -185,25 +186,22 @@ object WindowJoinUtil {
if (
leftWindowProperties.getTimeAttributeType != rightWindowProperties.getTimeAttributeType) {
throw new TableException(
- s"""
- |Currently, time attribute type of left and right inputs should be both row-time or
- |both proc-time. In the future, we could support different time attribute type.
- |""".stripMargin)
+ "Currently, window join doesn't support different time attribute type of left and " +
+ "right inputs.\n" +
+ s"The left time attribute type is ${leftWindowProperties.getTimeAttributeType}.\n" +
+ s"The right time attribute type is ${rightWindowProperties.getTimeAttributeType}.")
} else if (leftWindowProperties.getWindowSpec != rightWindowProperties.getWindowSpec) {
throw new TableException(
- s"""
- |Currently, the windowing TVFs must be the same of left and right inputs.
- |In the future, we could support different window TVFs, for example, tumbling windows
- | join sliding windows with the same window size.
- |""".stripMargin)
+ "Currently, window join doesn't support different window table function of left and " +
+ "right inputs.\n" +
+ s"The left window table function is ${leftWindowProperties}.\n" +
Review comment:
We just need to print the windowSpec instead of the total `leftWindowProperties`. Besides, we need to implement `toString` method for WindowSpecs.
##########
File path: flink-table/flink-table-planner-blink/src/test/scala/org/apache/flink/table/planner/plan/stream/sql/join/WindowJoinTest.scala
##########
@@ -562,11 +538,8 @@ class WindowJoinTest extends TableTestBase {
thrown.expect(classOf[TableException])
thrown.expectMessage(
- s"""
- |Currently, window starts equality and window ends equality are both required for
- |window join. In the future, we could support join clause which only includes window
- |starts equality or window ends equality for TUMBLE or HOP window.
- |""".stripMargin)
+ "Currently, window join requires JOIN ON condition must contain both window starts " +
+ "equality of input tables and window ends equality of input tables.")
Review comment:
Please also verify the full exception message.
##########
File path: flink-table/flink-table-planner-blink/src/main/scala/org/apache/flink/table/planner/plan/utils/WindowJoinUtil.scala
##########
@@ -185,25 +186,22 @@ object WindowJoinUtil {
if (
leftWindowProperties.getTimeAttributeType != rightWindowProperties.getTimeAttributeType) {
throw new TableException(
- s"""
- |Currently, time attribute type of left and right inputs should be both row-time or
- |both proc-time. In the future, we could support different time attribute type.
- |""".stripMargin)
+ "Currently, window join doesn't support different time attribute type of left and " +
+ "right inputs.\n" +
+ s"The left time attribute type is ${leftWindowProperties.getTimeAttributeType}.\n" +
+ s"The right time attribute type is ${rightWindowProperties.getTimeAttributeType}.")
} else if (leftWindowProperties.getWindowSpec != rightWindowProperties.getWindowSpec) {
throw new TableException(
- s"""
- |Currently, the windowing TVFs must be the same of left and right inputs.
- |In the future, we could support different window TVFs, for example, tumbling windows
- | join sliding windows with the same window size.
- |""".stripMargin)
+ "Currently, window join doesn't support different window table function of left and " +
+ "right inputs.\n" +
+ s"The left window table function is ${leftWindowProperties}.\n" +
+ s"The right window table function is ${rightWindowProperties}.")
}
} else if (windowStartEqualityLeftKeys.nonEmpty || windowEndEqualityLeftKeys.nonEmpty) {
throw new TableException(
- s"""
- |Currently, window starts equality and window ends equality are both required for
- |window join. In the future, we could support join clause which only includes window
- |starts equality or window ends equality for TUMBLE or HOP window.
- |""".stripMargin)
+ "Currently, window join requires JOIN ON condition must contain both window starts " +
+ "equality of input tables and window ends equality of input tables.\n" +
+ s"But the current JOIN ON condition is ${join.getCondition}.")
Review comment:
Currently, it prints:
```
But the current JOIN ON condition is AND(=($2, $7), =($0, $5)).
```
I think it unreadable and not helpful for users. Would be better to display field names.
----------------------------------------------------------------
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:
users@infra.apache.org
[GitHub] [flink] flinkbot edited a comment on pull request #15195: [FLINK-19609][table-planner-blink] Support streaming window join in planner
Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #15195:
URL: https://github.com/apache/flink/pull/15195#issuecomment-798871942
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "8f844ec2c7ace18f8d6a78efbabea949dd7b9a8c",
"status" : "PENDING",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14614",
"triggerID" : "8f844ec2c7ace18f8d6a78efbabea949dd7b9a8c",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* 8f844ec2c7ace18f8d6a78efbabea949dd7b9a8c Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14614)
<details>
<summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot run travis` re-run the last Travis build
- `@flinkbot run azure` re-run the last Azure build
</details>
----------------------------------------------------------------
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:
users@infra.apache.org
[GitHub] [flink] flinkbot edited a comment on pull request #15195: [FLINK-19609][table-planner-blink] Support streaming window join in planner
Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #15195:
URL: https://github.com/apache/flink/pull/15195#issuecomment-798871942
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "8f844ec2c7ace18f8d6a78efbabea949dd7b9a8c",
"status" : "FAILURE",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14614",
"triggerID" : "8f844ec2c7ace18f8d6a78efbabea949dd7b9a8c",
"triggerType" : "PUSH"
}, {
"hash" : "c7a1c712fc6f803918ab49a8e07994e1bc590652",
"status" : "PENDING",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14663",
"triggerID" : "c7a1c712fc6f803918ab49a8e07994e1bc590652",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* 8f844ec2c7ace18f8d6a78efbabea949dd7b9a8c Azure: [FAILURE](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14614)
* c7a1c712fc6f803918ab49a8e07994e1bc590652 Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14663)
<details>
<summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot run travis` re-run the last Travis build
- `@flinkbot run azure` re-run the last Azure build
</details>
----------------------------------------------------------------
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:
users@infra.apache.org
[GitHub] [flink] beyond1920 commented on a change in pull request #15195: [FLINK-19609][table-planner-blink] Support streaming window join in planner
Posted by GitBox <gi...@apache.org>.
beyond1920 commented on a change in pull request #15195:
URL: https://github.com/apache/flink/pull/15195#discussion_r594057866
##########
File path: flink-table/flink-table-planner-blink/src/test/resources/org/apache/flink/table/planner/plan/stream/sql/join/WindowJoinTest.xml
##########
@@ -0,0 +1,1041 @@
+<?xml version="1.0" ?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to you under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+-->
+<Root>
+ <TestCase name="testCantMergeWindowTVF_Cumulate">
+ <Resource name="sql">
+ <![CDATA[
+SELECT L.a, L.b, L.c, R.a, R.b, R.c
+FROM (
+ SELECT *
+ FROM TABLE(
+ CUMULATE(TABLE MyTable, DESCRIPTOR(rowtime), INTERVAL '10' MINUTE, INTERVAL '1' HOUR))
+) L
+JOIN (
+ SELECT *
+ FROM TABLE(
+ CUMULATE(TABLE MyTable2, DESCRIPTOR(rowtime), INTERVAL '10' MINUTE, INTERVAL '1' HOUR))
+) R
+ON L.window_start = R.window_start AND L.window_end = R.window_end AND L.a = R.a
+ ]]>
+ </Resource>
+ <Resource name="ast">
+ <![CDATA[
+LogicalProject(a=[$0], b=[$1], c=[$2], a0=[$8], b0=[$9], c0=[$10])
++- LogicalJoin(condition=[AND(=($5, $13), =($6, $14), =($0, $8))], joinType=[inner])
+ :- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4], window_start=[$5], window_end=[$6], window_time=[$7])
+ : +- LogicalTableFunctionScan(invocation=[CUMULATE($4, DESCRIPTOR($3), 600000:INTERVAL MINUTE, 3600000:INTERVAL HOUR)], rowType=[RecordType(INTEGER a, VARCHAR(2147483647) b, BIGINT c, TIME ATTRIBUTE(ROWTIME) rowtime, TIME ATTRIBUTE(PROCTIME) proctime, TIMESTAMP(3) window_start, TIMESTAMP(3) window_end, TIME ATTRIBUTE(ROWTIME) window_time)])
+ : +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4])
+ : +- LogicalWatermarkAssigner(rowtime=[rowtime], watermark=[-($3, 1000:INTERVAL SECOND)])
+ : +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[PROCTIME()])
+ : +- LogicalTableScan(table=[[default_catalog, default_database, MyTable]])
+ +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4], window_start=[$5], window_end=[$6], window_time=[$7])
+ +- LogicalTableFunctionScan(invocation=[CUMULATE($4, DESCRIPTOR($3), 600000:INTERVAL MINUTE, 3600000:INTERVAL HOUR)], rowType=[RecordType(INTEGER a, VARCHAR(2147483647) b, BIGINT c, TIME ATTRIBUTE(ROWTIME) rowtime, TIME ATTRIBUTE(PROCTIME) proctime, TIMESTAMP(3) window_start, TIMESTAMP(3) window_end, TIME ATTRIBUTE(ROWTIME) window_time)])
+ +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4])
+ +- LogicalWatermarkAssigner(rowtime=[rowtime], watermark=[-($3, 1000:INTERVAL SECOND)])
+ +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[PROCTIME()])
+ +- LogicalTableScan(table=[[default_catalog, default_database, MyTable2]])
+]]>
+ </Resource>
+ <Resource name="optimized rel plan">
+ <![CDATA[
+Calc(select=[a, b, c, a0, b0, c0])
++- WindowJoin(leftWindow=[CUMULATE(win_start=[window_start], win_end=[window_end], max_size=[1 h], step=[10 min])], rightWindow=[CUMULATE(win_start=[window_start], win_end=[window_end], max_size=[1 h], step=[10 min])], joinType=[InnerJoin], where=[=(a, a0)], select=[a, b, c, window_start, window_end, a0, b0, c0, window_start0, window_end0])
Review comment:
Ok. If I understand well, the problem also exists in WindowJoin, WindowAggregate, WindowJoin when input window strategy is `WindowAttachedWindowingStrategy`, and `TimeAttribute` is proc-time at the same time. Right?
----------------------------------------------------------------
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:
users@infra.apache.org
[GitHub] [flink] flinkbot edited a comment on pull request #15195: [FLINK-19609][table-planner-blink] Support streaming window join in planner
Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #15195:
URL: https://github.com/apache/flink/pull/15195#issuecomment-798871942
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "8f844ec2c7ace18f8d6a78efbabea949dd7b9a8c",
"status" : "DELETED",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14614",
"triggerID" : "8f844ec2c7ace18f8d6a78efbabea949dd7b9a8c",
"triggerType" : "PUSH"
}, {
"hash" : "c7a1c712fc6f803918ab49a8e07994e1bc590652",
"status" : "DELETED",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14663",
"triggerID" : "c7a1c712fc6f803918ab49a8e07994e1bc590652",
"triggerType" : "PUSH"
}, {
"hash" : "162ca63148a9c1c924936bc17743f830082d800e",
"status" : "DELETED",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14668",
"triggerID" : "162ca63148a9c1c924936bc17743f830082d800e",
"triggerType" : "PUSH"
}, {
"hash" : "0a79f7d2655ee39ce1bb193bde327b1121b80ff4",
"status" : "DELETED",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14683",
"triggerID" : "0a79f7d2655ee39ce1bb193bde327b1121b80ff4",
"triggerType" : "PUSH"
}, {
"hash" : "7de577188142578d0ed819e2623aedbcb1baccc5",
"status" : "DELETED",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14689",
"triggerID" : "7de577188142578d0ed819e2623aedbcb1baccc5",
"triggerType" : "PUSH"
}, {
"hash" : "44281b2314b6c5bf6b2cfc3387164b9aa7efcc74",
"status" : "DELETED",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14706",
"triggerID" : "44281b2314b6c5bf6b2cfc3387164b9aa7efcc74",
"triggerType" : "PUSH"
}, {
"hash" : "693860368d8c271691f65cdd37644d99df7786a5",
"status" : "DELETED",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14861",
"triggerID" : "693860368d8c271691f65cdd37644d99df7786a5",
"triggerType" : "PUSH"
}, {
"hash" : "47ef3ba16e9a53261be1fd78014d1cab14bc0cf7",
"status" : "SUCCESS",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14865",
"triggerID" : "47ef3ba16e9a53261be1fd78014d1cab14bc0cf7",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* 47ef3ba16e9a53261be1fd78014d1cab14bc0cf7 Azure: [SUCCESS](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14865)
<details>
<summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot run travis` re-run the last Travis build
- `@flinkbot run azure` re-run the last Azure build
</details>
----------------------------------------------------------------
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:
users@infra.apache.org
[GitHub] [flink] wuchong commented on a change in pull request #15195: [FLINK-19609][table-planner-blink] Support streaming window join in planner
Posted by GitBox <gi...@apache.org>.
wuchong commented on a change in pull request #15195:
URL: https://github.com/apache/flink/pull/15195#discussion_r594060694
##########
File path: flink-table/flink-table-planner-blink/src/test/resources/org/apache/flink/table/planner/plan/stream/sql/join/WindowJoinTest.xml
##########
@@ -0,0 +1,1041 @@
+<?xml version="1.0" ?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to you under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+-->
+<Root>
+ <TestCase name="testCantMergeWindowTVF_Cumulate">
+ <Resource name="sql">
+ <![CDATA[
+SELECT L.a, L.b, L.c, R.a, R.b, R.c
+FROM (
+ SELECT *
+ FROM TABLE(
+ CUMULATE(TABLE MyTable, DESCRIPTOR(rowtime), INTERVAL '10' MINUTE, INTERVAL '1' HOUR))
+) L
+JOIN (
+ SELECT *
+ FROM TABLE(
+ CUMULATE(TABLE MyTable2, DESCRIPTOR(rowtime), INTERVAL '10' MINUTE, INTERVAL '1' HOUR))
+) R
+ON L.window_start = R.window_start AND L.window_end = R.window_end AND L.a = R.a
+ ]]>
+ </Resource>
+ <Resource name="ast">
+ <![CDATA[
+LogicalProject(a=[$0], b=[$1], c=[$2], a0=[$8], b0=[$9], c0=[$10])
++- LogicalJoin(condition=[AND(=($5, $13), =($6, $14), =($0, $8))], joinType=[inner])
+ :- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4], window_start=[$5], window_end=[$6], window_time=[$7])
+ : +- LogicalTableFunctionScan(invocation=[CUMULATE($4, DESCRIPTOR($3), 600000:INTERVAL MINUTE, 3600000:INTERVAL HOUR)], rowType=[RecordType(INTEGER a, VARCHAR(2147483647) b, BIGINT c, TIME ATTRIBUTE(ROWTIME) rowtime, TIME ATTRIBUTE(PROCTIME) proctime, TIMESTAMP(3) window_start, TIMESTAMP(3) window_end, TIME ATTRIBUTE(ROWTIME) window_time)])
+ : +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4])
+ : +- LogicalWatermarkAssigner(rowtime=[rowtime], watermark=[-($3, 1000:INTERVAL SECOND)])
+ : +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[PROCTIME()])
+ : +- LogicalTableScan(table=[[default_catalog, default_database, MyTable]])
+ +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4], window_start=[$5], window_end=[$6], window_time=[$7])
+ +- LogicalTableFunctionScan(invocation=[CUMULATE($4, DESCRIPTOR($3), 600000:INTERVAL MINUTE, 3600000:INTERVAL HOUR)], rowType=[RecordType(INTEGER a, VARCHAR(2147483647) b, BIGINT c, TIME ATTRIBUTE(ROWTIME) rowtime, TIME ATTRIBUTE(PROCTIME) proctime, TIMESTAMP(3) window_start, TIMESTAMP(3) window_end, TIME ATTRIBUTE(ROWTIME) window_time)])
+ +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[$4])
+ +- LogicalWatermarkAssigner(rowtime=[rowtime], watermark=[-($3, 1000:INTERVAL SECOND)])
+ +- LogicalProject(a=[$0], b=[$1], c=[$2], rowtime=[$3], proctime=[PROCTIME()])
+ +- LogicalTableScan(table=[[default_catalog, default_database, MyTable2]])
+]]>
+ </Resource>
+ <Resource name="optimized rel plan">
+ <![CDATA[
+Calc(select=[a, b, c, a0, b0, c0])
++- WindowJoin(leftWindow=[CUMULATE(win_start=[window_start], win_end=[window_end], max_size=[1 h], step=[10 min])], rightWindow=[CUMULATE(win_start=[window_start], win_end=[window_end], max_size=[1 h], step=[10 min])], joinType=[InnerJoin], where=[=(a, a0)], select=[a, b, c, window_start, window_end, a0, b0, c0, window_start0, window_end0])
Review comment:
Yes.
----------------------------------------------------------------
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:
users@infra.apache.org
[GitHub] [flink] flinkbot edited a comment on pull request #15195: [FLINK-19609][table-planner-blink] Support streaming window join in planner
Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #15195:
URL: https://github.com/apache/flink/pull/15195#issuecomment-798871942
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "8f844ec2c7ace18f8d6a78efbabea949dd7b9a8c",
"status" : "DELETED",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14614",
"triggerID" : "8f844ec2c7ace18f8d6a78efbabea949dd7b9a8c",
"triggerType" : "PUSH"
}, {
"hash" : "c7a1c712fc6f803918ab49a8e07994e1bc590652",
"status" : "DELETED",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14663",
"triggerID" : "c7a1c712fc6f803918ab49a8e07994e1bc590652",
"triggerType" : "PUSH"
}, {
"hash" : "162ca63148a9c1c924936bc17743f830082d800e",
"status" : "DELETED",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14668",
"triggerID" : "162ca63148a9c1c924936bc17743f830082d800e",
"triggerType" : "PUSH"
}, {
"hash" : "0a79f7d2655ee39ce1bb193bde327b1121b80ff4",
"status" : "FAILURE",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14683",
"triggerID" : "0a79f7d2655ee39ce1bb193bde327b1121b80ff4",
"triggerType" : "PUSH"
}, {
"hash" : "7de577188142578d0ed819e2623aedbcb1baccc5",
"status" : "UNKNOWN",
"url" : "TBD",
"triggerID" : "7de577188142578d0ed819e2623aedbcb1baccc5",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* 0a79f7d2655ee39ce1bb193bde327b1121b80ff4 Azure: [FAILURE](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14683)
* 7de577188142578d0ed819e2623aedbcb1baccc5 UNKNOWN
<details>
<summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot run travis` re-run the last Travis build
- `@flinkbot run azure` re-run the last Azure build
</details>
----------------------------------------------------------------
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:
users@infra.apache.org
[GitHub] [flink] beyond1920 commented on pull request #15195: [FLINK-19609][table-planner-blink] Support streaming window join in planner
Posted by GitBox <gi...@apache.org>.
beyond1920 commented on pull request #15195:
URL: https://github.com/apache/flink/pull/15195#issuecomment-799444673
@wuchong Thanks, I've updated based on your comment.
----------------------------------------------------------------
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:
users@infra.apache.org
[GitHub] [flink] flinkbot edited a comment on pull request #15195: [FLINK-19609][table-planner-blink] Support streaming window join in planner
Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #15195:
URL: https://github.com/apache/flink/pull/15195#issuecomment-798871942
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "8f844ec2c7ace18f8d6a78efbabea949dd7b9a8c",
"status" : "FAILURE",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14614",
"triggerID" : "8f844ec2c7ace18f8d6a78efbabea949dd7b9a8c",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* 8f844ec2c7ace18f8d6a78efbabea949dd7b9a8c Azure: [FAILURE](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14614)
<details>
<summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot run travis` re-run the last Travis build
- `@flinkbot run azure` re-run the last Azure build
</details>
----------------------------------------------------------------
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:
users@infra.apache.org
[GitHub] [flink] beyond1920 commented on a change in pull request #15195: [FLINK-19609][table-planner-blink] Support streaming window join in planner
Posted by GitBox <gi...@apache.org>.
beyond1920 commented on a change in pull request #15195:
URL: https://github.com/apache/flink/pull/15195#discussion_r594017853
##########
File path: flink-table/flink-table-planner-blink/src/main/scala/org/apache/flink/table/planner/plan/nodes/physical/stream/StreamPhysicalWindowJoin.scala
##########
@@ -0,0 +1,91 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.flink.table.planner.plan.nodes.physical.stream
+
+import org.apache.flink.table.api.TableException
+import org.apache.flink.table.planner.plan.logical.WindowingStrategy
+import org.apache.flink.table.planner.plan.nodes.exec.ExecNode
+import org.apache.flink.table.planner.plan.nodes.physical.common.CommonPhysicalJoin
+import org.apache.flink.table.planner.plan.utils.PythonUtil.containsPythonCall
+import org.apache.flink.table.planner.plan.utils.RelExplainUtil.preferExpressionFormat
+
+import org.apache.calcite.plan.{RelOptCluster, RelTraitSet}
+import org.apache.calcite.rel._
+import org.apache.calcite.rel.core.{Join, JoinRelType}
+import org.apache.calcite.rex.RexNode
+
+import scala.collection.JavaConversions._
+import scala.collection.JavaConverters._
+
+/**
+ * The window join requires the join condition contains window starts equality of
+ * input tables and window ends equality of input tables.
+ * The semantic of window join is the same to the DataStream window join.
+ */
+class StreamPhysicalWindowJoin(
+ cluster: RelOptCluster,
+ traitSet: RelTraitSet,
+ leftRel: RelNode,
+ rightRel: RelNode,
+ joinType: JoinRelType,
+ // remaining join condition contains all of join condition except window starts equality
+ // and window end equality
+ remainingCondition: RexNode,
+ val leftWindowing: WindowingStrategy,
+ val rightWindowing: WindowingStrategy)
Review comment:
Left windowStrategy and Right windowStrategy only have same timeAttribute and WindowSpec. But window start index and window end index maybe different.
----------------------------------------------------------------
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:
users@infra.apache.org
[GitHub] [flink] wuchong commented on a change in pull request #15195: [FLINK-19609][table-planner-blink] Support streaming window join in planner
Posted by GitBox <gi...@apache.org>.
wuchong commented on a change in pull request #15195:
URL: https://github.com/apache/flink/pull/15195#discussion_r594060604
##########
File path: flink-table/flink-table-planner-blink/src/main/scala/org/apache/flink/table/planner/plan/utils/WindowJoinUtil.scala
##########
@@ -0,0 +1,219 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.planner.plan.utils
+
+import org.apache.flink.table.api.TableException
+import org.apache.flink.table.planner.plan.metadata.FlinkRelMetadataQuery
+import org.apache.flink.table.planner.plan.nodes.logical.FlinkLogicalJoin
+import org.apache.flink.table.planner.plan.`trait`.RelWindowProperties
+
+import org.apache.calcite.rex.{RexInputRef, RexNode, RexUtil}
+import org.apache.calcite.sql.fun.SqlStdOperatorTable
+import org.apache.calcite.util.ImmutableIntList
+
+import scala.collection.JavaConversions._
+import scala.collection.mutable
+
+/**
+ * Util for window join.
+ */
+object WindowJoinUtil {
+
+ /**
+ * Get window properties of left and right child.
+ *
+ * @param join input join
+ * @return window properties of left and right child.
+ */
+ def getChildWindowProperties(
+ join: FlinkLogicalJoin): (RelWindowProperties, RelWindowProperties) = {
+ val fmq = FlinkRelMetadataQuery.reuseOrCreate(join.getCluster.getMetadataQuery)
+ (fmq.getRelWindowProperties(join.getLeft), fmq.getRelWindowProperties(join.getRight))
+ }
+
+ /**
+ * Checks whether join condition contains window starts equality of input tables or window
+ * ends equality of input tables.
+ *
+ * @param join input join
+ * @return True if join condition contains window starts equality of input tables and window
+ * ends equality of input tables. Else false.
+ */
+ def containsWindowStartEqualityOrEndEquality(join: FlinkLogicalJoin): Boolean = {
+ val (windowStartEqualityLeftKeys, windowEndEqualityLeftKeys, _, _) =
+ excludeWindowStartEqualityAndEndEqualityFromJoinInfoPairs(join)
+ windowStartEqualityLeftKeys.nonEmpty || windowEndEqualityLeftKeys.nonEmpty
+ }
+
+ /**
+ * Excludes window starts equality and window ends equality from join info.
+ *
+ * @param join input join
+ * @return Remain join information after excludes window starts equality and window ends
+ * equality from join.
+ * The first element is left join keys of window starts equality,
+ * the second element is left join keys of window ends equality,
+ * the third element is right join keys of window starts equality,
+ * the forth element is right join keys of window ends equality,
+ * the fifth element is remain left join keys,
+ * the sixth element is remain right join keys,
+ * the last element is remain join condition which includes remain equal condition and
+ * non-equal condition.
+ */
+ def excludeWindowStartEqualityAndEndEqualityFromJoinCondition(
+ join: FlinkLogicalJoin): (
+ ImmutableIntList,
+ ImmutableIntList,
+ ImmutableIntList,
+ ImmutableIntList,
+ ImmutableIntList,
+ ImmutableIntList,
+ RexNode) = {
+ val (
+ windowStartEqualityLeftKeys,
+ windowEndEqualityLeftKeys,
+ windowStartEqualityRightKeys,
+ windowEndEqualityRightKeys) =
+ excludeWindowStartEqualityAndEndEqualityFromJoinInfoPairs(join)
+
+ val joinInfo = join.analyzeCondition()
+ val (remainLeftKeys, remainRightKeys, remainCondition) = if (
+ windowStartEqualityLeftKeys.nonEmpty || windowEndEqualityLeftKeys.nonEmpty) {
+ val joinFieldsType = join.getRowType.getFieldList
+ val leftFieldCnt = join.getLeft.getRowType.getFieldCount
+ val rexBuilder = join.getCluster.getRexBuilder
+ val remainEquals = mutable.ArrayBuffer[RexNode]()
+ val remainLeftKeysArray = mutable.ArrayBuffer[Int]()
+ val remainRightKeysArray = mutable.ArrayBuffer[Int]()
+ // convert remain pairs to RexInputRef tuple for building SqlStdOperatorTable.EQUALS calls
+ joinInfo.pairs().foreach { p =>
+ if (!windowStartEqualityLeftKeys.contains(p.source) &&
+ !windowEndEqualityLeftKeys.contains(p.source)) {
+ val leftFieldType = joinFieldsType.get(p.source).getType
+ val leftInputRef = new RexInputRef(p.source, leftFieldType)
+ val rightIndex = leftFieldCnt + p.target
+ val rightFieldType = joinFieldsType.get(rightIndex).getType
+ val rightInputRef = new RexInputRef(rightIndex, rightFieldType)
+ val remainEqual = rexBuilder.makeCall(
+ SqlStdOperatorTable.EQUALS,
Review comment:
Thanks for the explanation. Sounds good to me.
----------------------------------------------------------------
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:
users@infra.apache.org
[GitHub] [flink] flinkbot commented on pull request #15195: [FLINK-19609][table-planner-blink] Support streaming window join in planner
Posted by GitBox <gi...@apache.org>.
flinkbot commented on pull request #15195:
URL: https://github.com/apache/flink/pull/15195#issuecomment-798870019
Thanks a lot for your contribution to the Apache Flink project. I'm the @flinkbot. I help the community
to review your pull request. We will use this comment to track the progress of the review.
## Automated Checks
Last check on commit 8f844ec2c7ace18f8d6a78efbabea949dd7b9a8c (Sun Mar 14 08:40:20 UTC 2021)
**Warnings:**
* No documentation files were touched! Remember to keep the Flink docs up to date!
<sub>Mention the bot in a comment to re-run the automated checks.</sub>
## Review Progress
* ❓ 1. The [description] looks good.
* ❓ 2. There is [consensus] that the contribution should go into to Flink.
* ❓ 3. Needs [attention] from.
* ❓ 4. The change fits into the overall [architecture].
* ❓ 5. Overall code [quality] is good.
Please see the [Pull Request Review Guide](https://flink.apache.org/contributing/reviewing-prs.html) for a full explanation of the review process.<details>
The Bot is tracking the review progress through labels. Labels are applied according to the order of the review items. For consensus, approval by a Flink committer of PMC member is required <summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot approve description` to approve one or more aspects (aspects: `description`, `consensus`, `architecture` and `quality`)
- `@flinkbot approve all` to approve all aspects
- `@flinkbot approve-until architecture` to approve everything until `architecture`
- `@flinkbot attention @username1 [@username2 ..]` to require somebody's attention
- `@flinkbot disapprove architecture` to remove an approval you gave earlier
</details>
----------------------------------------------------------------
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:
users@infra.apache.org
[GitHub] [flink] flinkbot edited a comment on pull request #15195: [FLINK-19609][table-planner-blink] Support streaming window join in planner
Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #15195:
URL: https://github.com/apache/flink/pull/15195#issuecomment-798871942
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "8f844ec2c7ace18f8d6a78efbabea949dd7b9a8c",
"status" : "DELETED",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14614",
"triggerID" : "8f844ec2c7ace18f8d6a78efbabea949dd7b9a8c",
"triggerType" : "PUSH"
}, {
"hash" : "c7a1c712fc6f803918ab49a8e07994e1bc590652",
"status" : "DELETED",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14663",
"triggerID" : "c7a1c712fc6f803918ab49a8e07994e1bc590652",
"triggerType" : "PUSH"
}, {
"hash" : "162ca63148a9c1c924936bc17743f830082d800e",
"status" : "DELETED",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14668",
"triggerID" : "162ca63148a9c1c924936bc17743f830082d800e",
"triggerType" : "PUSH"
}, {
"hash" : "0a79f7d2655ee39ce1bb193bde327b1121b80ff4",
"status" : "DELETED",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14683",
"triggerID" : "0a79f7d2655ee39ce1bb193bde327b1121b80ff4",
"triggerType" : "PUSH"
}, {
"hash" : "7de577188142578d0ed819e2623aedbcb1baccc5",
"status" : "DELETED",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14689",
"triggerID" : "7de577188142578d0ed819e2623aedbcb1baccc5",
"triggerType" : "PUSH"
}, {
"hash" : "44281b2314b6c5bf6b2cfc3387164b9aa7efcc74",
"status" : "SUCCESS",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14706",
"triggerID" : "44281b2314b6c5bf6b2cfc3387164b9aa7efcc74",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* 44281b2314b6c5bf6b2cfc3387164b9aa7efcc74 Azure: [SUCCESS](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=14706)
<details>
<summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot run travis` re-run the last Travis build
- `@flinkbot run azure` re-run the last Azure build
</details>
----------------------------------------------------------------
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:
users@infra.apache.org
[GitHub] [flink] beyond1920 commented on pull request #15195: [FLINK-19609][table-planner-blink] Support streaming window join in planner
Posted by GitBox <gi...@apache.org>.
beyond1920 commented on pull request #15195:
URL: https://github.com/apache/flink/pull/15195#issuecomment-800781664
@wuchong Thanks a lot, I've updated based on your comment.
----------------------------------------------------------------
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:
users@infra.apache.org