Bigquery JSON_EXTRACT function takes a string as the key to return the value. Is it possible to take the string from a column?
The json_string_expr
to process is like {'A': '123', 'B': '456'}
.
I want to take the key from a column list
.
The Bigquery table and expected result are as below.
| json_string_expr | list | expected_result
|{'A': '123', 'B': '456'} | A | '123'
|{'A': '789', 'B': '012'} | B | '012'
JSON_EXTRACT(json_string_expr, '$.list')
couldn't give the expected result, because the function expects a string after $.
.
Any idea how to return the expected result using standard SQL?