Using Jinja for loops on repeated SQL 1
Scanning through your customers.sql file again, you realize that there is a lot of repeating of CASE WHEN ... statements for creating different columns counting orders by status. This is causing the data mart model to be super long and complex.
As an initial step, you broke out that CTE into its own intermediary mart model called int_customers__pivoted.sql and moved the logic there.
However, the more you look at it, the more it feels like the intermediate model can benefit from a Jinja loop, for better scalability and less repeating.
Questo esercizio fa parte del corso
Case Study: Building E-Commerce Data Models with dbt
Esercizio pratico interattivo
Passa dalla teoria alla pratica con uno dei nostri esercizi interattivi
Inizia esercizio