flink-user-zh mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From 111 <xingh...@163.com>
Subject Flink SQL 1.10中ROW_NUMBER的使用
Date Tue, 07 Apr 2020 05:07:19 GMT
HI,
我这边想要在滑动窗口之后做一个topN,于是就有下面的SQL:
-- 窗口聚合
create view window_v as
select
        member_id,
        category_id,
 HOP_END(ts, INTERVAL '10' SECOND, INTERVAL '30' MINUTE) as `time`,
        count(1) as c
from stream_t 
group by member_id, category_id, 
HOP(ts, INTERVAL '10' SECOND, INTERVAL '30' MINUTE);


-- 排序取top 20
SELECT
member_id,
        category_id,
        c,
        row_number() over (PARTITION BY member_id ORDER BY c) AS rn
FROM window_v;


但是执行异常:
Caused by: org.apache.flink.table.api.TableException: OVER windows' ordering in stream mode
must be defined on a time attribute. at org.apache.flink.table.planner.plan.nodes.physical.stream.StreamExecOverAggregate.translateToPlanInternal(StreamExecOverAggregate.scala:195)
at org.apache.flink.table.planner.plan.nodes.physical.stream.StreamExecOverAggregate.translateToPlanInternal(StreamExecOverAggregate.scala:56)
at org.apache.flink.table.planner.plan.nodes.exec.ExecNode$class.translateToPlan(ExecNode.scala:58)
我看官网的TOPN例子中,order by 后面也可以是long型。难道row_number不能作用在窗口结果上?
Best,Xinghalo
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message