beyond1920 commented on a change in pull request #15997: URL: https://github.com/apache/flink/pull/15997#discussion_r640267152
########## File path: flink-table/flink-table-planner-blink/src/test/resources/org/apache/flink/table/planner/plan/rules/physical/stream/WatermarkAssignerChangelogNormalizeTransposeRuleTest.xml ########## @@ -0,0 +1,154 @@ +<?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="testNothingHappenWithCalc"> + <Resource name="sql"> + <![CDATA[ +SELECT +TUMBLE_START(currency_time, INTERVAL '5' SECOND) as w_start, +TUMBLE_END(currency_time, INTERVAL '5' SECOND) as w_end, +MAX(rate) AS max_rate +FROM src_with_computed_column +GROUP BY TUMBLE(currency_time, INTERVAL '5' SECOND) +]]> + </Resource> + <Resource name="ast"> + <![CDATA[ +LogicalProject(w_start=[TUMBLE_START($0)], w_end=[TUMBLE_END($0)], max_rate=[$1]) ++- LogicalAggregate(group=[{0}], max_rate=[MAX($1)]) + +- LogicalProject($f0=[$TUMBLE($4, 5000:INTERVAL SECOND)], rate=[$2]) + +- LogicalWatermarkAssigner(rowtime=[currency_time], watermark=[-($4, 5000:INTERVAL SECOND)]) + +- LogicalProject(currency=[$0], currency_no=[$1], rate=[$2], c=[$3], currency_time=[TO_TIMESTAMP($3)]) + +- LogicalTableScan(table=[[default_catalog, default_database, src_with_computed_column]]) +]]> + </Resource> + <Resource name="optimized rel plan"> + <![CDATA[ +Calc(select=[w$start AS w_start, w$end AS w_end, max_rate], changelogMode=[I]) ++- GroupWindowAggregate(window=[TumblingGroupWindow('w$, currency_time, 5000)], properties=[w$start, w$end, w$rowtime, w$proctime], select=[MAX(rate) AS max_rate, start('w$) AS w$start, end('w$) AS w$end, rowtime('w$) AS w$rowtime, proctime('w$) AS w$proctime], changelogMode=[I]) + +- Exchange(distribution=[single], changelogMode=[I,UB,UA,D]) + +- WatermarkAssigner(rowtime=[currency_time], watermark=[-(currency_time, 5000:INTERVAL SECOND)], changelogMode=[I,UB,UA,D]) Review comment: rewrites has no effect if does not satisfy any of the following condition: 1. shuffle keys are all kept after Calc 2. row time field does not depend on computed column In this case, Calc should not pushed down because shuffle key are not kept after calc. And watermark could not pushed down alone because row-time based on a computed column. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected]
