I am having hard time parsing data from BigQuery in column format for analysis, help is really appreciated.
I have user_detail table with following schema
| Field Name | Type | Mode | Description |
|---|---|---|---|
| user_id | INTEGER | NULLABLE | |
| user_names | STRING | NULLABLE | {"dl":"512"} |
I have following sample data in this table
| user_id | user_names |
|---|---|
| 12829 | [{"_id":{"$oid":"5d650676af82eb0a30737e74"},"_type":"UserName","capture_date":{"$date":"2019-08-27T00:00:00.000+0000"},"source":"google","name1":"John","name3":"Doe","name4":"D/O Jane Doe","gender":"1","dob":{"$date":"1986-07-10T00:00:00.000+0000"}}] |
I want to get the data in following tabular format
select user_id, source, name1, name3
I have tried unnest operator but apparently because user_names column is in string format, I am not able to get it as it is not in array format (Values referenced in FROM clause must be arrays. user_names has type STRING at [5:10])
Can you please help me how can I accomplish this?