ddl array 创建问题求助

classic Classic list List threaded Threaded
2 messages Options
kcz
Reply | Threaded
Open this post in threaded view
|

ddl array 创建问题求助

kcz
源数据:
{
        "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&gt; of the 'event_time_line' field of the TableSource return type.
Reply | Threaded
Open this post in threaded view
|

Re: ddl array 创建问题求助

Benchao Li
Hi,

1. format.json-schema不需要写,可以去掉;
2. 此外event_time_line的类型应该是array<row<`count` int, rule_name varchar>>

出发 <[hidden email]> 于2020年4月10日周五 上午12:09写道:

> 源数据:
> {
>         "types": "pg",
>         "event_time_line": [{
>                         "count": 24,
>                         "rule_name": "你好24"
>                 },
>                 {
>                         "count": 25,
>                         "rule_name": "逆战好25"
>
>
>                 }
>         ]
> }
>
>
>
> DDL:
>
>
>
>
>
>
> CREATE TABLE sourceTable (
> &nbsp; &nbsp; 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:&nbsp;
>         {"types":{type:"string"}},{ "event_time_line": {type:"object",
> "properties":&nbsp;
>         {"rule_name": {type: "string"}},
> &nbsp; &nbsp; "count": {"type": "string"}}}}'
> );
>
>
>
> ERROR:
> table field 'event_time_line' does not match with the physical type
> ROW<`rule_name` STRING&gt; 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: [hidden email]; [hidden email]