带有相关子查询的bigquery MERGE DML

时间:2018-10-18 10:02:17

标签: google-bigquery

是否可以使用bigQuery中的MERGE DML进行相关查询(MERGE中WHEN子句之一内的子查询)?

举例来说,请参阅下面的“我在谷歌搜索未匹配的合并时发现合并”的查询。请注意WHEN子句中的两个SELECTS:

 <dependency>
<groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf</artifactId>
 </dependency>

 <dependency>
<groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf-spring4</artifactId>
</dependency>

该如何在bigQuery中完成?是否需要根据我上面的查询进行修改? 我目前得到: MERGE Target1 AS T USING Source1 AS S ON (T.label_id = S.label_id) WHEN NOT MATCHED BY TARGET AND S.project_name IN (SELECT DISTINCT(project_name) FROM Source1) THEN INSERT(attr1, attr2) VALUES(S.attr1, S.attr2) WHEN MATCHED THEN UPDATE SET T.attr1 = S.attr1 WHEN NOT MATCHED BY SOURCE AND T.project_name IN (SELECT DISTINCT(project_name) FROM Source1) THEN DELETE ;

1 个答案:

答案 0 :(得分:2)

很遗憾,BigQuery的WHEN子句are not supported for MERGE statements中的子查询。

有一个feature request和一个similar scenario和一个workaround可能对您有帮助。