Skip to content

Instantly share code, notes, and snippets.

@seahrh
Last active February 8, 2019 06:48
Show Gist options
  • Save seahrh/bba9537eabe147de3c25219112e0fe30 to your computer and use it in GitHub Desktop.
Save seahrh/bba9537eabe147de3c25219112e0fe30 to your computer and use it in GitHub Desktop.
Loop dictionary in airflow jinja template
{% for k, v in params.lifecycle_days.items() %}
alter table {{ k }} drop if exists partition (ds<'{{ macros.ds_format(macros.ds_add(ds, v*-1), "%Y-%m-%d", "%Y%m%d") }}');
{% endfor %}
{% for k, v in params.lifecycle_days.items() %}
analyze table {{ k }} partition (ds='{{ ds_nodash }}') compute statistics;
{% endfor %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment