-
Notifications
You must be signed in to change notification settings - Fork 128
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
Fix missing value in upload model executions - add else clause to for if loops #386
Conversation
@@ -179,6 +179,8 @@ | |||
{% else %} | |||
'{{ stage.started_at }}', {# compile_started_at #} | |||
{% endif %} | |||
{ % else %} | |||
null, {# compile_started_at #} | |||
{% endfor %} |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 :)
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
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.
Refactor logic to evaluate compile_started_at and query_completed_at values.
…//github.com/kenpokiwi/dbt_artifacts into fix/missing_value_in_upload_model_executions
Thanks for all your work on this! |
Overview
See details in #385
Update type - breaking / non-breaking
What does this solve?
Resolves #385
Outstanding questions
What databases have you tested with?