The query result schema printed by table.printSchema():
|-- deviceId: BIGINT
|-- channel: STRING
|-- schemaId: BIGINT
|-- productId: BIGINT
|-- schema: LEGACY('RAW', 'ANY<com.yunmo.iot.schema.Schema>')
bug when excuting table.toRetractStream[DeviceSchema].print(), exception throwed:
Exception in thread "main" org.apache.flink.table.api.ValidationException: Field types of query result and registered TableSink do not match.
Query schema: [deviceId: BIGINT, channel: STRING, schemaId: BIGINT, productId: BIGINT, schema: RAW('com.yunmo.iot.schema.Schema', ?)]
Sink schema: [deviceId: BIGINT, channel: STRING, schemaId: BIGINT, productId: BIGINT, schema: LEGACY('RAW', 'ANY<com.yunmo.iot.schema.Schema>')]
The com.yunmo.iot.schema.Schema is a generic type.
The schema field of Query schema change from LEGACY('RAW' to RAW, but the Sink schema still a LEGACY('RAW'
Unfortunately, the type system rework of Flink's Table & SQL API is not completed yet and maybe not all layers play nicely together. How did you define your data type? Are you mixing DataType
and the deprecated Types
? Using Types
consistently should solve the problem for now. Otherwise, feel free to open an issue on Flink's issue tracker.