Update nested field in BigQuery table

后端 未结 3 1881
醉话见心
醉话见心 2020-12-20 22:44

I am trying to perform what, you would think, is a trivial operation in BigQuery; I am trying to update a nested field in a BigQuery table that is the result of a 360 export

3条回答
  •  我在风中等你
    2020-12-20 23:14

    hits is an array, so you need to use an array subquery to assign to it. It would look something like this:

    #standardSQL
    UPDATE `dataset_name`.`ga_sessions_20170705`
    SET hits =
      ARRAY(
        SELECT AS STRUCT * REPLACE(
          (SELECT AS STRUCT eventInfo.* REPLACE('some string' AS eventLabel)) AS eventInfo)
        FROM UNNEST(hits)
      )
    WHERE TRUE;
    

提交回复
热议问题