我在 Jupyter Notebook 中使用 Trino 和 Hive。我想通过以下方式聚合一个表:
q = f"""
CREATE TABLE {aggregated_table} AS
WITH aggregated_data AS (
SELECT
id,
date,
-- Aggregate counts into JSON strings
json_format(
map_agg(column_A, COUNT(column_A))
) AS column_A_counts,
AVG(column_B) AS column_B_avg,
FIRST_VALUE(column_C) OVER (PARTITION BY id, date) AS column_C
FROM
{disaggregated_table}
GROUP BY
id, date
)
SELECT
*
FROM
aggregated_data
"""
%sql $q
我得到的错误是:
TrinoUserError(type=USER_ERROR, name=FUNCTION_NOT_FOUND, message="line ...: Unexpected parameters (map(varchar(5),bigint)) for function json_format. Expected: json_format(json)"
我该如何解决?