Copilot commented on code in PR #9586:
URL: https://github.com/apache/seatunnel/pull/9586#discussion_r2218411818


##########
seatunnel-api/src/main/java/org/apache/seatunnel/api/table/catalog/MetadataSchema.java:
##########
@@ -0,0 +1,63 @@
+/*
+ * 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.api.table.catalog;
+
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Collectors;
+
+/** Represent a physical table schema. */

Review Comment:
   The comment is incorrect. This class represents a metadata schema, not a 
physical table schema. Update the comment to accurately reflect the purpose of 
MetadataSchema.
   ```suggestion
   /** Represents a metadata schema, which includes information about columns 
and their properties. */
   ```



##########
seatunnel-api/src/main/java/org/apache/seatunnel/api/table/catalog/AbstractSchema.java:
##########
@@ -0,0 +1,86 @@
+/*
+ * 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.api.table.catalog;
+
+import org.apache.seatunnel.api.table.type.SeaTunnelDataType;
+import org.apache.seatunnel.api.table.type.SeaTunnelRowType;
+
+import lombok.AccessLevel;
+import lombok.Data;
+import lombok.Getter;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.stream.Collectors;
+
+/** Represent a physical table schema. */
+@Data
+public class AbstractSchema implements Serializable {
+    private static final long serialVersionUID = 1L;
+    protected final List<Column> columns;
+
+    @Getter(AccessLevel.PRIVATE)
+    protected final List<String> columnNames;
+
+    public AbstractSchema(List<Column> columns) {
+        this.columns = columns;
+        this.columnNames = 
columns.stream().map(Column::getName).collect(Collectors.toList());
+    }
+
+    // Lombok requires a no-arg constructor for @Data annotation to work 
properly
+    private AbstractSchema() {
+        this.columns = new ArrayList<>();
+        this.columnNames = new ArrayList<>();
+    }
+

Review Comment:
   The private no-arg constructor is unnecessary. Lombok's @Data annotation can 
work without it when a parameterized constructor is present. Remove this 
constructor to simplify the code.
   ```suggestion
   
   ```



##########
seatunnel-transforms-v2/src/main/java/org/apache/seatunnel/transform/metadata/MetadataTransform.java:
##########
@@ -132,21 +124,13 @@ protected Column[] getOutputColumns() {
                                     null,
                                     null);
                     break;
-                case DELAY:
-                case EVENT_TIME:
-                    column =
-                            PhysicalColumn.of(
-                                    mappingFieldName,
-                                    BasicType.LONG_TYPE,
-                                    (Long) null,
-                                    null,
-                                    true,
-                                    null,
-                                    null);
-                    break;
                 default:
-                    throw TransformCommonError.cannotFindMetadataFieldError(
-                            getPluginName(), mappingFieldName);
+                    if (metadataSchema.contains(metadataFieldName)) {
+                        column = metadataSchema.getColumn(metadataFieldName);
+                    } else {
+                        throw 
TransformCommonError.cannotFindMetadataFieldError(
+                                getPluginName(), mappingFieldName);
+                    }

Review Comment:
   [nitpick] Consider extracting the metadata schema column lookup logic into a 
separate method to improve readability and reduce nesting in the switch 
statement.
   ```suggestion
                       column = getMetadataColumn(metadataFieldName, 
mappingFieldName);
   ```



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