When to use this
API sources often return data with multiple levels of nesting — auser object that contains an address object which itself contains a coordinates object. While Parse JSON fields works for a single level, deeply nested structures require a systematic approach to flatten everything into a single, query-friendly row.
Sample input
Anevents table in the Raw layer where each row has nested JSON:
We want to flatten all nested fields into top-level columns.
Implementation
- Nekt Express / BigQuery
- Athena SQL
- Python (Nekt SDK)
Use dot-notation with
JSON_VALUE to traverse the nested paths.Expected output
Tips and gotchas
For very wide or deeply nested JSON (10+ fields, 3+ levels), consider flattening incrementally — create an intermediate table with the first level flattened, then flatten further in a second transformation. This makes debugging and maintenance much easier.