org.apache.flink.table.api.ValidationException: Expected LocalReferenceExpression. Got: timestamp

编程入门 行业动态 更新时间:2024-10-07 22:28:05

org.apache.<a href=https://www.elefans.com/category/jswz/34/1769678.html style=flink.table.api.ValidationException: Expected LocalReferenceExpression. Got: timestamp"/>

org.apache.flink.table.api.ValidationException: Expected LocalReferenceExpression. Got: timestamp


情景:在设置滑动窗口时遇到的问题:Expected LocalReferenceExpression. Got: timestamp,详细代码如下:

Table table = tableEnv.fromDataStream(stream);
table
.window(Slide.over(lit(1).hours()).every(lit(5).minutes()).on(($("timestamp").rowtime()).as("ts")).as("w"))
.groupBy($("w"), $("itemId"))
.select($("itemId"), $("itemId").count().as("itemCount"), $("w").end().as("windowEnd"))
.window(Over.partitionBy($("windowEnd")).orderBy($("itemCount").desc()).as("row_num"))
.select($("itemId"), $("itemCount"), $("windowEnd"))
.where($("row_num").between(0, 3));

原因是:需要在定义表设置事件时间,在表API中不能设置事件时间。
原来代码修改为:

Table table = tableEnv.fromDataStream(stream,$("itemId"),$("timestamp").rowtime().as("ts"));
Table tableResult =table.window(Slide.over(lit(1).hours()).every(lit(5).minutes()).on($("ts")).as("w")).groupBy($("w"), $("itemId")).select($("itemId"), $("itemId").count().as("itemCount"), $("w").end().as("windowEnd")).window(Over.partitionBy($("windowEnd")).orderBy($("itemCount").desc()).as("rank")).select($("itemId"), $("itemCount"), $("windowEnd")).where($("row_num").between(0, 3));

更多推荐

org.apache.flink.table.api.ValidationException: Expected LocalReferenceExpressio

本文发布于:2024-02-14 11:31:11,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1763069.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:flink   table   org   apache   api

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!