pan3793 edited a comment on issue #1885:
URL: https://github.com/apache/iceberg/issues/1885#issuecomment-739987048
I think I found the solution:
```
@Override
protected void output(DataStream<GenericRecord> outputStream,
org.apache.avro.Schema avroSchema) {
DataStream<Row> rowDataStream = outputStream.map(genericRecord -> {
int columnNum = genericRecord.getSchema().getFields().size();
Object[] rowData = new Object[columnNum];
for (int i = 0; i < columnNum; i++) {
rowData[i] = genericRecord.get(i);
}
return Row.of(rowData);
});
org.apache.iceberg.shaded.org.apache.avro.Schema shadeAvroSchema =
new
org.apache.iceberg.shaded.org.apache.avro.Schema.Parser().parse(avroSchema.toString());
Schema icebergSchema = AvroSchemaUtil.toIceberg(shadeAvroSchema);
RowType rowType = FlinkSchemaUtil.convert(icebergSchema);
TableSchema tableSchema = FlinkSchemaUtil.toSchema(rowType);
FlinkSink.forRow(rowDataStream, tableSchema);
}
```
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]