Laissez-moi reproduire l'erreur avec un cas réel que j'ai reçu d'un coéquipier :
# create the table
CREATE TABLE temp.bucket_locations
AS
SELECT 'ASIA-EAST1' bucket_location
UNION ALL SELECT 'ASIA-NORTHEAST2' bucket_location;
#update several times
UPDATE temp.bucket_locations
SET bucket_location = "US"
WHERE UPPER(bucket_location) LIKE "US%";
UPDATE temp.bucket_locations
SET bucket_location = "TW"
WHERE UPPER(bucket_location) LIKE "ASIA-EAST1%";
UPDATE temp.bucket_locations
SET bucket_location = "JP"
WHERE UPPER(bucket_location) LIKE "ASIA-NORTHEAST1%";
UPDATE temp.bucket_locations
SET bucket_location = "HK"
WHERE UPPER(bucket_location) LIKE "ASIA-EAST2%";
UPDATE temp.bucket_locations
SET bucket_location = "JP"
WHERE UPPER(bucket_location) LIKE "ASIA-NORTHEAST2%";
UPDATE temp.bucket_locations
SET bucket_location = "KR"
WHERE UPPER(bucket_location) LIKE "ASIA-NORTHEAST3%";
UPDATE temp.bucket_locations
SET bucket_location = "IN"
WHERE UPPER(bucket_location) LIKE "ASIA-SOUTH1%";
UPDATE temp.bucket_locations
SET bucket_location = "SG"
WHERE UPPER(bucket_location) LIKE "ASIA-SOUTHEAST1%";
UPDATE temp.bucket_locations
SET bucket_location = "AU"
WHERE UPPER(bucket_location) LIKE "AUSTRALIA%";
UPDATE temp.bucket_locations
SET bucket_location = "FI"
WHERE UPPER(bucket_location) LIKE "EUROPE-NORTH1%";
UPDATE temp.bucket_locations
SET bucket_location = "BE"
WHERE UPPER(bucket_location) LIKE "EUROPE-WEST1%";
UPDATE temp.bucket_locations
SET bucket_location = "GB"
WHERE UPPER(bucket_location) LIKE "EUROPE-WEST2%";
UPDATE temp.bucket_locations
SET bucket_location = "DE"
WHERE UPPER(bucket_location) LIKE "EUROPE-WEST3%";
UPDATE temp.bucket_locations
SET bucket_location = "NL"
WHERE UPPER(bucket_location) LIKE "EUROPE-WEST4%";
UPDATE temp.bucket_locations
SET bucket_location = "CH"
WHERE UPPER(bucket_location) LIKE "EUROPE-WEST6%";
UPDATE temp.bucket_locations
SET bucket_location = "CA"
WHERE UPPER(bucket_location) LIKE "NORTHAMERICA%";
UPDATE temp.bucket_locations
SET bucket_location = "BR"
WHERE UPPER(bucket_location) LIKE "SOUTHAMERICA%";
Dépassement des limites de débit : trop d'opérations de mise à jour de la table pour cette table
La solution dans ce cas est d'éviter de faire autant de mises à jour. Au lieu de cela, nous pouvons en faire une seule, en combinant tous les mappings ensemble :
CREATE TEMP TABLE `mappings`
AS
SELECT *
FROM UNNEST(
[STRUCT('US' AS abbr, 'US%' AS long), ('TW', 'ASIA-EAST1%'), ('JP', 'ASIA-NORTHEAST2%'
# add mappings
)]);
UPDATE temp.bucket_locations
SET bucket_location = abbr
FROM mappings
WHERE UPPER(bucket_location) LIKE long