In BigQuery
Table issue_fields :
| issue_id | field_name | field_value |
|---|---|---|
| 101 | city | NY |
| 101 | size | 10 m2 |
| 103 | postalcode | 1020 |
| 103 | city | SF |
Table issues :
| issue_id | created_date
I want, in BigQuery, to create a table which is the issues table with n new columns, every column is a field_name, for all field_name in the table issue_fields.
Desired output :
| issue_id | created_date | city | size | postalcode |
|---|---|---|---|---|
| 101 | 2023 | NY | 10 m2 | |
| 103 | 2022 | SF | 1020 |
Tried with ChatGPT without success
You can get the following output (excluding the
created_datefield) using the below code.This will use if statements to extract the key value pairs, returning the desired output table.