Skip to content

Commit

Permalink
Refactor logic for timestamp values
Browse files Browse the repository at this point in the history
Refactor logic to evaluate compile_started_at and query_completed_at values.
  • Loading branch information
kenpokiwi authored Sep 21, 2023
1 parent 3fd7645 commit 89857ed
Showing 1 changed file with 4 additions and 15 deletions.
19 changes: 4 additions & 15 deletions macros/upload_individual_datasets/upload_model_executions.sql
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,10 @@
'{{ model.status }}', {# status #}

{% if model.timing != [] %}
{% for stage in model.timing if stage.name == "compile" %}
{% if loop.length == 0 %}
null, {# compile_started_at #}
{% else %}
'{{ stage.started_at }}', {# compile_started_at #}
{% endif %}
{% endfor %}

{% for stage in model.timing if stage.name == "execute" %}
{% if loop.length == 0 %}
null, {# query_completed_at #}
{% else %}
'{{ stage.completed_at }}', {# query_completed_at #}
{% endif %}
{% endfor %}
{% set compile_started_at = (model.timing | selectattr("name", "eq", "compile") | first | default({})).get("started_at") %}
{% if compile_started_at %}'{{ compile_started_at }}'{% else %}null{% endif %}, {# compile_started_at #}
{% set query_completed_at = (model.timing | selectattr("name", "eq", "execute") | first | default({})).get("completed_at") %}
{% if query_completed_at %}'{{ query_completed_at }}'{% else %}null{% endif %}, {# query_completed_at #}
{% else %}
null, {# compile_started_at #}
null, {# query_completed_at #}
Expand Down

0 comments on commit 89857ed

Please sign in to comment.