You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by GitBox <gi...@apache.org> on 2020/12/07 15:31:14 UTC

[GitHub] [iceberg] pan3793 edited a comment on issue #1885: Flink Iceberg Usage

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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org