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 2020/12/20 06:57:07 UTC

[GitHub] [flink] wenlong88 commented on a change in pull request #14398: [FLINK-20516][table-planner-blink] Separate the implementation of BatchExecTableSourceScan and StreamExecTableSourceScan

wenlong88 commented on a change in pull request #14398:
URL: https://github.com/apache/flink/pull/14398#discussion_r546330391



##########
File path: flink-table/flink-table-planner-blink/src/main/java/org/apache/flink/table/planner/plan/nodes/exec/batch/BatchExecTableSourceScan.java
##########
@@ -0,0 +1,69 @@
+/*
+ * 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.common.io.InputFormat;
+import org.apache.flink.api.dag.Transformation;
+import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
+import org.apache.flink.streaming.api.functions.source.InputFormatSourceFunction;
+import org.apache.flink.table.connector.source.ScanTableSource;
+import org.apache.flink.table.data.RowData;
+import org.apache.flink.table.planner.delegation.BatchPlanner;
+import org.apache.flink.table.planner.plan.nodes.exec.common.CommonExecTableSourceScan;
+import org.apache.flink.table.planner.plan.nodes.exec.utils.ExecNodeUtil;
+import org.apache.flink.table.runtime.typeutils.InternalTypeInfo;
+import org.apache.flink.table.types.logical.RowType;
+
+import java.util.Collections;
+
+/**
+ * Batch exec node to read data from an external source defined by a bounded {@link ScanTableSource}.
+ */
+public class BatchExecTableSourceScan extends BatchExecNode<RowData> implements CommonExecTableSourceScan {
+	private final ScanTableSource tableSource;
+
+	public BatchExecTableSourceScan(
+			ScanTableSource tableSource,
+			RowType outputType,
+			String description) {
+		super(Collections.emptyList(), outputType, description);
+		this.tableSource = tableSource;
+	}
+
+	@Override
+	protected Transformation<RowData> translateToPlanInternal(BatchPlanner planner) {
+		return createSourceTransformation(planner.getExecEnv(), tableSource, getOutputType(), getDesc());
+	}
+
+	@Override
+	public Transformation<RowData> createInputFormatTransformation(
+			StreamExecutionEnvironment env,
+			InputFormat<RowData, ?> inputFormat,
+			InternalTypeInfo<RowData> outputTypeInfo,
+			String name) {
+		// env.createInput will use ContinuousFileReaderOperator, but it do not support multiple
+		// paths. If read partitioned source, after partition pruning, we need let InputFormat
+		// to read multiple partitions which are multiple paths.
+		// We can use InputFormatSourceFunction directly to support InputFormat.
+		InputFormatSourceFunction<RowData> func = new InputFormatSourceFunction<>(inputFormat, outputTypeInfo);
+		Transformation<RowData> transformation = env.addSource(func, name, outputTypeInfo).getTransformation();
+		ExecNodeUtil.setManagedMemoryWeight(transformation, 0L);

Review comment:
       Is it necessary to set 0 managed memory weight, by default it should be 0.




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