How to convert a Table to a DataStream containing array types (Flink)?

Viewed 391

I have issues concerning the table-api of Flink (1.13+). I have a POJO containing several fields, one of them being:

List<String> my_list; 

I create my table using the following declaration for this field:

"CREATE TABLE my_table (
   ...
   my_list ARRAY<STRING>,
   ...
)"

When I try to convert my table to DataStream using the toRetractStream[MY_POJO] method after, I got the following error:

Exception in thread "main" org.apache.flink.table.api.ValidationException: Column types of query result and sink for unregistered table do not match.

Cause: Incompatible types for sink column 'my_list' at position 11. Query schema: [..., my_list: ARRAY, ...] Sink schema: [..., my_list: RAW('java.util.List', ?), ...]

I would like to avoid mapping every fields by hand and keep the code clean, is there a solution to handle this kind of data types ?

1 Answers

I would recommend to try out the new API methods from/toDataStream and from/toChangelogStream. Those support all kinds of classes and data types.

toDataStream supports also mapping to POJOs with List members.

Related