Created
June 17, 2020 13:47
-
-
Save clrcrl/99c5e995d30b5f39dd92689f07dc9955 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% macro clean_data(relation) %} | |
{%- set columns = adapter.get_columns_in_relation(relation) -%} | |
{% set where_clauses={ | |
'id': 'not in (1, 2)', | |
'last_name': "not in ('Carroll')" | |
} %} | |
select | |
{% for column in columns %} | |
{{ column.name | lower }} {{", " if not loop.last}} | |
{%- endfor %} | |
from {{ relation }} | |
where | |
{% for column in columns %} | |
{% if column.name | lower in where_clauses.keys() %} | |
{{ "and" if not loop.first }} {{ column.name | lower }} {{ where_clauses[ column.name | lower] }} | |
{% endif %} | |
{% endfor %} | |
{% endmacro %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment