I am trying to update the hits.page.pagePath field in the Google Analytics export in BigQuery, however i\'m unable to unnest the field using the method outlined in the docum
This should help get you started. You need to include everything else from hits
in order to perform the update, including the nested page
.
UPDATE `you_dataset.tablename`
SET hits = ARRAY(
SELECT AS STRUCT * REPLACE (
(SELECT AS STRUCT page.* REPLACE ('foo' AS pagePath)) AS page
)
FROM UNNEST(hits) as pagePath
)
WHERE fullVisitorID like "%1%"
Below is for BigQuery Standard SQL
UPDATE `project-name.datasetId.ga_sessions_yyyymmdd`
SET hits = ARRAY(
SELECT AS STRUCT * REPLACE(
(SELECT AS STRUCT *
REPLACE('Your New pagePath' AS pagePath)
FROM UNNEST([page])
) AS page)
FROM UNNEST(hits)
)
WHERE fullVisitorID like "%1%"
As you can see in above example you would replace pagePath with string 'Your New pagePath'
Of course in reality you would want to have some logic here - so replace that part to whatever logic you need - like for example you would need to UPPER whole string - you would use something like below
REPLACE(UPPER(pagePath) AS pagePath)