Fwd: flink1.12.0中使用LISTAGG报错

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Fwd: flink1.12.0中使用LISTAGG报错

huang huang

---------- Forwarded message ---------
发件人: huang huang <[hidden email]>
Date: 2020年12月17日周四 下午12:47
Subject: flink1.12.0中使用LISTAGG报错
To: <[hidden email]>


各位好:

使用pyflink执行sql时,LISTAGG出现了错误

请问目前版本的LISTAGG不支持排序么,有人遇到过这种情况么?


FLINK版本:1.12.0


SQL代码:

SELECT
 session_id,
 LISTAGG(page_id, ',') WITHIN GROUP(ORDER BY action_time) as user_hit_log
 FROM user_action
 group by session_id

报错信息:


Caused byorg.apache.calcite.sql.validate.SqlValidatorExceptionAggregate expression 'LISTAGGmust not contain a within group clause

如果有写法不对,请指正,感谢!


根据查到的文档LISTAGG的用法,没看出来问题:

Listagg is an ordered set function, which require the within group clause to specify an order. The minimal syntax is:

LISTAGG(<expression>, <separator>) WITHIN GROUP(ORDER BY …)


参考链接:

https://ci.apache.org/projects/flink/flink-docs-stable/dev/table/functions/systemFunctions.html#aggregate-functions

https://modern-sql.com/feature/listagg