相同的实例 ID 和项目 ID 可以以不同的时间序列重复任何次数。我正在尝试一个选择语句,它将为每一行返回一个值(无笛卡尔积)
输出像
InstanceId ProjectId Time
2763333 manage-x 10:30
2763333 manage-x 11:30
2763334 manage-y 10:30
因为这是一个记录类型,我试过这个表名是公制
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 产品。请提出您的建议和帮助。谢谢

