title: BigQuery: How do I add a field to a REPEATED record?
body: <p>I've got a table in Google BigQuery that consists of a few fields, then a REPEATED record which may contain one or more objects. I want to create a new table with an extra field in the REPEATED data, and copy my original data into the new table, populating the new field with the output of GENERATE_UUID() so there is one unique identifier per REPEATED line of data.</p>
  
  <p>I had a similar question at <a href="https://stackoverflow.com/questions/60303028/how-do-i-copy-from-one-bigquery-table-to-another-when-the-target-contains-repeat">How do I copy from one BigQuery Table to another when the target contains REPEATED fields?</a> but I don't know how to adapt this to fit my current use case.</p>
  
  <p>Here's my "new" Schema 1 (ie Schema 2 from the above link)</p>
  
  <pre><code>[
      {"name": "id", "type": "NUMERIC", "mode": "REQUIRED"},
      {"name": "name", "type": "STRING", "mode": "REQUIRED"},
      {"name": "created", "type": "TIMESTAMP", "mode": "REQUIRED"},
      {"name": "valid", "type": "BOOLEAN", "mode": "REQUIRED"},
      {"name": "parameters", "type": "RECORD", "mode": "REPEATED", "fields":
          [
              {"name": "parameter1", "type": "STRING", "mode": "REQUIRED"},
              {"name": "parameter2", "type": "FLOAT", "mode": "REQUIRED"},
              {"name": "parameter3", "type": "BOOLEAN", "mode": "REQUIRED"}
          ]
      }
  ]
  </code></pre>
  
  <p>and I'd like it to end up like this, Schema 2:</p>
  
  <pre><code>[
      {"name": "id", "type": "NUMERIC", "mode": "REQUIRED"},
      {"name": "name", "type": "STRING", "mode": "REQUIRED"},
      {"name": "created", "type": "TIMESTAMP", "mode": "REQUIRED"},
      {"name": "valid", "type": "BOOLEAN", "mode": "REQUIRED"},
      {"name": "parameters", "type": "RECORD", "mode": "REPEATED", "fields":
          [
              {"name": "uuid", "type": "STRING", "mode": "REQUIRED"},
              {"name": "parameter1", "type": "STRING", "mode": "REQUIRED"},
              {"name": "parameter2", "type": "FLOAT", "mode": "REQUIRED"},
              {"name": "parameter3", "type": "BOOLEAN", "mode": "REQUIRED"}
          ]
      }
  ]
  </code></pre>
  
  <p>So I've got my new table (Table 2) created with this Schema. I want to copy from Table 1, and I'm trying something like this:</p>
  
  <pre><code>insert into table2_with_uuid(id, name, created, valid, parameters)
  select id, name, created, valid,
  [(
  GENERATE_UUID(), parameters.parameter1, parameters.parameter2, parameters.parameter3
  )]
  from table1_no_guid;
  </code></pre>
  
  <p>This gives me an error saying: 
  <code>Cannot access field ceId on a value with type ARRAY&lt;STRUCT&lt;parameter1</code> (etc)</p>
  
  <p>Does anyone have any suggestions as to how to proceed? Thanks!</p>