You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@flink.apache.org by huang huang <le...@gmail.com> on 2020/12/17 06:01:30 UTC

Fwd: flink1.12.0中使用LISTAGG报错

---------- Forwarded message ---------
发件人: huang huang <le...@gmail.com>
Date: 2020年12月17日周四 下午12:47
Subject: flink1.12.0中使用LISTAGG报错
To: <us...@flink.apache.org>


各位好:

使用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 by: org.apache.calcite.sql.validate.SqlValidatorException: Aggregate
expression 'LISTAGG' must 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