Hi wanglei,

Yes, your observation is correct. Currently the type derivation relies on
legacy types, which only support (38, 18) as decimal precisions.

wangl...@geekplus.com.cn <wangl...@geekplus.com.cn> 于2020年4月16日周四 下午6:54写道:

>
> 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)
>
> ------------------------------
> wangl...@geekplus.com.cn
>
>
> *From:* Benchao Li <libenc...@gmail.com>
> *Date:* 2020-04-16 16:56
> *To:* wangl...@geekplus.com.cn
> *CC:* user <user@flink.apache.org>
> *Subject:* Re: FlinkSQL query error when specify json-schema.
> 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.
>
> wangl...@geekplus.com.cn <wangl...@geekplus.com.cn> 于2020年4月16日周四
> 下午4:21写道:
>
>>
>> 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
>>
>> ------------------------------
>> wangl...@geekplus.com.cn
>>
>>
>
> --
>
> Benchao Li
> School of Electronics Engineering and Computer Science, Peking University
> Tel:+86-15650713730
> Email: libenc...@gmail.com; libenc...@pku.edu.cn
>
>

-- 

Benchao Li
School of Electronics Engineering and Computer Science, Peking University
Tel:+86-15650713730
Email: libenc...@gmail.com; libenc...@pku.edu.cn

Reply via email to