Unnesting a JSON Stringified data that was stored in a STRING Column, not RECORD Column

56 views Asked by At

I have a JSON Stringified data resides in a column called "Request". Been trying to UNNEST it using examples from Unnest a JSON stringified array in BigQuery but it shows no result.

Here is the data structure :

{"PaynetInstantTransfer":
  {
  "id": {"value": "02c8e435"}  
  "userIp": {"value": "000.000.000.000"},
  "purpose": "TRANSFER",
  "cardType": "NOT_AVAILABLE",
  "visaClass": "NOT_AVAILABLE",
  "phoneNumber": "0000000000",
  "proxyNumber": "NOT_AVAILABLE",
  "transAmount": 50.0
  }
}

Anyone knows how to UNNEST this type of array? It was stored in a column and the data type set for the column is STRING, not RECORD. Those example from the link works because it was an array initialized in the query itself. My issue here is above data was already stored in the column.

SELECT id, 
  JSON_EXTRACT_SCALAR(json, '$.PaynetInstantTransfer') as PaynetInstantTransfer
FROM `table.table`,
UNNEST(JSON_EXTRACT_ARRAY(request,'$')) json 

I tried this, can run, but no record shown. Anyone knows what am I missing here? I am trying to flatten the column so I can use those data for another purpose. Thanks.

0

There are 0 answers