请教这种数据格式怎么配置event time呢

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

请教这种数据格式怎么配置event time呢

nobleyd
CREATE TABLE user_log
(
    d MAP<STRING, STRING>,
    process_time AS PROCTIME(),
    event_time AS
TO_TIMESTAMP(FROM_UNIXTIME(COALESCE(d['server_time'], 0) / 1000)),
    WATERMARK FOR event_time AS event_time - INTERVAL '60' SECOND
) WITH (
    'connector' = 'kafka',

     ...

);

如上,报错。貌似不支持这么玩。但是我的数据格式就是这样的,比如:

{

  "d": {

    "name": "abc",

    "age": 12

  }

}
Reply | Threaded
Open this post in threaded view
|

Re: 请教这种数据格式怎么配置event time呢

Jark
Administrator
报什么错?


On Tue, 17 Nov 2020 at 23:43, 赵一旦 <[hidden email]> wrote:

> CREATE TABLE user_log
> (
>     d MAP<STRING, STRING>,
>     process_time AS PROCTIME(),
>     event_time AS
> TO_TIMESTAMP(FROM_UNIXTIME(COALESCE(d['server_time'], 0) / 1000)),
>     WATERMARK FOR event_time AS event_time - INTERVAL '60' SECOND
> ) WITH (
>     'connector' = 'kafka',
>
>      ...
>
> );
>
> 如上,报错。貌似不支持这么玩。但是我的数据格式就是这样的,比如:
>
> {
>
>   "d": {
>
>     "name": "abc",
>
>     "age": 12
>
>   }
>
> }
>
Reply | Threaded
Open this post in threaded view
|

Re: 请教这种数据格式怎么配置event time呢

nobleyd
已解决。COALESCE函数调用那的类型问题。d['server_time']是String类型,后边0是数字。

Jark Wu <[hidden email]> 于2020年11月17日周二 下午11:48写道:

> 报什么错?
>
>
> On Tue, 17 Nov 2020 at 23:43, 赵一旦 <[hidden email]> wrote:
>
> > CREATE TABLE user_log
> > (
> >     d MAP<STRING, STRING>,
> >     process_time AS PROCTIME(),
> >     event_time AS
> > TO_TIMESTAMP(FROM_UNIXTIME(COALESCE(d['server_time'], 0) / 1000)),
> >     WATERMARK FOR event_time AS event_time - INTERVAL '60' SECOND
> > ) WITH (
> >     'connector' = 'kafka',
> >
> >      ...
> >
> > );
> >
> > 如上,报错。貌似不支持这么玩。但是我的数据格式就是这样的,比如:
> >
> > {
> >
> >   "d": {
> >
> >     "name": "abc",
> >
> >     "age": 12
> >
> >   }
> >
> > }
> >
>