CREATE TABLE user_log( `id` INT, `timestamp` BIGINT ) WITH ( 'connector.type' = 'kafka', 'connector.version' = 'universal', 'connector.topic' = 'wanglei_jsontest', 'connector.startup-mode' = 'latest-offset', 'connector.properties.0.key' = 'zookeeper.connect', 'connector.properties.0.value' = '172.19.78.32:2181', 'connector.properties.1.key' = 'bootstrap.servers', 'connector.properties.1.value' = '172.19.78.32:9092', 'update-mode' = 'append', 'format.type' = 'json', 'format.json-schema' = '{ "type": "object", "properties": { "id": {"type": "integer"}, "timestamp": {"type": "number"} } }' ); Then select * from user_log; org.apache.flink.table.api.ValidationException: Type INT of table field 'id' does not match with the physical type LEGACY('DECIMAL', 'DECIMAL') of the 'id' field of the TableSource return type. Seems the specified type "integer", "number" can not be mapped to INT, BIGINT How can i solve this problem? Thanks, Lei |
Hi wanglei, You don't need to specify 'format.json-schema', the format can derive schema from the DDL. Your exception above means the schema in 'format.json-schema' and DDL are not match.
Benchao Li School of Electronics Engineering and Computer Science, Peking University Tel:+86-15650713730 Email: [hidden email]; [hidden email] |
Thanks, I have tried. 'format.derive-schema' = 'true' will work. But if i insist to use format.json-schema, the CREATE TABLE must be writtten as: `id` DECIMAL (38,18), ` timestamp ` DECIMAL (38,18)
|
Hi wanglei, Yes, your observation is correct. Currently the type derivation relies on legacy types, which only support (38, 18) as decimal precisions.
Benchao Li School of Electronics Engineering and Computer Science, Peking University Tel:+86-15650713730 Email: [hidden email]; [hidden email] |
Free forum by Nabble | Edit this page |