hailin0 commented on code in PR #3396:
URL:
https://github.com/apache/incubator-seatunnel/pull/3396#discussion_r1020130068
##########
seatunnel-core/seatunnel-flink-starter/src/main/java/org/apache/seatunnel/core/starter/flink/execution/TransformExecuteProcessor.java:
##########
@@ -34,6 +34,7 @@
import java.util.List;
import java.util.stream.Collectors;
+@Deprecated
public class TransformExecuteProcessor extends
AbstractPluginExecuteProcessor<FlinkStreamTransform> {
Review Comment:
remove this file?
##########
seatunnel-core/seatunnel-flink-starter/src/main/java/org/apache/seatunnel/core/starter/flink/execution/TransformV2ExecuteProcessor.java:
##########
@@ -0,0 +1,111 @@
+/*
+ * 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.seatunnel.core.starter.flink.execution;
+
+import org.apache.seatunnel.api.common.JobContext;
+import org.apache.seatunnel.api.table.type.SeaTunnelDataType;
+import org.apache.seatunnel.api.table.type.SeaTunnelRow;
+import org.apache.seatunnel.api.transform.SeaTunnelTransform;
+import org.apache.seatunnel.core.starter.exception.TaskExecuteException;
+import org.apache.seatunnel.plugin.discovery.PluginIdentifier;
+import
org.apache.seatunnel.plugin.discovery.seatunnel.SeaTunnelTransformPluginDiscovery;
+import org.apache.seatunnel.translation.flink.serialization.FlinkRowConverter;
+import org.apache.seatunnel.translation.flink.utils.TypeConverterUtils;
+
+import org.apache.seatunnel.shade.com.typesafe.config.Config;
+
+import com.google.common.collect.Lists;
+import org.apache.flink.api.common.functions.MapFunction;
+import org.apache.flink.api.common.typeinfo.TypeInformation;
+import org.apache.flink.streaming.api.datastream.DataStream;
+import org.apache.flink.types.Row;
+
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Collectors;
+
+public class TransformV2ExecuteProcessor extends
AbstractPluginExecuteProcessor<SeaTunnelTransform> {
+
+ private static final String PLUGIN_TYPE = "transform";
+
+ protected TransformV2ExecuteProcessor(List<URL> jarPaths, List<? extends
Config> pluginConfigs, JobContext jobContext) {
+ super(jarPaths, pluginConfigs, jobContext);
+ }
+
+ @Override
+ protected List<SeaTunnelTransform> initializePlugins(List<URL> jarPaths,
List<? extends Config> pluginConfigs, JobContext jobContext) {
+ SeaTunnelTransformPluginDiscovery transformV2PluginDiscovery = new
SeaTunnelTransformPluginDiscovery();
+ List<URL> pluginJars = new ArrayList<>();
+ List<SeaTunnelTransform> transforms = pluginConfigs.stream()
+ .map(transformConfig -> {
+ PluginIdentifier pluginIdentifier =
PluginIdentifier.of(ENGINE_TYPE, PLUGIN_TYPE,
transformConfig.getString(PLUGIN_NAME));
+ List<URL> pluginJarPaths =
transformV2PluginDiscovery.getPluginJarPaths(Lists.newArrayList(pluginIdentifier));
+ SeaTunnelTransform<?> seaTunnelTransform =
+
transformV2PluginDiscovery.createPluginInstance(pluginIdentifier);
+ jarPaths.addAll(pluginJarPaths);
+ seaTunnelTransform.prepare(transformConfig);
+ seaTunnelTransform.setJobContext(jobContext);
+ return seaTunnelTransform;
+ }).distinct().collect(Collectors.toList());
+ jarPaths.addAll(pluginJars);
+ return transforms;
+ }
+
+ @Override
+ public List<DataStream<Row>> execute(List<DataStream<Row>>
upstreamDataStreams) throws TaskExecuteException {
+ if (plugins.isEmpty()) {
+ return upstreamDataStreams;
+ }
+ DataStream<Row> input = upstreamDataStreams.get(0);
+ List<DataStream<Row>> result = new ArrayList<>();
+ for (int i = 0; i < plugins.size(); i++) {
+ try {
+ SeaTunnelTransform<Row> transform = plugins.get(i);
Review Comment:
```suggestion
SeaTunnelTransform<SeaTunnelRow> transform = plugins.get(i);
```
##########
seatunnel-engine/seatunnel-engine-client/src/test/resources/batch_fakesource_to_file.conf:
##########
@@ -41,6 +41,12 @@ source {
}
transform {
+ Copy {
+ source_table_name = "fake"
+ result_table_name = "fake1"
+ src_field = "name"
+ dest_field = "name1"
+ }
}
Review Comment:
revert
##########
seatunnel-examples/seatunnel-flink-connector-v2-example/pom.xml:
##########
@@ -96,6 +96,13 @@
<scope>${flink.scope}</scope>
</dependency>
+ <dependency>
+ <groupId>org.apache.seatunnel</groupId>
+ <artifactId>seatunnel-transforms-v2</artifactId>
+ <version>${project.version}</version>
+ <scope>${flink.scope}</scope>
+ </dependency>
+
Review Comment:
revert
example module only run as your local env
##########
seatunnel-examples/seatunnel-flink-connector-v2-example/src/main/java/org/apache/seatunnel/example/flink/v2/SeaTunnelApiExample.java:
##########
@@ -31,7 +31,7 @@
public class SeaTunnelApiExample {
public static void main(String[] args) throws FileNotFoundException,
URISyntaxException, CommandException {
- String configurePath = args.length > 0 ? args[0] :
"/examples/fake_to_console.conf";
+ String configurePath = args.length > 0 ? args[0] :
"/examples/split_transform.conf";
Review Comment:
revert
##########
seatunnel-core/seatunnel-flink-starter/src/main/java/org/apache/seatunnel/core/starter/flink/execution/TransformV2ExecuteProcessor.java:
##########
@@ -0,0 +1,111 @@
+/*
+ * 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.seatunnel.core.starter.flink.execution;
+
+import org.apache.seatunnel.api.common.JobContext;
+import org.apache.seatunnel.api.table.type.SeaTunnelDataType;
+import org.apache.seatunnel.api.table.type.SeaTunnelRow;
+import org.apache.seatunnel.api.transform.SeaTunnelTransform;
+import org.apache.seatunnel.core.starter.exception.TaskExecuteException;
+import org.apache.seatunnel.plugin.discovery.PluginIdentifier;
+import
org.apache.seatunnel.plugin.discovery.seatunnel.SeaTunnelTransformPluginDiscovery;
+import org.apache.seatunnel.translation.flink.serialization.FlinkRowConverter;
+import org.apache.seatunnel.translation.flink.utils.TypeConverterUtils;
+
+import org.apache.seatunnel.shade.com.typesafe.config.Config;
+
+import com.google.common.collect.Lists;
+import org.apache.flink.api.common.functions.MapFunction;
+import org.apache.flink.api.common.typeinfo.TypeInformation;
+import org.apache.flink.streaming.api.datastream.DataStream;
+import org.apache.flink.types.Row;
+
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Collectors;
+
+public class TransformV2ExecuteProcessor extends
AbstractPluginExecuteProcessor<SeaTunnelTransform> {
+
+ private static final String PLUGIN_TYPE = "transform";
+
+ protected TransformV2ExecuteProcessor(List<URL> jarPaths, List<? extends
Config> pluginConfigs, JobContext jobContext) {
+ super(jarPaths, pluginConfigs, jobContext);
+ }
+
+ @Override
+ protected List<SeaTunnelTransform> initializePlugins(List<URL> jarPaths,
List<? extends Config> pluginConfigs, JobContext jobContext) {
+ SeaTunnelTransformPluginDiscovery transformV2PluginDiscovery = new
SeaTunnelTransformPluginDiscovery();
+ List<URL> pluginJars = new ArrayList<>();
+ List<SeaTunnelTransform> transforms = pluginConfigs.stream()
+ .map(transformConfig -> {
+ PluginIdentifier pluginIdentifier =
PluginIdentifier.of(ENGINE_TYPE, PLUGIN_TYPE,
transformConfig.getString(PLUGIN_NAME));
+ List<URL> pluginJarPaths =
transformV2PluginDiscovery.getPluginJarPaths(Lists.newArrayList(pluginIdentifier));
+ SeaTunnelTransform<?> seaTunnelTransform =
+
transformV2PluginDiscovery.createPluginInstance(pluginIdentifier);
+ jarPaths.addAll(pluginJarPaths);
+ seaTunnelTransform.prepare(transformConfig);
+ seaTunnelTransform.setJobContext(jobContext);
+ return seaTunnelTransform;
+ }).distinct().collect(Collectors.toList());
+ jarPaths.addAll(pluginJars);
+ return transforms;
+ }
+
+ @Override
+ public List<DataStream<Row>> execute(List<DataStream<Row>>
upstreamDataStreams) throws TaskExecuteException {
+ if (plugins.isEmpty()) {
+ return upstreamDataStreams;
+ }
+ DataStream<Row> input = upstreamDataStreams.get(0);
+ List<DataStream<Row>> result = new ArrayList<>();
+ for (int i = 0; i < plugins.size(); i++) {
+ try {
+ SeaTunnelTransform<Row> transform = plugins.get(i);
+ Config pluginConfig = pluginConfigs.get(i);
+ DataStream<Row> stream =
fromSourceTable(pluginConfig).orElse(input);
+ input = flinkTransformV2(transform, stream);
+ registerResultTable(pluginConfig, input);
+ result.add(input);
+ } catch (Exception e) {
+ throw new TaskExecuteException(
+ String.format("SeaTunnel transform task: %s execute
error", plugins.get(i).getPluginName()), e);
+ }
+ }
+ return result;
+ }
+
+ protected DataStream<Row> flinkTransformV2(SeaTunnelTransform transform,
DataStream<Row> stream) {
Review Comment:
```suggestion
protected DataStream<Row> flinkTransform(SeaTunnelTransform transform,
DataStream<Row> stream) {
```
##########
seatunnel-core/seatunnel-flink-starter/src/main/java/org/apache/seatunnel/core/starter/flink/execution/TransformV2ExecuteProcessor.java:
##########
@@ -0,0 +1,111 @@
+/*
+ * 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.seatunnel.core.starter.flink.execution;
+
+import org.apache.seatunnel.api.common.JobContext;
+import org.apache.seatunnel.api.table.type.SeaTunnelDataType;
+import org.apache.seatunnel.api.table.type.SeaTunnelRow;
+import org.apache.seatunnel.api.transform.SeaTunnelTransform;
+import org.apache.seatunnel.core.starter.exception.TaskExecuteException;
+import org.apache.seatunnel.plugin.discovery.PluginIdentifier;
+import
org.apache.seatunnel.plugin.discovery.seatunnel.SeaTunnelTransformPluginDiscovery;
+import org.apache.seatunnel.translation.flink.serialization.FlinkRowConverter;
+import org.apache.seatunnel.translation.flink.utils.TypeConverterUtils;
+
+import org.apache.seatunnel.shade.com.typesafe.config.Config;
+
+import com.google.common.collect.Lists;
+import org.apache.flink.api.common.functions.MapFunction;
+import org.apache.flink.api.common.typeinfo.TypeInformation;
+import org.apache.flink.streaming.api.datastream.DataStream;
+import org.apache.flink.types.Row;
+
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Collectors;
+
+public class TransformV2ExecuteProcessor extends
AbstractPluginExecuteProcessor<SeaTunnelTransform> {
+
+ private static final String PLUGIN_TYPE = "transform";
+
+ protected TransformV2ExecuteProcessor(List<URL> jarPaths, List<? extends
Config> pluginConfigs, JobContext jobContext) {
+ super(jarPaths, pluginConfigs, jobContext);
+ }
+
+ @Override
+ protected List<SeaTunnelTransform> initializePlugins(List<URL> jarPaths,
List<? extends Config> pluginConfigs, JobContext jobContext) {
+ SeaTunnelTransformPluginDiscovery transformV2PluginDiscovery = new
SeaTunnelTransformPluginDiscovery();
+ List<URL> pluginJars = new ArrayList<>();
+ List<SeaTunnelTransform> transforms = pluginConfigs.stream()
+ .map(transformConfig -> {
+ PluginIdentifier pluginIdentifier =
PluginIdentifier.of(ENGINE_TYPE, PLUGIN_TYPE,
transformConfig.getString(PLUGIN_NAME));
+ List<URL> pluginJarPaths =
transformV2PluginDiscovery.getPluginJarPaths(Lists.newArrayList(pluginIdentifier));
+ SeaTunnelTransform<?> seaTunnelTransform =
+
transformV2PluginDiscovery.createPluginInstance(pluginIdentifier);
+ jarPaths.addAll(pluginJarPaths);
+ seaTunnelTransform.prepare(transformConfig);
+ seaTunnelTransform.setJobContext(jobContext);
+ return seaTunnelTransform;
+ }).distinct().collect(Collectors.toList());
+ jarPaths.addAll(pluginJars);
+ return transforms;
+ }
+
+ @Override
+ public List<DataStream<Row>> execute(List<DataStream<Row>>
upstreamDataStreams) throws TaskExecuteException {
+ if (plugins.isEmpty()) {
+ return upstreamDataStreams;
+ }
+ DataStream<Row> input = upstreamDataStreams.get(0);
+ List<DataStream<Row>> result = new ArrayList<>();
+ for (int i = 0; i < plugins.size(); i++) {
+ try {
+ SeaTunnelTransform<Row> transform = plugins.get(i);
+ Config pluginConfig = pluginConfigs.get(i);
+ DataStream<Row> stream =
fromSourceTable(pluginConfig).orElse(input);
+ input = flinkTransformV2(transform, stream);
+ registerResultTable(pluginConfig, input);
+ result.add(input);
+ } catch (Exception e) {
+ throw new TaskExecuteException(
+ String.format("SeaTunnel transform task: %s execute
error", plugins.get(i).getPluginName()), e);
+ }
+ }
+ return result;
+ }
+
+ protected DataStream<Row> flinkTransformV2(SeaTunnelTransform transform,
DataStream<Row> stream) {
+ SeaTunnelDataType seaTunnelDataType =
TypeConverterUtils.convert(stream.getType());
+ transform.setTypeInfo(seaTunnelDataType);
+ TypeInformation rowTypeInfo =
TypeConverterUtils.convert(transform.getProducedType());
+ FlinkRowConverter transformInputRowConverter = new
FlinkRowConverter(seaTunnelDataType);
+ FlinkRowConverter transformOutRowConverter = new
FlinkRowConverter(transform.getProducedType());
Review Comment:
```suggestion
FlinkRowConverter transformOutputRowConverter = new
FlinkRowConverter(transform.getProducedType());
```
##########
seatunnel-core/seatunnel-flink-starter/src/main/java/org/apache/seatunnel/core/starter/flink/execution/TransformV2ExecuteProcessor.java:
##########
@@ -0,0 +1,111 @@
+/*
+ * 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.seatunnel.core.starter.flink.execution;
+
+import org.apache.seatunnel.api.common.JobContext;
+import org.apache.seatunnel.api.table.type.SeaTunnelDataType;
+import org.apache.seatunnel.api.table.type.SeaTunnelRow;
+import org.apache.seatunnel.api.transform.SeaTunnelTransform;
+import org.apache.seatunnel.core.starter.exception.TaskExecuteException;
+import org.apache.seatunnel.plugin.discovery.PluginIdentifier;
+import
org.apache.seatunnel.plugin.discovery.seatunnel.SeaTunnelTransformPluginDiscovery;
+import org.apache.seatunnel.translation.flink.serialization.FlinkRowConverter;
+import org.apache.seatunnel.translation.flink.utils.TypeConverterUtils;
+
+import org.apache.seatunnel.shade.com.typesafe.config.Config;
+
+import com.google.common.collect.Lists;
+import org.apache.flink.api.common.functions.MapFunction;
+import org.apache.flink.api.common.typeinfo.TypeInformation;
+import org.apache.flink.streaming.api.datastream.DataStream;
+import org.apache.flink.types.Row;
+
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Collectors;
+
+public class TransformV2ExecuteProcessor extends
AbstractPluginExecuteProcessor<SeaTunnelTransform> {
+
+ private static final String PLUGIN_TYPE = "transform";
+
+ protected TransformV2ExecuteProcessor(List<URL> jarPaths, List<? extends
Config> pluginConfigs, JobContext jobContext) {
+ super(jarPaths, pluginConfigs, jobContext);
+ }
+
+ @Override
+ protected List<SeaTunnelTransform> initializePlugins(List<URL> jarPaths,
List<? extends Config> pluginConfigs, JobContext jobContext) {
+ SeaTunnelTransformPluginDiscovery transformV2PluginDiscovery = new
SeaTunnelTransformPluginDiscovery();
Review Comment:
```suggestion
SeaTunnelTransformPluginDiscovery transformPluginDiscovery = new
SeaTunnelTransformPluginDiscovery();
```
##########
seatunnel-examples/seatunnel-engine-examples/src/main/resources/examples/fake_to_console.conf:
##########
@@ -52,6 +52,12 @@ source {
}
transform {
+ Copy {
+ source_table_name = "fake"
+ result_table_name = "fake1"
+ src_field = "name"
+ dest_field = "name1"
+ }
Review Comment:
revert
--
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]