Skip to content

Commit

Permalink
fix (#717)
Browse files Browse the repository at this point in the history
  • Loading branch information
dapollak authored May 28, 2024
1 parent b303b58 commit c2f9c21
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
10 changes: 10 additions & 0 deletions integration_tests/tests/test_dbt_artifacts/test_artifacts.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,13 @@ def test_source_freshness_results(test_id: str, dbt_project: DbtProject):
where=f"unique_id = 'source.elementary_tests.test_source.{test_id}'",
raise_if_empty=True,
)


def test_timings(dbt_project: DbtProject):
dbt_project.dbt_runner.vars["disable_dbt_artifacts_autoupload"] = False
dbt_project.dbt_runner.vars["disable_run_results"] = False
dbt_project.dbt_runner.run(select=TEST_MODEL)
results = dbt_project.run_query('select * from {{ ref("dbt_run_results") }}')

assert len(results) == 1
assert results[0]["execute_started_at"]
9 changes: 8 additions & 1 deletion macros/utils/graph/get_run_result_dict.sql
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,20 @@
{% do return(run_result.to_dict()) %}
{% else %}
{# There's a bug in dbt 1.8 which causes run_result.to_dict to fail on an exception #}
{% set timing_dicts = [] %}
{% if run_result.timing %}
{% for item in run_result.timing %}
{% do timing_dicts.append(item.to_dict()) %}
{% endfor %}
{% endif %}

{% do return({
'status': run_result.status,
'message': run_result.message,
'adapter_response': run_result.adapter_response,
'failures': run_result.failures,
'execution_time': run_result.execution_time,
'timing': run_result.timing,
'timing': timing_dicts,
'node': run_result.node.to_dict() if run_result.node else None,
'thread_id': run_result.thread_id
}) %}
Expand Down

0 comments on commit c2f9c21

Please sign in to comment.