怎样使用unnest将json数组实现列转行

【详述】我page_log表的events列是json数组,怎样使用unnest将其一列转多行?
【背景】
建表语句:
CREATE TABLE IF NOT EXISTS page_log (
user_id string COMMENT “用户ID”,
events JSON COMMENT “事件列表”
)
DUPLICATE KEY(user_id)
COMMENT “”
DISTRIBUTED BY HASH(user_id)
PROPERTIES (
“replication_num” = “3”
);

样例数据:
INSERT INTO dwd_buried_log_page (events,user_id) VALUES
(’[{“event_id”: “anlipanliAdvancedSearch_ContentClick”, “item_id”: “4001919”, “item_index”: 1, “item_type”: “anlipanli”, “res_code”: 200, “sort_by”: “”, “ts”: 1691118512249}]’,‘1648179193459144863’),
(’[{“event_id”: “anlipanliAdvancedSearch_ContentClick”, “item_id”: “4001919”, “item_index”: 1, “item_type”: “anlipanli”, “res_code”: 200, “sort_by”: “”, “ts”: 1691118512249}]’,‘1648179193459144863’);

【是否存算分离】否
【StarRocks版本】2.5-stable
【集群规模】例如:3fe(1 follower+2observer)+5be(fe与be混部)
【机器信息】CPU虚拟核/内存/网卡,例如:48C/64G/万兆

SELECT user_id,
PARSE_JSON(UNNEST) AS event_json
FROM page_log,
UNNEST(CAST(PARSE_JSON(EVENTS) AS ARRAY)) AS UNNEST;

starrcoks中支持UNNEST吗?为什么我使用这个函数报错呢?

您使用的是什么版本的starrocks,支持这个函数的,请发下具体报错

楼主的例子我在 starrocks 3.2. 3.3 版本上可以建表和插入数据

但使用 @guanxiangyu 的查询语句报错如下:

starrocks 3.3 报错如下:

org.jkiss.dbeaver.model.sql.DBSQLException: SQL 错误 [1064] [42000]: Getting syntax error at line 4, column 39. Detail message: Unexpected input ‘)’, the most similar input is {’<’}.
at org.jkiss.dbeaver.model.impl.jdbc.exec.JDBCStatementImpl.executeStatement(JDBCStatementImpl.java:133)
at org.jkiss.dbeaver.ui.editors.sql.execute.SQLQueryJob.executeStatement(SQLQueryJob.java:614)
at org.jkiss.dbeaver.ui.editors.sql.execute.SQLQueryJob.lambda$2(SQLQueryJob.java:505)
at org.jkiss.dbeaver.model.exec.DBExecUtils.tryExecuteRecover(DBExecUtils.java:194)
at org.jkiss.dbeaver.ui.editors.sql.execute.SQLQueryJob.executeSingleQuery(SQLQueryJob.java:524)
at org.jkiss.dbeaver.ui.editors.sql.execute.SQLQueryJob.extractData(SQLQueryJob.java:976)
at org.jkiss.dbeaver.ui.editors.sql.SQLEditor$QueryResultsContainer.readData(SQLEditor.java:4155)
at org.jkiss.dbeaver.ui.controls.resultset.ResultSetJobDataRead.lambda$0(ResultSetJobDataRead.java:123)
at org.jkiss.dbeaver.model.exec.DBExecUtils.tryExecuteRecover(DBExecUtils.java:194)
at org.jkiss.dbeaver.ui.controls.resultset.ResultSetJobDataRead.run(ResultSetJobDataRead.java:121)
at org.jkiss.dbeaver.ui.controls.resultset.ResultSetViewer$ResultSetDataPumpJob.run(ResultSetViewer.java:5148)
at org.jkiss.dbeaver.model.runtime.AbstractJob.run(AbstractJob.java:115)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
Caused by: java.sql.SQLSyntaxErrorException: Getting syntax error at line 4, column 39. Detail message: Unexpected input ‘)’, the most similar input is {’<’}.
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:121)
at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122)
at com.mysql.cj.jdbc.StatementImpl.executeInternal(StatementImpl.java:767)
at com.mysql.cj.jdbc.StatementImpl.execute(StatementImpl.java:652)
at org.jkiss.dbeaver.model.impl.jdbc.exec.JDBCStatementImpl.execute(JDBCStatementImpl.java:330)
at org.jkiss.dbeaver.model.impl.jdbc.exec.JDBCStatementImpl.executeStatement(JDBCStatementImpl.java:131)
… 12 more