Hi,这个是一个已知的bug[1],已经在1.13.1以及1.4版本修复了。
可以使用一下1.13.1试一下,1.4版本现在也正在投票中了,应该很快就会发布出来了。

[1] https://issues.apache.org/jira/browse/FLINK-19449

kcz <[email protected]> 于2021年9月22日周三 上午11:41写道:

> 如何使用才是正确的,求大佬帮看看
> behavior,next_bv 字段内容一直是保持一致的,无法得到自己想要的结果
>
>
> 发送的数据
> {
> &nbsp;&nbsp;"user_id":&nbsp;1,
> &nbsp;&nbsp;"item_id":&nbsp;1,
> &nbsp;&nbsp;"behavior":"pv1"
> }
> {
> &nbsp;&nbsp;"user_id":&nbsp;1,
> &nbsp;&nbsp;"item_id":&nbsp;1,
> &nbsp;&nbsp;"behavior":"pv2"
> }
>
>
>
>
>
>
> CREATE TABLE KafkaTable (
> &nbsp; `user_id` BIGINT,
> &nbsp; `item_id` BIGINT,
> &nbsp; `behavior` STRING,
> &nbsp; proctime as PROCTIME()
> ) WITH (
> &nbsp; 'connector' = 'kafka',
> &nbsp; 'topic' = 'user_behavior',
> &nbsp; 'properties.bootstrap.servers' = '',
> &nbsp; 'properties.group.id' = 'testGroup',
> &nbsp; 'scan.startup.mode' = 'earliest-offset',
> &nbsp; 'format' = 'json'
> );
>
>
>
> SELECT
>         user_id,
>         item_id,
>         behavior,
>         next_bv&nbsp;
> FROM
>         ( SELECT *, lag( behavior, 1 ) over ( PARTITION BY user_id ORDER
> BY proctime ) AS next_bv FROM KafkaTable ) t;



-- 

Best,
Benchao Li

回复