godfreyhe commented on a change in pull request #17666: URL: https://github.com/apache/flink/pull/17666#discussion_r754795448
########## File path: flink-table/flink-table-planner/src/test/scala/org/apache/flink/table/planner/plan/batch/sql/WindowTableFunctionTest.scala ########## @@ -0,0 +1,198 @@ +/* + * 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.batch.sql + +import org.apache.flink.api.scala._ +import org.apache.flink.table.api._ +import org.apache.flink.table.planner.utils.TableTestBase + +import java.sql.Timestamp + +import org.junit.{Before, Test} + +class WindowTableFunctionTest extends TableTestBase { Review comment: please add some test cases to verify the projection window-table-function transpose ########## File path: flink-table/flink-table-planner/src/main/scala/org/apache/flink/table/planner/plan/nodes/common/CommonPhysicalWindowTableFunction.scala ########## @@ -0,0 +1,70 @@ +/* + * 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.common + +import org.apache.flink.table.api.TableException +import org.apache.flink.table.planner.plan.logical.{CumulativeWindowSpec, HoppingWindowSpec, TimeAttributeWindowingStrategy, TumblingWindowSpec} + +import org.apache.calcite.plan.{RelOptCluster, RelTraitSet} +import org.apache.calcite.rel.`type`.RelDataType +import org.apache.calcite.rel.metadata.RelMetadataQuery +import org.apache.calcite.rel.{RelNode, RelWriter, SingleRel} + +import scala.collection.JavaConverters._ + +/** + * Base physical RelNode for window table-valued function. + */ +abstract class CommonPhysicalWindowTableFunction( + cluster: RelOptCluster, + traitSet: RelTraitSet, + inputRel: RelNode, + outputRowType: RelDataType, + val windowing: TimeAttributeWindowingStrategy) + extends SingleRel(cluster, traitSet, inputRel) { + + override def deriveRowType(): RelDataType = outputRowType + + override def explainTerms(pw: RelWriter): RelWriter = { + val inputFieldNames = getInput.getRowType.getFieldNames.asScala.toArray + super.explainTerms(pw) + .item("window", windowing.toSummaryString(inputFieldNames)) + } + + override def estimateRowCount(mq: RelMetadataQuery): Double = { Review comment: We should add a test case in FlinkRelMdRowCountTest for WindowTableFunction -- 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. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
