File tree Expand file tree Collapse file tree 5 files changed +110
-4
lines changed Expand file tree Collapse file tree 5 files changed +110
-4
lines changed Original file line number Diff line number Diff line change @@ -3,10 +3,11 @@ This package builds a mart of tables from dbt artifacts loaded into a table. It
3
3
4
4
Models included:
5
5
6
- - ` fct_dbt_model_executions `
7
- - ` fct_dbt_run_results `
6
+ - ` dim_dbt__models `
7
+ - ` fct_dbt__model_executions `
8
8
- ` fct_dbt__latest_full_model_executions `
9
9
- ` fct_dbt__critical_path `
10
+ - ` fct_dbt_run_results `
10
11
11
12
The critical path model determines the slowest route through your DAG, which provides you with the information needed to make a targeted effort to reducing ` dbt run ` times. For example:
12
13
Original file line number Diff line number Diff line change
1
+ {{ config( materialized= ' incremental' , unique_key= ' manifest_model_id' ) }}
2
+
3
+ with dbt_models as (
4
+
5
+ select * from {{ ref(' stg_dbt__models' ) }}
6
+
7
+ ),
8
+
9
+ dbt_models_incremental as (
10
+
11
+ select *
12
+ from dbt_models
13
+
14
+ {% if is_incremental() %}
15
+ -- this filter will only be applied on an incremental run
16
+ where artifact_generated_at > (select max (artifact_generated_at) from {{ this }})
17
+ {% endif %}
18
+
19
+ ),
20
+
21
+ fields as (
22
+
23
+ select
24
+ manifest_model_id,
25
+ command_invocation_id,
26
+ artifact_generated_at,
27
+ node_id,
28
+ name,
29
+ model_schema,
30
+ depends_on_nodes,
31
+ package_name,
32
+ model_path,
33
+ checksum,
34
+ model_materialization
35
+ from dbt_models_incremental
36
+
37
+ )
38
+
39
+ select * from fields
Original file line number Diff line number Diff line change 3
3
with models as (
4
4
5
5
select *
6
- from {{ ref(' stg_dbt__models ' ) }}
6
+ from {{ ref(' dim_dbt__models ' ) }}
7
7
8
8
),
9
9
10
10
model_executions as (
11
11
12
12
select *
13
- from {{ ref(' stg_dbt__model_executions ' ) }}
13
+ from {{ ref(' int_dbt__model_executions ' ) }}
14
14
15
15
),
16
16
Original file line number Diff line number Diff line change
1
+ {{ config( materialized= ' incremental' , unique_key= ' model_execution_id' ) }}
2
+
3
+ with model_executions as (
4
+
5
+ select *
6
+ from {{ ref(' stg_dbt__model_executions' ) }}
7
+
8
+ ),
9
+
10
+ model_executions_incremental as (
11
+
12
+ select *
13
+ from model_executions
14
+
15
+ {% if is_incremental() %}
16
+ -- this filter will only be applied on an incremental run
17
+ where artifact_generated_at > (select max (artifact_generated_at) from {{ this }})
18
+ {% endif %}
19
+
20
+ ),
21
+
22
+ fields as (
23
+
24
+ select
25
+ model_execution_id,
26
+ command_invocation_id,
27
+ artifact_generated_at,
28
+ was_full_refresh,
29
+ node_id,
30
+ thread_id,
31
+ status,
32
+ compile_started_at,
33
+ query_completed_at,
34
+ total_node_runtime,
35
+ rows_affected
36
+ from model_executions_incremental
37
+
38
+ )
39
+
40
+ select * from fields
Original file line number Diff line number Diff line change @@ -103,3 +103,29 @@ models:
103
103
description : Was the run executed with a --full-refresh flag?
104
104
- name : env_*
105
105
description : Columns for the environment variables set when the command was executed.
106
+
107
+ - name : dim_dbt__models
108
+ description : All dbt model metadata from every manifest.json.
109
+ columns :
110
+ - name : manifest_model_id
111
+ description : Primary key generated from the command_invocation_id and checksum.
112
+ tests :
113
+ - unique
114
+ - not_null
115
+ - name : command_invocation_id
116
+ description : The id of the command which resulted in the source artifact's generation.
117
+ - name : artifact_generated_at
118
+ description : Timestamp of when the source artifact was generated.
119
+ - name : node_id
120
+ description : Unique id for the node, in the form of model.[package_name].[model_name]
121
+ - name : name
122
+ description : The model name.
123
+ - name : model_schema
124
+ - name : depends_on_nodes
125
+ description : List of node ids the model depends on.
126
+ - name : package_name
127
+ - name : model_path
128
+ description : Filepath of the model.
129
+ - name : checksum
130
+ description : Unique identifier for the model. If a model is unchanged between separate executions this will remain the same.
131
+ - name : model_materialization
You can’t perform that action at this time.
0 commit comments