CREATE OR REPLACE TEMP TABLE in a script error: “Exceeded rate limits: too many table update operations for this table.”

霸气de小男生 提交于 2021-02-08 11:31:25

问题


This script gives me an error after ~11 steps:

DECLARE steps INT64 DEFAULT 1;
LOOP 
  CREATE OR REPLACE TEMP TABLE countme AS (SELECT steps, 1 x, [1,2,3] y);
  SET steps = steps+1;
  IF steps=30 THEN LEAVE; END IF;
END LOOP;

Exceeded rate limits: too many table update operations for this table. For more information, see https://cloud.google.com/bigquery/troubleshooting-errors

Even if this is a temp table - what can I do instead?


回答1:


Instead of using a TEMP TABLE, hold the results on a temp variable with an array. You can even materialize it as the last step:

DECLARE steps INT64 DEFAULT 1;
DECLARE table_holder ARRAY<STRUCT<steps INT64, x INT64, y ARRAY<INT64>>>;

LOOP 
  SET table_holder = (
    SELECT ARRAY_AGG(
      STRUCT(steps, 1 AS x, [1,2,3] AS y))
    FROM (SELECT '')
  );
  SET steps = steps+1;
  IF steps=30 THEN LEAVE; END IF;
END LOOP;

CREATE TABLE temp.results
AS
SELECT *
FROM UNNEST(table_holder)


来源:https://stackoverflow.com/questions/59314389/create-or-replace-temp-table-in-a-script-error-exceeded-rate-limits-too-many

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!