I have a json file in S3 with the following strucure
{
status: "Success",
created_at: "19 AUG 2019",
employees:[
{"name":"name1", "id":"1"},
{"name":"name2", "id":"2"},
{"name":"name3", "id":"3"}
],
contacts: []
}
The following SQL functions works fine to find number of contacts
SELECT count(*) FROM S3Object[*].contacts[*]
But sometimes, the json file doesn't have that contacs
key itself like,
{
status: "Success",
created_at: "19 AUG 2019",
employees:[
{"name":"name1", "id":"1"},
{"name":"name2", "id":"2"},
{"name":"name3", "id":"3"}
]
}
In this case the above sql returns contacts count as 1 but I am expecting it to return "zero".
How to re-write a sql dynamically to handle both the file content?