【发布时间】:2016-10-04 05:57:07
【问题描述】:
我想为我的表(在 Google BigQuery 中)中的每个用户选择不同的列值。我考虑过使用ARRAY_AGG(),比如:
SELECT user_id, ARRAY_AGG(DISTINCT field1) AS f1, ARRAY_AGG(DISTINCT field2) AS f2
FROM t GROUP BY user_id
但是因为对于某些 user_ids,field1 或 field2 中的所有值都为空,我收到此错误消息:Array 'f1' cannot have a null element
我想知道是否有一种解决方法可以避免此错误,或者是否有其他方法可以在不使用 ARRAY_AGG() 的情况下获得结果
【问题讨论】:
-
您可能还对code.google.com/p/google-bigquery/issues/detail?id=587 感兴趣(它也适用于
ARRAY_AGG)。我在该功能上取得了一些进展,但还没有任何要宣布的内容。
标签: sql google-bigquery