How I can parse the below JSON using Trino.
[
{
"district_name":"District name",
"attributes":[
{"survey_date":"2024-08-29","commodity_name":"ABC","avg_spot_price":123},
{"survey_date":"2024-08-29","commodity_name":"DEF","avg_spot_price":456}
]
}
]
I’m using below SQL but it is raising error.
SELECT
district_name, attributes
FROM
UNNEST(CAST(JSON_EXTRACT(districts_data
,'$'
) as ARRAY(ROW(district_name VARCHAR, attributes ARRAY(ROW(survey_date VARCHAR, commodity_name VARCHAR, avg_spot_price DOUBLE)))
)
)
) as x(district_name, attributes)
1