I have a problem with BigQuery syntax that I\'m a bit stuck on. I have an entry in a table that has multiple key value pairs as an array and I would like to update only a single
Below is for BigQuery Standard SQL
See corrected version of very yours code
SET
event_params = ARRAY(
SELECT AS STRUCT * REPLACE(
CASE WHEN event_param.key = 'programName' THEN
(SELECT AS STRUCT * REPLACE('anonymous' AS string_value) FROM UNNEST([value]))
ELSE value
END AS value
)
FROM UNNEST(event_params) AS event_param
)
Also, note - you can remove reference to event_param
as in below example
SET
event_params = ARRAY(
SELECT AS STRUCT * REPLACE(
CASE WHEN key = 'programName' THEN
(SELECT AS STRUCT * REPLACE('anonymous' AS string_value) FROM UNNEST([value]))
ELSE value
END AS value
)
FROM UNNEST(event_params)
)