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 "marble.zhong@coinflex.com.INVALID" <ma...@coinflex.com.INVALID> on 2020/09/24 07:33:01 UTC

A group window expects a time attribute for grouping in a stream environment.

hi, 

在用table window时报下面的exception, 需要在groupBy里增加什么吗? window W已经指定的proctime字段pt了。
报Exception, Caused by: org.apache.flink.table.api.ValidationException: A
group window expects a time attribute for grouping in a stream environment.

Table outTable = tEnv.from(tableName)
                .select($("marketId"), $("midPrice"), $("spotPrice"),
$("pt"))
               
.window(Slide.over(lit(intervals).minutes()).every(lit(1).second()).on($("pt")).as("w"))
                .groupBy($("marketId"), $("w"))
                .select($("marketId"),
                       
($("midPrice").dividedBy($("spotPrice"))).avg().as("price"));

Schema的定义是这样,
tEnv.connect(getPulsarDescriptor(inTopic))
                .withSchema( new Schema()
                        .field("marketId", DataTypes.BIGINT())
                        .field("midPrice", DataTypes.DECIMAL(38,18))
                        .field("spotPrice", DataTypes.DECIMAL(38,18))
                        .field("lastUpdated", DataTypes.BIGINT())
                        .field("pt", DataTypes.TIMESTAMP(3)).proctime()
                        )
                .inAppendMode()
                .createTemporaryTable(tableName);

谢谢



--
Sent from: http://apache-flink.147419.n8.nabble.com/