DuckDB has an unnest()
function that we can use to unnest lists and structs. Well, it can also be applied to NULL
, but that’ll return an empty result.
By “unnest” I mean it takes the list or struct, and it returns its contents as rows in a table. You might say that it converts lists and structs into tables, where each item in the list or struct becomes a row in the table.
Below are examples of using DuckDB’s unnest()
function to unnest lists and structs.