Loading repeated fields in GBQ by importing a JSON file
By importing a JSON file with repeated records in BigQuery, you can create a table with nested repeated fields.
For example, for the schema:
[
{"type":"STRING", "name":"item"},
{"type":"RECORD", "name":"click", "mode":"REPEATED", "fields": [{"type":"TIMESTAMP", "name":"click_time"}, {"type":"STRING", "name":"userid"}]
}
]
you can load in a JSON file of clicks on an item, with clicks repeated for each item. The table would have fields item
, click.click_time
, and click.userid
.
My question
Say you have a CSV file that has flattened the above JSON item-clicks, with one row per click, but repeated values for click
and item
. Can you load this into GBQ and convert it, with a GBQ query, to the equivalent table that you would have if you had loaded the JSON file with repeated fields?
The table resulting from the GBQ query on the imported CSV table should have item, click.click_time
, click.userid
as fields.