Skip to content

Commit

Permalink
Fixed postgres issues
Browse files Browse the repository at this point in the history
  • Loading branch information
bvkabn committed Sep 20, 2024
1 parent 14a9239 commit d234259
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 11 deletions.
35 changes: 27 additions & 8 deletions models/dim_dbt__current_models.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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" %}
,
Expand All @@ -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" %}
,
Expand All @@ -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" %}
,
Expand Down
2 changes: 1 addition & 1 deletion models/sources/model_executions.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions models/sources/sources.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit d234259

Please sign in to comment.