在非窗口化的表上使用窗口属性
At 2024-03-08 09:28:10, "[email protected]" <[email protected]> wrote:
>public static void main(String[] args) {
> StreamExecutionEnvironment env =
> StreamExecutionEnvironment.getExecutionEnvironment();
> StreamTableEnvironment tEnv = StreamTableEnvironment.create(env);
> List<Persion> list = new ArrayList<>();
> list.add(new Persion("Fred",35));
> list.add(new Persion("wilma",35));
> list.add(new Persion("Pebbles",2));
> DataStream<Persion> flintstones = env.fromCollection(list);
> Table table = tEnv.fromDataStream(flintstones);
> Table select = table.select($("name"), $("age"),
> $("addtime").proctime());
> Table select1 = select.window(
> Tumble.over(lit(10).second())
> .on($("addtime"))
> .as("w"))
> .groupBy($("name"), $("w"))
> .select($("name"), $("age").sum());
> select1.execute().print();
>
> }
>
> public static class Persion{
> public String name;
> public Integer age;
> public Persion(){}
> public Persion(String name,Integer age){
> this.name = name;
> this.age = age;
> }
> public String toString(){
> return this.name.toString()+":age "+this.age.toString();
> }
> }
>
>提示Exception in thread "main" org.apache.flink.table.api.ValidationException:
>Window properties can only be used on windowed tables
>是哪里错了?