hailin0 commented on code in PR #3145:
URL: 
https://github.com/apache/incubator-seatunnel/pull/3145#discussion_r1003411850


##########
seatunnel-transforms-v2/src/main/java/org/apache/seatunnel/transform/CopyFieldTransform.java:
##########
@@ -0,0 +1,78 @@
+/*
+ * 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;
+
+import org.apache.seatunnel.api.table.type.SeaTunnelDataType;
+import org.apache.seatunnel.api.table.type.SeaTunnelRowType;
+import org.apache.seatunnel.api.transform.SeaTunnelTransform;
+import org.apache.seatunnel.transform.common.SeaTunnelRowAccessor;
+import org.apache.seatunnel.transform.common.SingleFieldOutputTransform;
+
+import org.apache.seatunnel.shade.com.typesafe.config.Config;
+
+import com.google.auto.service.AutoService;
+
+@AutoService(SeaTunnelTransform.class)
+public class CopyFieldTransform extends SingleFieldOutputTransform {
+
+    private static final String SRC_FIELD = "src_field";
+    private static final String DEST_FIELD = "dest_field";
+
+    private String srcField;
+    private int srcFieldIndex;
+    private SeaTunnelDataType srcFieldDataType;
+    private String destField;
+
+    @Override
+    public String getPluginName() {
+        return "Copy";
+    }
+
+    @Override
+    protected void setConfig(Config pluginConfig) {
+        if (!pluginConfig.hasPath(SRC_FIELD)) {
+            throw new IllegalArgumentException("The configuration missing key: 
" + SRC_FIELD);
+        }
+        if (!pluginConfig.hasPath(DEST_FIELD)) {
+            throw new IllegalArgumentException("The configuration missing key: 
" + DEST_FIELD);
+        }
+        this.srcField = pluginConfig.getString(SRC_FIELD);
+        this.destField = pluginConfig.getString(DEST_FIELD);
+    }
+
+    @Override
+    protected void setInputRowType(SeaTunnelRowType inputRowType) {
+        srcFieldIndex = inputRowType.indexOf(srcField);
+        srcFieldDataType = inputRowType.getFieldType(srcFieldIndex);
+    }
+
+    @Override
+    protected String getOutputFieldName() {
+        return destField;
+    }
+
+    @Override
+    protected SeaTunnelDataType getOutputFieldDataType() {
+        return srcFieldDataType;
+    }
+
+    @Override
+    protected Object getOutputFieldValue(SeaTunnelRowAccessor inputRow) {
+        return inputRow.getField(srcFieldIndex);

Review Comment:
   
https://github.com/apache/incubator-seatunnel/blob/dev/seatunnel-api/src/main/java/org/apache/seatunnel/api/table/type/SeaTunnelRowType.java#L85



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