当使用BigQuery Merge操作时,DELETE子句可能会导致查询大小扩大的问题。以下是一些解决方法:
-- 创建临时表
CREATE TEMPORARY TABLE temp_table AS
SELECT *
FROM your_table
WHERE condition_to_delete;
-- 执行Merge操作
MERGE your_table t
USING temp_table s
ON t.key_column = s.key_column
WHEN MATCHED THEN DELETE;
MERGE your_table t
USING (
SELECT key_column
FROM your_table
WHERE condition_to_delete
) s
ON t.key_column = s.key_column
WHEN MATCHED THEN DELETE;
DECLARE delete_count INT64 DEFAULT 1;
LOOP
DELETE FROM your_table
WHERE condition_to_delete
LIMIT delete_count;
IF ROW_COUNT() = 0 THEN
BREAK;
END IF;
END LOOP;
以上是一些解决"BigQuery Merge - DELETE子句导致查询大小扩大"问题的方法。根据具体情况选择合适的解决方法,以减小查询的大小。