Hi All,
I have the following document
[
{
"document": {
"request": "Primary",
"results": {
"bit1": [
10.959,
11.802,
11.194,
15.374
],
"bit2": [
19.403,
20.118,
20.589
],
"bit3": [
1602597900000,
1602597960000,
1602598020000
]
},
"load_time": "1602684260",
"docType": "docType"
}
},
{
"document": {
"request": "Primary",
"results": {
"bit1": [
12.959,
10.802,
09.194
],
"bit2": [
11.003,
11.988,
12.089
],
"bit3": [
1602597900000,
1602597960000,
1602598020000
]
},
"load_time": "1602684263",
"docType": "docType"
}
}
I am trying to unnest the document and I am using the following query but this query is doing multi joins.
SELECT
bit1,
bit2,
bit3
FROM
document DC
UNNEST DC.results.bit1 as bitr1
UNNEST DC.results.bit2 as bitr2
UNNEST DC.results.bit3 as bitr3
WHERE
DC.docType=‘docType’
This query works perfectly but I see null when I try to convert bit3 from MILLIS TO STR.
SELECT
DC.results.bit1 as bitr1,
DC.results.bit2 as bitr2,
MILLIS_TO_STR(TO_NUMBER(DC.results.bit3)) as bitr3
FROM
document DC
WHERE
DC.docType=‘docType’
NOTE:
bit1,bit2, and bit3 are coming as a string so in my second query, I am converting it to numbers and then to DateTime datatype.