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 Caizhi Weng <ts...@gmail.com> on 2021/08/04 06:34:08 UTC
Re: flink table over 窗口报错
Hi!
order by 的字段是 f_time_bak,但是 watermark 的字段是 f_time,这两个不一致。
yanyunpeng <ya...@rockontrol.com> 于2021年8月4日周三 下午2:30写道:
> 代码如下:
> EnvironmentSettings bbSettings =
> EnvironmentSettings.newInstance().useBlinkPlanner().inBatchMode().build();
> TableEnvironment tableEnv = TableEnvironment.create(bbSettings);
> tableEnv.executeSql("CREATE TABLE t_yyp_test (\n" +
> " f_id INT,\n" +
> " f_h STRING,\n" +
> " f_l STRING,\n" +
> " f_j STRING,\n" +
> " f_value DOUBLE,\n" +
> " f_time TIMESTAMP(3)\n, " +
> " f_time_bak TIMESTAMP(3)\n, " +
> " PRIMARY KEY (f_id) NOT ENFORCED,\n" +
> " WATERMARK FOR f_time AS f_time \n" +
> ") WITH (\n" +
> " 'connector' = 'jdbc',\n" +
> " 'url' = 'jdbc:mysql://***',\n" +
> " 'table-name' = '123',\n" +
> " 'username' = '123',\n" +
> " 'password' = '123'\n" +
> ")");
> tableEnv.registerFunction("GaussianFunction", new GaussianFunction());
> Table table = tableEnv
> .from("t_yyp_test")
> .window(Over.partitionBy($("f_h"), $("f_l"), $("f_j"))
> .orderBy($("f_time_bak"))
> .preceding("unbounded_range")
> .following(CURRENT_RANGE)
> .as("w"))
> .select($("f_h"),
> $("f_l"),
> $("f_j"),
> $("f_value").avg().over($("w")),
> $("f_value").varPop().over($("w")),
> $("f_value").stddevPop().over($("w")));
>
>
> 已经定义了eventTime 使用eventTIme或者别的时间字段排序都报错
>
>
> Exception in thread "main" org.apache.flink.table.api.ValidationException:
> Ordering must be defined on a time attribute.
>
>
> 请问这是什么原因