From e736d3a55c5960fcf0637ca1e94f3bea813b3957 Mon Sep 17 00:00:00 2001 From: "Alexis A." Date: Thu, 14 Nov 2024 16:38:42 +0100 Subject: [PATCH] doc(cumulative_flux): add usage comment --- .../sql/sparte/macros/cumulative_flux.sql | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/airflow/include/sql/sparte/macros/cumulative_flux.sql b/airflow/include/sql/sparte/macros/cumulative_flux.sql index 2d51684c4..ab3604b6a 100644 --- a/airflow/include/sql/sparte/macros/cumulative_flux.sql +++ b/airflow/include/sql/sparte/macros/cumulative_flux.sql @@ -1,4 +1,29 @@ +{# + +Cette macro permet de générer une liste de combinaisons d'années +pour calculer des flux cumulés. + +Usage : + {% call(start_year, end_year) cumulative_flux( + first_available_year=2009, + last_available_year=2012 + ) %} + sum(population_{{ start_year }}_{{ end_year + 1 }}) + as population_{{ start_year }}_{{ end_year + 1 }} + {% endcall %} + +Va créer les colonnes suivantes : + - population_2009_2010 + - population_2010_2011 + - population_2011_2012 + - population_2009_2011 + - population_2010_2012 + - population_2009_2012 +A partir des sommes des colonnes de flux annuels. + +#} {% macro cumulative_flux(first_available_year, last_available_year) %} + {% set ns = namespace(continued=false) %} {% for start_year in range(first_available_year, last_available_year + 1) %} {% for end_year in range(first_available_year, last_available_year + 1) -%}