Hisoka-X commented on code in PR #5646:
URL: https://github.com/apache/seatunnel/pull/5646#discussion_r1411803677


##########
seatunnel-transforms-v2/src/main/java/org/apache/seatunnel/transform/common/AbstractMultiCatalogSupportTransform.java:
##########
@@ -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.seatunnel.transform.common;
+
+import org.apache.seatunnel.shade.com.typesafe.config.Config;
+
+import org.apache.seatunnel.api.common.PrepareFailException;
+import org.apache.seatunnel.api.configuration.ReadonlyConfig;
+import org.apache.seatunnel.api.table.catalog.CatalogTable;
+import org.apache.seatunnel.api.table.type.SeaTunnelDataType;
+import org.apache.seatunnel.api.table.type.SeaTunnelRow;
+import org.apache.seatunnel.api.transform.SeaTunnelTransform;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+public abstract class AbstractMultiCatalogSupportTransform
+        implements SeaTunnelTransform<SeaTunnelRow> {
+
+    protected List<CatalogTable> inputCatalogTables;
+
+    protected List<CatalogTable> outputCatalogTables;
+
+    protected Map<String, SeaTunnelTransform<SeaTunnelRow>> transformMap;
+
+    public AbstractMultiCatalogSupportTransform(
+            List<CatalogTable> inputCatalogTables, ReadonlyConfig config) {
+        this.inputCatalogTables = inputCatalogTables;
+        this.transformMap = new HashMap<>();
+        inputCatalogTables.forEach(
+                inputCatalogTable -> {
+                    String tableId = 
inputCatalogTable.getTableId().toTablePath().toString();
+                    transformMap.put(tableId, 
buildTransform(inputCatalogTable, config));
+                });
+
+        this.outputCatalogTables =
+                inputCatalogTables.stream()
+                        .map(
+                                inputCatalogTable -> {
+                                    String tableName =
+                                            
inputCatalogTable.getTableId().toTablePath().toString();
+                                    return 
transformMap.get(tableName).getProducedCatalogTable();
+                                })
+                        .collect(Collectors.toList());

Review Comment:
   This processing method contains serious potential problems. If there are 10 
tables in the upstream, but only one of the tables is need be transformed, the 
job will report an error because the transform of the remaining 9 tables cannot 
be constructed normally, there is no corresponding configuration, and it stands 
to reason that the transforms of the remaining 9 tables should not be 
constructed, because no modifications have been made at all. We should not 
foreach the upstream catalogtables, but foreach the user's transform 
configuration.



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