You need to read and work with a directory of similarly structured JSON files.
Solution
Treat the directory of JSON files as single database table.
Discussion
This is one of DuckDB’s superpowers. The developers seem to know what we data folk have to put up with on a daily basis and have made wonderful affordances for many common idioms.
We’ll use some “March Madness” bracket data from a 538 project that I converted to ndjson for a quick example. It has 61 ndjson files, one for each of the brackets. We’ll read them all in and also keep the filename around since the bracket number does not seem to be in the schema (please be kind to your future self and others and include this info in the data file).
Take note that there’s a timestamp field in the schema, but that field only appears in 21 of the 61 JSON files. DuckDB handles this well, but you should always make a thorough inspection of your data before blindly letting these conversions take place.
That timestamp is in a gosh awful format: 3/20/2014 10:31 PM, but we can help DuckDB deal with it and let it know it should be in all the files: