【发布时间】:2020-07-15 11:06:42
【问题描述】:
相同的实例 ID 和项目 ID 可以以不同的时间序列重复任意次数。我正在尝试一个 select 语句,它将为每一行返回一个值(无 cartestian 产品)
输出喜欢
InstanceId ProjectId Time
2763333 manage-x 10:30
2763333 manage-x 11:30
2763334 manage-y 10:30
因为这是一个记录类型,所以我试过这个表名是metric
select res.value from metric,unnest(resource.labels) as res where res.key="instance_id"
这给了我 2763339646023081 的正确值
现在我想在同一个语句中获取 project_id,所以我需要一个类似于 sql 的相关子查询
select res.value from metric,unnest(resource.labels) as res,(select proj.value from metric,unnest(resource.labels) as proj where proj.key="project_id" and this part i need help to refer the res.value(instance_id) from the outer query to match to the corresponding instance for the project_id in the inner query)) where res.key="instance_id"
所以如上所示,我不确定如何在内部子查询中引用 instance_id 来获取相应的 project_id,我对 BigQuery 很陌生,我尝试了各种连接组合,但它不起作用并给了我 cartestian 产品.请提出您的建议和帮助。谢谢
【问题讨论】:
-
谁能帮助解决这个问题?谢谢
标签: sql google-bigquery