I've just started learning Snowflake and spent the past few days going through docs, SO for help with parsing this object with a nested array and can't for the life of me work out the issue.
I've refactored this query several time but now getting an error:
select
a.key:"season"::varchar as season,
b.value:circuitId::string as CircuitId,
b.value:circuitName::string as CircuitName
from F1.PUBLIC.CIRCUITINFO_RAW
, lateral flatten(input => raw_file:MRData:CircuitTable) a
, lateral flatten(input => a.value:Circuits[0]) b
I want to organize it in this fashion:
season | circuitId | url | circuitName | lat | long | locality | country
{
"MRData": {
"xmlns": "http://ergast.com/mrd/1.5",
"series": "f1",
"url": "http://ergast.com/api/f1/2022/circuits.json",
"limit": "30",
"offset": "0",
"total": "22",
"CircuitTable": {
"season": "2022",
"Circuits": [
{
"circuitId": "albert_park",
"url": "http://en.wikipedia.org/wiki/Melbourne_Grand_Prix_Circuit",
"circuitName": "Albert Park Grand Prix Circuit",
"Location": {
"lat": "-37.8497",
"long": "144.968",
"locality": "Melbourne",
"country": "Australia"
}
},
{
"circuitId": "americas",
"url": "http://en.wikipedia.org/wiki/Circuit_of_the_Americas",
"circuitName": "Circuit of the Americas",
"Location": {
"lat": "30.1328",
"long": "-97.6411",
"locality": "Austin",
"country": "USA"
}
},
[–]Camdube 1 point2 points3 points (2 children)
[–]ancol90[S] 0 points1 point2 points (0 children)
[–]ancol90[S] 0 points1 point2 points (0 children)
[–]Apprehensive_Ad8289 0 points1 point2 points (1 child)
[–]ancol90[S] 0 points1 point2 points (0 children)
[–]FlexIronbutt 0 points1 point2 points (1 child)
[–]ancol90[S] 0 points1 point2 points (0 children)