You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-zh@flink.apache.org by 出发 <57...@qq.com> on 2020/04/09 12:34:36 UTC
ddl array 创建问题求助
源数据:
{
"types": "pg",
"event_time_line": [{
"count": 24,
"rule_name": "你好24"
},
{
"count": 25,
"rule_name": "逆战好25"
}
]
}
DDL:
CREATE TABLE sourceTable (
types varchar,
event_time_line ROW (
`rule_name` VARCHAR,
`count` VARCHAR
),
proctime AS PROCTIME ()
) WITH (
'connector.type' = 'kafka',
'connector.version' = 'universal',
'connector.startup-mode' = 'earliest-offset',
'connector.topic' = 'topic_test_1',
'connector.properties.zookeeper.connect' = 'localhost:2181',
'connector.properties.bootstrap.servers' = 'localhost:9092',
'update-mode' = 'append',
'format.type' = 'json',
'format.derive-schema' = 'true',
'format.json-schema' = '{type: "object", properties:
{"types":{type:"string"}},{ "event_time_line": {type:"object", "properties":
{"rule_name": {type: "string"}},
"count": {"type": "string"}}}}'
);
ERROR:
table field 'event_time_line' does not match with the physical type ROW<`rule_name` STRING> of the 'event_time_line' field of the TableSource return type.
Re: ddl array 创建问题求助
Posted by Benchao Li <li...@gmail.com>.
Hi,
1. format.json-schema不需要写,可以去掉;
2. 此外event_time_line的类型应该是array<row<`count` int, rule_name varchar>>
出发 <57...@qq.com> 于2020年4月10日周五 上午12:09写道:
> 源数据:
> {
> "types": "pg",
> "event_time_line": [{
> "count": 24,
> "rule_name": "你好24"
> },
> {
> "count": 25,
> "rule_name": "逆战好25"
>
>
> }
> ]
> }
>
>
>
> DDL:
>
>
>
>
>
>
> CREATE TABLE sourceTable (
> types varchar,
> event_time_line ROW (
> `rule_name` VARCHAR,
> `count` VARCHAR
> ),
> proctime AS PROCTIME ()
> ) WITH (
> 'connector.type' = 'kafka',
> 'connector.version' = 'universal',
> 'connector.startup-mode' = 'earliest-offset',
> 'connector.topic' = 'topic_test_1',
> 'connector.properties.zookeeper.connect' = 'localhost:2181',
> 'connector.properties.bootstrap.servers' = 'localhost:9092',
> 'update-mode' = 'append',
> 'format.type' = 'json',
> 'format.derive-schema' = 'true',
> 'format.json-schema' = '{type: "object", properties:
> {"types":{type:"string"}},{ "event_time_line": {type:"object",
> "properties":
> {"rule_name": {type: "string"}},
> "count": {"type": "string"}}}}'
> );
>
>
>
> ERROR:
> table field 'event_time_line' does not match with the physical type
> ROW<`rule_name` STRING> of the 'event_time_line' field of the
> TableSource return type.
--
Benchao Li
School of Electronics Engineering and Computer Science, Peking University
Tel:+86-15650713730
Email: libenchao@gmail.com; libenchao@pku.edu.cn