Got it. I'm not sure why you mentioned ResolvedSchema in the first place,
usually in the Table API you work with RowType / RowData.

- For Avro I use AvroSchemaConverter.convertToSchema method to get an Avro
schema from a RowType, then
use org.apache.flink.formats.avro.RowDataToAvroConverters to serialize
RowData as Avro's GenericRecord.
- For JSON you can create
org.apache.flink.formats.json.JsonRowDataSerializationSchema that takes
RowType as a parameter, then serialize RowData as a JSON payload.
- I haven't used Protobuf with Flink, but it looks like Flink 1.16 added
quite a bit of support for Protobuf. It seems like you can similarly
create org.apache.flink.formats.protobuf.serialize.PbRowDataSerializationSchema
that takes RowType as a parameter, then serialize RowData as a Protobuf
payload.

On Tue, Nov 8, 2022 at 7:47 AM Theodor Wübker <theo.wueb...@inside-m2m.de>
wrote:

> Hey,
>
> yes I have. I actually use these packages as well. However I am quite new
> to Flink and the Flink Type system in the Table API. Me searching these
> packages did not result in anything. My understanding of especially
> Protobuf is also not great, so its very possible I missed something
> (possibly a complex way of doing it). I am relatively certain though that
> there is nothing that does the trick as straightforward as there is for
> Avro with AvroSchemaConverter in the flink-avro package.
>
> -Theo
>
> On 8. Nov 2022, at 16:34, Yaroslav Tkachenko <yaros...@goldsky.com> wrote:
>
> Hey Theo, have you looked at the flink-json and flink-protobuf packages?
>
> On Tue, Nov 8, 2022 at 5:21 AM Theodor Wübker <theo.wueb...@inside-m2m.de>
> wrote:
>
>> Hello,
>>
>> I have a streaming use case, where I execute a query on a Table. I take
>> the ResolvedSchema of the table and convert it to an Avro-Schema using the
>> AvroSchemaConverter. Now I want to do the same for JSON and Protobuf.
>> However, it seems there is nothing similar to AvroSchemaConverter - I
>> wonder if I have to code the Mapping of Flinks DataType to JSON and
>> Protobuf myself now, or if I missed something. I would be glad if someone
>> could point me in the right direction here.
>>
>> Yours sincerely,
>> Theo
>
>
>

Reply via email to