大家好,我这次遇到了一个新的组数组错误,我将与您共享我正在查询的表的架构,以便您可以告诉我解决方案。我尝试使用ARRAY_TO_STRING,但在这种情况下无法解决问题...
SELECT
individual_details.gender AS gender,
COUNT(DISTINCT profile.owner_id ) AS profile_count_distinct
FROM dataset.profile AS profile
LEFT JOIN UNNEST(profile.individual_details) as individual_details
GROUP BY 1
ORDER BY 2 DESC
UNNEST中引用的值必须是数组。 UNNEST包含表达式 类型为[5:18]的STRUCT类型
答案 0 :(得分:3)
individual_details
不是数组,而是STRUCT-因此您不需要它
尝试以下
SELECT
individual_details.gender AS gender,
COUNT(DISTINCT profile.owner_id ) AS profile_count_distinct
FROM dataset.profile AS profile
GROUP BY 1
ORDER BY 2 DESC