Skip to content

Commit

Permalink
doc(cumulative_flux): add usage comment
Browse files Browse the repository at this point in the history
  • Loading branch information
alexisig committed Nov 14, 2024
1 parent 997be7b commit e736d3a
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions airflow/include/sql/sparte/macros/cumulative_flux.sql
Original file line number Diff line number Diff line change
@@ -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) -%}
Expand Down

0 comments on commit e736d3a

Please sign in to comment.