google-bigquery - 谷歌 bigquery 的 collect_set

标签 google-bigquery

嗨,我在任何地方都找不到这个。

如何在 Google BigQuery 中执行 collect_set?

我有一个已经用大查询编写的查询

选择 用户身份, 脚步, 从表

我需要将每个 user_id 的所有步骤放入一个数组中,就像 collect_set 那样。

最佳答案

尝试使用 NEST()功能:

SELECT user_id, NEST(steps) AS steps 
FROM table
GROUP BY user_id

有关如何使 NEST 能够写入表的一些技巧,请参见下文
BigQuery NEST() returns 'Error: An internal error occurred'

另一种选择是使用 GROUP_CONCAT 将步骤列表构建为字符串:

SELECT user_id, GROUP_CONCAT(steps) AS steps 
FROM table
GROUP BY user_id

关于google-bigquery - 谷歌 bigquery 的 collect_set,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36094892/

相关文章:

google-app-engine - BigQuery 无法通过 Google Cloud Storage 导入 Cloud Datastore 备份文件

google-cloud-platform - 部署云功能时谷歌Bigquery导入错误

sql - 对不在 GROUP BY 中的字段使用 IF 语句

firebase - 将数据从Firestore导入到bigQuery中

google-drive-api - 使用带Google表格的BigQuery API时"Encountered an error while globbing file pattern"错误

python - 既不是 GROUPED 也不是 AGGREGATED 的列 X - StandardSQL/BigQuery

mysql - Httparchive - BigQuery 如何获取 2010-2014 年每年的中位数 bytesTotal

google-bigquery - 在 BigQuery 中获取 "Query too large"

google-bigquery - 仪表板后端的 BigQuery 与 Cloud SQL

sql - 如何通过 BigQuery 中最近的时间戳加入?