Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix missing value in upload model executions - add else clause to for if loops #386

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions macros/upload_individual_datasets/upload_model_executions.sql
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@
{% else %}
'{{ stage.started_at }}', {# compile_started_at #}
{% endif %}
{ % else %}
null, {# compile_started_at #}
{% endfor %}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think originally this loop.length section was designed for the use-case you are fixing here, but doesn't make sense (it wouldn't run if the loop was empty). That means it can be removed I believe. Looking at the logic here, it also looks like it could be hugely simplified using Jinja filtering:

                {% 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 #}

I think this would aid readability and consistency. What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I think that is much more elegant :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for looking at this. For consistency, please could you also add the same logic into the other two macros in here for BQ and Snowflalke? From lines 88 and 164. Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the feedback. Update done.


{% for stage in model.timing if stage.name == "execute" %}
Expand All @@ -187,6 +189,8 @@
{% else %}
'{{ stage.completed_at }}', {# query_completed_at #}
{% endif %}
{ % else %}
null, {# query_completed_at #}
{% endfor %}
{% else %}
null, {# compile_started_at #}
Expand Down
Loading