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.
Cet exercice fait partie du cours
Case Study: Building E-Commerce Data Models with dbt
Exercice interactif pratique
Passez de la théorie à la pratique avec l’un de nos exercices interactifs
Commencer l’exercice