I just wrote a whole blog post on unnesting arrays in Redshift after having to do this for a client project. It walks through the entire process, including all of the functions required. Hopefully attempts to build some intuitions as well as just sharing the code.
I actually specifically chose not to macro-ize this code. In my specific situation I only had to do this once within an entire project and hopefully you don’t have excessive use of semi-structured data in Redshift either. Given that, i found that the complexity of the macro version would have actually been greater than simply writing the SQL to do the thing. Obviously, dbt-utils’ generate_series is still super-useful
Hopefully a good resource for folks who have to do this for the first time.