I am trying to convert an array of array to multiple columns. The data structure is as follows:
Column name: Inputs
{
answers: [{
type: END_TIME,
answer: [{
int_value: 1015
}]
},{
type: LOCATION,
answer: [{
string_value: "SAN_JOSE"
},{
string_value: "CA"
}]
}],
username: "xxxxx",
status: COMPLETE
}
Ideal output would be
end_time location username status
1015 SAN_JOSE, CA xxxxx COMPLETE
But I am getting the following result:
end_time location username status
[{ [{ xxxxx COMPLETE
int_value: 1015 string_value: "SAN_JOSE"
}] },{
string_value: "CA"
}]
Using the sample statement below
SELECT
(SELECT answer FROM UNNEST(Inputs.answers) where type = 'END_TIME') end_time,
(SELECT answer FROM UNNEST(Inputs.answers) where type = 'LOCATION') location,
t.Inputs.username username,
t.Inputs.status status
FROM table_name t
;
Any suggestions would be greatly appreciated. TIA!