I'm trying to flatten data from repeated fields in Big Query. I have had a look at this Querying multiple repeated fields in BigQuery, however I can't seem to get this to work.
My data looks like the following:
[
{
"visitorId": null,
"visitNumber": "15",
"device": {
"browser": "Safari (in-app)",
"browserVersion": "(not set)",
"browserSize": "380x670",
"operatingSystem": "iOS",
},
"hits": [
{
"isEntrance": "true",
"isExit": "true",
"referer": null,
"page": {
"pagePath": "/news/bla-bla-bla",
"hostname": "www.example.com",
"pageTitle": "Win tickets!!",
"searchKeyword": null,
"searchCategory": null,
"pagePathLevel1": "/news/",
"pagePathLevel2": "/bla-bla-bla",
"pagePathLevel3": "",
"pagePathLevel4": ""
},
"transaction": null
}
]
}
]
What I want is the fields in the hits-page repeated fields.
For instance i want to fetch the hits.page.pagePath (with the value "/news/bla-bla-bla")
I have tried with the following query, but i get an error:
SELECT
visitorId,
visitNumber,
device.browser,
hits.page.pagePath
FROM
`Project.Page`
LIMIT 1000
The error i'm getting is this
Error: Cannot access field page on a value with type ARRAY<STRUCT<hitNumber INT64, time INT64, hour INT64, ...>>