diff --git a/models/dim_dbt__current_models.sql b/models/dim_dbt__current_models.sql index 2b94f11e..778385a0 100644 --- a/models/dim_dbt__current_models.sql +++ b/models/dim_dbt__current_models.sql @@ -37,13 +37,22 @@ with select node_id, max( - case when was_full_refresh = 1 then query_completed_at end + case + when was_full_refresh {% if target.type == "sqlserver" %} = 1 {% endif %} + then query_completed_at + end ) as last_full_refresh_run_completed_at, max( - case when was_full_refresh = 1 then total_node_runtime end + case + when was_full_refresh {% if target.type == "sqlserver" %} = 1 {% endif %} + then total_node_runtime + end ) as last_full_refresh_run_total_runtime, max( - case when was_full_refresh = 1 then rows_affected end + case + when was_full_refresh {% if target.type == "sqlserver" %} = 1 {% endif %} + then rows_affected + end ) as last_full_refresh_run_rows_affected {% if target.type == "bigquery" %} , @@ -52,8 +61,9 @@ with ) as last_full_refresh_run_bytes_processed {% endif %}, max(case when run_idx_id_only = 1 then query_completed_at end) as last_run_completed_at, - max(case when run_idx_id_only = 1 then total_node_runtime end) as last_run_total_runtime - , + max( + case when run_idx_id_only = 1 then total_node_runtime end + ) as last_run_total_runtime, max(case when run_idx_id_only = 1 then rows_affected end) as last_run_rows_affected {% if target.type == "bigquery" %} , @@ -62,13 +72,22 @@ with ) as last_run_bytes_processed {% endif %}, max( - case when not was_full_refresh = 1 then query_completed_at end + case + when not was_full_refresh {% if target.type == "sqlserver" %} = 1 {% endif %} + then query_completed_at + end ) as last_incremental_run_completed_at, max( - case when not was_full_refresh = 1 then total_node_runtime end + case + when not was_full_refresh {% if target.type == "sqlserver" %} = 1 {% endif %} + then total_node_runtime + end ) as last_incremental_run_total_runtime, max( - case when not was_full_refresh = 1 then rows_affected end + case + when not was_full_refresh {% if target.type == "sqlserver" %} = 1 {% endif %} + then rows_affected + end ) as last_incremental_run_rows_affected {% if target.type == "bigquery" %} , diff --git a/models/sources/model_executions.sql b/models/sources/model_executions.sql index e07107cf..fa57379f 100644 --- a/models/sources/model_executions.sql +++ b/models/sources/model_executions.sql @@ -14,7 +14,7 @@ select cast(null as {{ type_int() }}) as rows_affected, {% if target.type == "bigquery" %} , cast(null as {{ type_int() }}) as bytes_processed - {% endif %}, + {% endif %} cast(null as {{ type_string() }}) as materialization, cast(null as {{ type_string() }}) as {% if target.type == "sqlserver" %} "schema" {% else %} schema diff --git a/models/sources/sources.sql b/models/sources/sources.sql index a6a1ee85..91c8d1d3 100644 --- a/models/sources/sources.sql +++ b/models/sources/sources.sql @@ -4,13 +4,13 @@ with dummy_cte as (select 1 as foo) select cast(null as {{ type_string() }}) as command_invocation_id, cast(null as {{ type_string() }}) as node_id, - cast(null as {{ type_timestamp() }}) as run_started_at + cast(null as {{ type_timestamp() }}) as run_started_at, cast(null as {{ type_string() }}) as {% if target.type == "sqlserver" %} "database" {% else %} database {% endif %}, cast(null as {{ type_string() }}) as {% if target.type == "sqlserver" %} "schema" {% else %} schema - {% endif %},, + {% endif %}, cast(null as {{ type_string() }}) as source_name, cast(null as {{ type_string() }}) as loader, cast(null as {{ type_string() }}) as name,