尝试运行此查询(mytable不是真实的表名):
遇到此错误:Cannot access field permission on a value with type ARRAY<STRUCT<resource STRING, permission STRING, granted BOOL, ...>> at [2:41]
当我预览表格时,它看起来像这样:
答案 0 :(得分:3)
从下面的模式中可以看到-#standardSQL
SELECT DISTINCT x.permission
FROM `your_table`,
UNNEST(protopayload_auditlog.authorizationInfo) x
LIMIT 10
是一个数组
因此,要访问数组元素,请先将其UNNEST删除,如下面的示例所示
#standardSQL
SELECT DISTINCT x.permission
FROM `your_table` t,
t.protopayload_auditlog.authorizationInfo x
LIMIT 10
结果为
注意:上述查询中UNNEST'ing的快捷方式是
how do I concat it to a comma separated string?
更新
#standardSQL SELECT ARRAY_TO_STRING(ARRAY(SELECT permission FROM t.protopayload_auditlog.authorizationInfo), ',') permissions FROM `your_table` t LIMIT 10
public class TaskManager {
static ExecutorService e = Executors.newFixedThreadPool(4);
private TaskManager(){
}
public static void addAsyncTask(AsyncTaskWrapper task){
e.submit(task);
}
}