ConeyLiu commented on code in PR #4577:
URL: https://github.com/apache/iceberg/pull/4577#discussion_r1008682913
##########
core/src/main/java/org/apache/iceberg/avro/BuildAvroProjection.java:
##########
@@ -107,13 +107,15 @@ public Schema record(Schema record, List<String> names,
Iterable<Schema.Field> s
field.name());
// Create a field that will be defaulted to null. We assign a unique
suffix to the field
// to make sure that even if records in the file have the field it is
not projected.
+ String fieldName = AvroSchemaUtil.makeCompatibleName(field.name());
Schema.Field newField =
new Schema.Field(
- field.name() + "_r" + field.fieldId(),
+ fieldName + "_r" + field.fieldId(),
AvroSchemaUtil.toOption(AvroSchemaUtil.convert(field.type())),
null,
JsonProperties.NULL_VALUE);
newField.addProp(AvroSchemaUtil.FIELD_ID_PROP, field.fieldId());
+ newField.addProp(AvroSchemaUtil.ICEBERG_FIELD_NAME_PROP, field.name());
Review Comment:
> Nit: Can we use fieldName here? (Actually prefer to rename to
'oldFieldName' if you don't mind.
This aligns the code in
https://github.com/apache/iceberg/blob/dbb8a404f6632a55acb36e949f0e7b84b643cede/core/src/main/java/org/apache/iceberg/avro/TypeToSchema.java#L110
> Also , do you know the significance of this property?
Actually, I don't know the true meaning. It seems the property is set, but
could not find any usage. Maybe for debugging or similar.
> Looks like in the other case its only set if the field name has been
changed, should we do that?
I do this in previously commit:
https://github.com/apache/iceberg/pull/4577/commits/d54148421d8740f6e792d1567e5c7fe610c12a48.
And changed by some comments and advice.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]