Skip to content

Commit f5fae21

Browse files
committed
fix(RecordAssembler): optimize field creation using Accessor (#3031)
1 parent ad5fb80 commit f5fae21

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

core/src/main/java/kafka/automq/table/process/RecordAssembler.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import org.apache.avro.SchemaNormalization;
2828
import org.apache.avro.generic.GenericData;
2929
import org.apache.avro.generic.GenericRecord;
30+
import org.apache.avro.util.internal.Accessor;
3031

3132
import java.util.ArrayList;
3233
import java.util.List;
@@ -145,7 +146,9 @@ private AssemblerSchema buildFinalAssemblerSchema() {
145146
List<Schema.Field> finalFields = new ArrayList<>(baseRecord.getSchema().getFields().size() + 3);
146147
Schema baseSchema = baseRecord.getSchema();
147148
for (Schema.Field field : baseSchema.getFields()) {
148-
finalFields.add(new Schema.Field(field, field.schema()));
149+
// Accessor keeps the original Schema instance (preserving logical types) while skipping default-value revalidation.
150+
Schema.Field f = Accessor.createField(field.name(), field.schema(), field.doc(), Accessor.defaultValue(field), false, field.order());
151+
finalFields.add(f);
149152
}
150153

151154
int baseFieldCount = baseSchema.getFields().size();

0 commit comments

Comments
 (0)