JingsongLi commented on a change in pull request #17666:
URL: https://github.com/apache/flink/pull/17666#discussion_r746306840



##########
File path: 
flink-table/flink-table-planner/src/main/scala/org/apache/flink/table/planner/plan/nodes/physical/batch/BatchPhysicalWindowTableFunction.scala
##########
@@ -0,0 +1,95 @@
+/*
+ * 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.batch
+
+import org.apache.flink.table.api.TableException
+import org.apache.flink.table.planner.calcite.FlinkTypeFactory
+import org.apache.flink.table.planner.plan.logical.{CumulativeWindowSpec, 
HoppingWindowSpec, TimeAttributeWindowingStrategy, TumblingWindowSpec}
+import 
org.apache.flink.table.planner.plan.nodes.exec.batch.BatchExecWindowTableFunction
+import org.apache.flink.table.planner.plan.nodes.exec.{ExecNode, InputProperty}
+
+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 java.util
+
+import scala.collection.JavaConverters._
+
+/**
+ * Batch physical RelNode for window table-valued function.
+ */
+class BatchPhysicalWindowTableFunction(
+    cluster: RelOptCluster,
+    traitSet: RelTraitSet,
+    inputRel: RelNode,
+    outputRowType: RelDataType,
+    val windowing: TimeAttributeWindowingStrategy)
+  extends SingleRel(cluster, traitSet, inputRel)
+  with BatchPhysicalRel {
+
+  override def deriveRowType(): RelDataType = outputRowType
+
+  override def copy(traitSet: RelTraitSet, inputs: util.List[RelNode]): 
RelNode = {
+    new BatchPhysicalWindowTableFunction(
+      cluster,
+      traitSet,
+      inputs.get(0),
+      outputRowType,
+      windowing)
+  }
+
+  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:
       Looks like streaming also can have this method? We can extract an 
abstract class for physical node too.

##########
File path: 
flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/plan/nodes/exec/batch/BatchExecWindowTableFunction.java
##########
@@ -0,0 +1,84 @@
+/*
+ * 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.exec.batch;
+
+import org.apache.flink.api.dag.Transformation;
+import org.apache.flink.streaming.api.transformations.OneInputTransformation;
+import org.apache.flink.table.api.TableException;
+import org.apache.flink.table.data.RowData;
+import org.apache.flink.table.planner.delegation.PlannerBase;
+import 
org.apache.flink.table.planner.plan.logical.TimeAttributeWindowingStrategy;
+import org.apache.flink.table.planner.plan.logical.WindowSpec;
+import org.apache.flink.table.planner.plan.nodes.exec.ExecEdge;
+import org.apache.flink.table.planner.plan.nodes.exec.ExecNode;
+import org.apache.flink.table.planner.plan.nodes.exec.ExecNodeBase;
+import org.apache.flink.table.planner.plan.nodes.exec.InputProperty;
+import 
org.apache.flink.table.planner.plan.nodes.exec.SingleTransformationTranslator;
+import org.apache.flink.table.runtime.operators.window.TimeWindow;
+import 
org.apache.flink.table.runtime.operators.window.WindowTableFunctionOperator;
+import 
org.apache.flink.table.runtime.operators.window.assigners.WindowAssigner;
+import org.apache.flink.table.runtime.typeutils.InternalTypeInfo;
+import org.apache.flink.table.runtime.util.TimeWindowUtil;
+import org.apache.flink.table.types.logical.RowType;
+
+import java.time.ZoneId;
+import java.util.Collections;
+
+import static 
org.apache.flink.table.planner.plan.utils.WindowTableFunctionUtil.createWindowAssigner;
+
+/** Batch {@link ExecNode} for window table-valued function. */
+public class BatchExecWindowTableFunction extends ExecNodeBase<RowData>

Review comment:
       Looks totally same to Stream... Can we have abstract class?

##########
File path: 
flink-table/flink-table-runtime/src/main/java/org/apache/flink/table/runtime/operators/window/WindowTableFunctionOperator.java
##########
@@ -89,7 +89,12 @@ public void open() throws Exception {
     @Override
     public void processElement(StreamRecord<RowData> element) throws Exception 
{
         RowData inputRow = element.getValue();
-        long timestamp = inputRow.getTimestamp(rowtimeIndex, 
3).getMillisecond();
+        TimestampData timestampData = inputRow.getTimestamp(rowtimeIndex, 3);

Review comment:
       Using `RowData.isNullAt`




-- 
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]


Reply via email to