AndrewJSchofield commented on code in PR #16159:
URL: https://github.com/apache/kafka/pull/16159#discussion_r1625791162


##########
connect/transforms/src/main/java/org/apache/kafka/connect/transforms/InsertField.java:
##########
@@ -208,25 +250,26 @@ private Schema makeUpdatedSchema(Schema schema) {
             builder.field(field.name(), field.schema());
         }
 
-        if (topicField != null) {
-            builder.field(topicField.name, topicField.optional ? 
Schema.OPTIONAL_STRING_SCHEMA : Schema.STRING_SCHEMA);
-        }
-        if (partitionField != null) {
-            builder.field(partitionField.name, partitionField.optional ? 
Schema.OPTIONAL_INT32_SCHEMA : Schema.INT32_SCHEMA);
-        }
-        if (offsetField != null) {
-            builder.field(offsetField.name, offsetField.optional ? 
Schema.OPTIONAL_INT64_SCHEMA : Schema.INT64_SCHEMA);
-        }
-        if (timestampField != null) {
-            builder.field(timestampField.name, timestampField.optional ? 
OPTIONAL_TIMESTAMP_SCHEMA : Timestamp.SCHEMA);
-        }
-        if (staticField != null) {
-            builder.field(staticField.name, staticField.optional ? 
Schema.OPTIONAL_STRING_SCHEMA : Schema.STRING_SCHEMA);
-        }
+        addField(topicField, builder, Schema.OPTIONAL_STRING_SCHEMA, 
Schema.STRING_SCHEMA);
+        addField(partitionField, builder, Schema.OPTIONAL_INT32_SCHEMA, 
Schema.INT32_SCHEMA);
+        addField(offsetField, builder, Schema.OPTIONAL_INT64_SCHEMA, 
Schema.INT64_SCHEMA);
+        addField(timestampField, builder, OPTIONAL_TIMESTAMP_SCHEMA, 
Timestamp.SCHEMA);
+        addField(staticField, builder, Schema.OPTIONAL_STRING_SCHEMA, 
Schema.STRING_SCHEMA);
+        addField(currentTimestampField, builder, OPTIONAL_TIMESTAMP_SCHEMA, 
Timestamp.SCHEMA);
 
         return builder.build();
     }
 
+    private void addField(InsertionSpec spec, SchemaBuilder builder, Schema 
optionalStringSchema, Schema stringSchema) {

Review Comment:
   The parameters `optionalStringSchema` and `stringSchema` are not necessarily 
string schemas. I suggest `optionalSchema` and `schema` would be more accurate.



##########
connect/transforms/src/test/java/org/apache/kafka/connect/transforms/InsertFieldTest.java:
##########
@@ -16,7 +16,21 @@
  */
 package org.apache.kafka.connect.transforms;
 
+import static org.junit.jupiter.api.Assertions.assertEquals;

Review Comment:
   Reordering the imports was not a necessary change. The previous ordering was 
consistent with the other related tests, so I would prefer this is reverted.



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