在BigQuery上连接嵌套字段的值

Gil*_*zan 4 google-bigquery

我有以下架构:

[
   {
        'name': 'id',
        'type': 'INTEGER' 
   }
   {
        'name': 'record',
        'type': 'RECORD',
        'fields': [
            {
                'name': 'repeated',
                'type': 'STRING',
                'mode': 'REPEATED'
            }
         ]
   }
]
Run Code Online (Sandbox Code Playgroud)

以下数据:

+--------------------+
|id??|record.repeated|
+--------------------+
|1???|'a'????????????|
|????|'b'????????????|
|????|'c'????????????|
+--------------------+
|2???|'a'????????????|
|????|'c'????????????|
+--------------------+
|3???|'d'????????????|
+--------------------+
Run Code Online (Sandbox Code Playgroud)

我需要的是创建一个返回此的查询:

+--------------------+
|id??|record.repeated|
+--------------------+
|1???|'a,b,c'????????|
+--------------------+
|2???|'a,c'??????????|
+--------------------+
|3???|'d'????????????|
+--------------------+
Run Code Online (Sandbox Code Playgroud)

换句话说,我需要查询,允许我使用分隔符(在本例中为逗号)连接嵌套字段的值.类似于MySQL 的GROUP_CONCAT函数,但是在BigQuery上.

相关的想法:concat在sql中的所有列值

那可能吗?

谢谢.

Pen*_*m10 8

这很简单

select group_concat(record.repeated) from table
Run Code Online (Sandbox Code Playgroud)

publicdata的一个例子是

SELECT group_concat(payload.shas.encoded)
FROM [publicdata:samples.github_nested]
WHERE repository.url='https://github.com/dreamerslab/workspace'
Run Code Online (Sandbox Code Playgroud)