Skip to content

Commit

Permalink
testing
Browse files Browse the repository at this point in the history
  • Loading branch information
saraburns1 committed Jul 12, 2024
1 parent 321c3a1 commit 78f3820
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 20 deletions.
36 changes: 17 additions & 19 deletions macros/drop_stale_tables.sql
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
{% macro drop_stale_tables(dryrun=False) %}

{% set current_models=[] %}
{% set current_models = [] %}

{% for node in graph.nodes.values()
| selectattr("resource_type", "in", ["model", "snapshot"])%}
{% do current_models.append(node.name) %}
{% for node in graph.nodes.values() | selectattr(
"resource_type", "in", ["model", "snapshot"]
) %}
{% do current_models.append(node.name) %}

{% endfor %}
{% endfor %}

{% set cleanup_query %}
{% set cleanup_query %}
WITH MODELS_TO_DROP AS (
SELECT
CASE
Expand All @@ -31,25 +32,22 @@
concat('DROP ',RELATION_TYPE,' ',RELATION_NAME,';') as DROP_COMMANDS
FROM MODELS_TO_DROP

{% endset %}
{% endset %}
{% do log(cleanup_query, info=True) %}
{% set drop_commands = run_query(cleanup_query).columns[0].values() %}

{% if drop_commands %}
{% if dryrun | as_bool == False %}
{% do log('Executing DROP commands...', True) %}
{% else %}
{% do log('Printing DROP commands...', True) %}
{% endif %}
{% for drop_command in drop_commands %}
{% do log(drop_command, True) %}
{% if dryrun | as_bool == False %}
{% do run_query(drop_command) %}
{% do log("Executing DROP commands...", True) %}
{% else %} {% do log("Printing DROP commands...", True) %}
{% endif %}
{% endfor %}
{% else %}
{% do log('No relations to clean.', True) %}
{% for drop_command in drop_commands %}
{% do log(drop_command, True) %}
{% if dryrun | as_bool == False %}
{% do run_query(drop_command) %}
{% endif %}
{% endfor %}
{% else %} {% do log("No relations to clean.", True) %}
{% endif %}

{%- endmacro -%}

6 changes: 5 additions & 1 deletion models/courses/course_names.sql
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ with
from {{ source("event_sink", "course_overviews") }}
group by org, course_key
)
select course_key, display_name as course_name, splitByString('+', course_key)[-1] as course_run, org
select
course_key,
display_name as course_name,
splitByString('+', course_key)[-1] as course_run,
org
from {{ source("event_sink", "course_overviews") }} co
inner join
most_recent_overviews mro
Expand Down

0 comments on commit 78f3820

Please sign in to comment.