DB Quacks SQL Tutorial · Chapter 3

JSON and the Amazing Technicolor Dreamcoat

Tech-savvy beaver swims up with a tablet. Greetings! Our pond location data is stored in modern JSON format instead of CSV. JSON handles complex, nested information beautifully! Can you read this JSON file directly?

Your task

Read and display specific fields from the external JSON file 'data/pond_locations.json'. Show the pond_id, pond_name, capacity, water_type, and depth_meters fields. You will be working with a JSON file containing pond location data.

Hint

Similar to CSV reading, but look for a function specifically designed for JSON format.

Expected result

A table showing pond_id, pond_name, capacity, water_type, and depth_meters from the pond_locations.json file.

Tables

duck_diaries (10 rows)

columntype
diary_idBIGINT
duck_idBIGINT
entry_dateDATE
diary_textVARCHAR
moodVARCHAR

duck_surveys (5000 rows)

columntype
survey_idBIGINT
duck_idBIGINT
ageBIGINT
favorite_foodVARCHAR
favorite_pondBIGINT
swimming_ratingBIGINT
migration_preferenceVARCHAR
social_behaviorVARCHAR
health_statusVARCHAR
activity_levelVARCHAR
survey_dateDATE
survey_locationBIGINT

ducks (15 rows)

columntype
idBIGINT
nameVARCHAR
ageBIGINT
speciesVARCHAR
birth_dateDATE
arrival_dateDATE

ponds (3 rows)

columntype
pond_idBIGINT
pond_nameVARCHAR
location_latDOUBLE
location_lngDOUBLE
capacityBIGINT
featuresVARCHAR[]
amenitiesVARCHAR[]

Files

data/pond_locations.json (3 rows)

columntype
pond_idBIGINT
pond_nameVARCHAR
locationSTRUCT(latitude DOUBLE, longitude DOUBLE, features VARCHAR[])
capacityBIGINT
amenitiesVARCHAR[]
water_typeVARCHAR
depth_metersDOUBLE
is_publicBOOLEAN
maintenance_scheduleVARCHAR

Database: https://dbquacks.com/data/databases/tutorial.duckdb

This page as markdown: https://dbquacks.com/tutorial/15.md

Start level 15 →

DuckDB docs for this lesson