rahil-c commented on code in PR #14355:
URL: https://github.com/apache/hudi/pull/14355#discussion_r2590992645
##########
hudi-flink-datasource/hudi-flink/src/main/java/org/apache/hudi/table/format/FormatUtils.java:
##########
@@ -55,13 +56,13 @@ private FormatUtils() {
public static GenericRecord buildAvroRecordBySchema(
IndexedRecord record,
- Schema requiredSchema,
+ HoodieSchema requiredSchema,
int[] requiredPos,
GenericRecordBuilder recordBuilder) {
- List<Schema.Field> requiredFields = requiredSchema.getFields();
+ List<HoodieSchemaField> requiredFields = requiredSchema.getFields();
assert (requiredFields.size() == requiredPos.length);
Iterator<Integer> positionIterator = Arrays.stream(requiredPos).iterator();
- requiredFields.forEach(f -> recordBuilder.set(f, getVal(record,
positionIterator.next())));
+ requiredFields.forEach(f -> recordBuilder.set(f.name(), getVal(record,
positionIterator.next())));
Review Comment:
<img width="716" height="626" alt="Screenshot 2025-12-04 at 4 07 43 PM"
src="https://github.com/user-attachments/assets/2537a75b-6645-4846-8f2e-f7ca36e873c0"
/>
So we are unable to directly set using f.pos() since the api is protected
and does not allow to me to leverage it
```
[ERROR] Failed to execute goal
org.apache.maven.plugins:maven-compiler-plugin:3.13.0:compile (default-compile)
on project hudi-flink: Compilation failure
[ERROR]
/Users/rahil/workplace/hudi/hudi-flink-datasource/hudi-flink/src/main/java/org/apache/hudi/table/format/FormatUtils.java:[65,46]
no suitable method found for set(int,java.lang.Object)
[ERROR] method
org.apache.avro.generic.GenericRecordBuilder.set(java.lang.String,java.lang.Object)
is not applicable
[ERROR] (argument mismatch; int cannot be converted to
java.lang.String)
[ERROR] method
org.apache.avro.generic.GenericRecordBuilder.set(org.apache.avro.Schema.Field,java.lang.Object)
is not applicable
[ERROR] (argument mismatch; int cannot be converted to
org.apache.avro.Schema.Field)
[ERROR] method
org.apache.avro.generic.GenericRecordBuilder.set(int,java.lang.Object) is not
applicable
[ERROR] (set(int,java.lang.Object) has protected access in
org.apache.avro.generic.GenericRecordBuilder)
[ERROR]
```
However if we pass to `set` the `f.getAvroField()` under the hood it will
access the avro field position.
--
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]