Skip to content

Commit

Permalink
Improve build speed
Browse files Browse the repository at this point in the history
  • Loading branch information
NiallRees committed Mar 3, 2021
1 parent 834074a commit 8afa9bb
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 18 deletions.
1 change: 1 addition & 0 deletions models/dim_dbt__models.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
select * from {{ ref("stg_dbt__models") }}
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,28 @@
with models as (

select *
from {{ ref('stg_dbt__models') }}
from {{ ref('dim_dbt__models') }}

),

model_executions as (

select *
from {{ ref('stg_dbt__model_executions') }}

),

model_executions_incremental as (

select *
from model_executions

{% if is_incremental() %}
-- this filter will only be applied on an incremental run
where artifact_generated_at > (select max(artifact_generated_at) from {{ this }})
{% endif %}
from {{ ref('int_dbt__model_executions') }}

),

model_executions_with_materialization as (

select
model_executions_incremental.*,
model_executions.*,
models.model_materialization,
models.model_schema,
models.name
from model_executions_incremental
from model_executions
left join models on (
model_executions_incremental.command_invocation_id = models.command_invocation_id
and model_executions_incremental.node_id = models.node_id
model_executions.command_invocation_id = models.command_invocation_id
and model_executions.node_id = models.node_id
)

),
Expand Down
20 changes: 20 additions & 0 deletions models/incremental/int_dbt__model_executions.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
with model_executions as (

select *
from {{ ref('stg_dbt__model_executions') }}

),

model_executions_incremental as (

select *
from model_executions

{% if is_incremental() %}
-- this filter will only be applied on an incremental run
where artifact_generated_at > (select max(artifact_generated_at) from {{ this }})
{% endif %}

)

select * from model_executions_incremental

0 comments on commit 8afa9bb

Please sign in to comment.