Skip to content

Commit b0b961f

Browse files
committed
Adapt to Iceberg 1.7.0 API changes
- RowDataUtil.clone() now requires FieldGetter[] parameter - PruneColumns now requires TypeWithSchemaVisitor.visit() Signed-off-by: Jiwon Park <jpark92@outlook.kr>
1 parent 6e5ba0a commit b0b961f

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

amoro-format-mixed/amoro-mixed-flink/amoro-mixed-flink-common/src/main/java/org/apache/amoro/flink/read/hybrid/reader/RowDataRecordFactory.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,12 @@
2929
class RowDataRecordFactory implements RecordFactory<RowData> {
3030
private final RowType rowType;
3131
private final TypeSerializer[] fieldSerializers;
32+
private final RowData.FieldGetter[] fieldGetters;
3233

3334
RowDataRecordFactory(RowType rowType) {
3435
this.rowType = rowType;
3536
this.fieldSerializers = createFieldSerializers(rowType);
37+
this.fieldGetters = createFieldGetters(rowType);
3638
}
3739

3840
static TypeSerializer[] createFieldSerializers(RowType rowType) {
@@ -41,6 +43,14 @@ static TypeSerializer[] createFieldSerializers(RowType rowType) {
4143
.toArray(TypeSerializer[]::new);
4244
}
4345

46+
static RowData.FieldGetter[] createFieldGetters(RowType rowType) {
47+
RowData.FieldGetter[] fieldGetters = new RowData.FieldGetter[rowType.getFieldCount()];
48+
for (int i = 0; i < rowType.getFieldCount(); i++) {
49+
fieldGetters[i] = RowData.createFieldGetter(rowType.getTypeAt(i), i);
50+
}
51+
return fieldGetters;
52+
}
53+
4454
@Override
4555
public RowData[] createBatch(int batchSize) {
4656
RowData[] arr = new RowData[batchSize];
@@ -57,6 +67,7 @@ public void clone(RowData from, RowData[] batch, int position) {
5767
// Clone method will allocate a new GenericRowData object
5868
// if the target object is NOT a GenericRowData.
5969
// So we should always set the clone return value back to the array.
60-
batch[position] = RowDataUtil.clone(from, batch[position], rowType, fieldSerializers);
70+
batch[position] =
71+
RowDataUtil.clone(from, batch[position], rowType, fieldSerializers, fieldGetters);
6172
}
6273
}

amoro-format-mixed/amoro-mixed-hive/src/main/java/org/apache/iceberg/parquet/AdaptHiveParquetSchemaUtil.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,9 @@ private static Schema convertInternal(
7979
public static MessageType pruneColumns(MessageType fileSchema, Schema expectedSchema) {
8080
// column order must match the incoming type, so it doesn't matter that the ids are unordered
8181
Set<Integer> selectedIds = TypeUtil.getProjectedIds(expectedSchema);
82-
return (MessageType) ParquetTypeVisitor.visit(fileSchema, new PruneColumns(selectedIds));
82+
return (MessageType)
83+
TypeWithSchemaVisitor.visit(
84+
expectedSchema.asStruct(), fileSchema, new PruneColumns(selectedIds));
8385
}
8486

8587
/**

0 commit comments

Comments
 (0)