Home > other >  Unnest a JSON array in as multiple rows - BigQuery
Unnest a JSON array in as multiple rows - BigQuery

Time:11-11

I have a table that looks like this

| id | title    |  metadata                                      |
| 1  | apples   | [{"tags": [200,211], "categories": [313,412]}] |
| 2  | oranges  | [{"tags": [311,112], "categories": [616,712]}] |

I want to unnest the metadata so the results is one row per tag

| id | title     |  tag |
| 1  | apples    |  200  | 
| 1  | apples    |  212  |
| 2  | oranges   |  313  |  
| 2  | oranges   |  112  |

I know I need to use enter image description here

  • Related