Skip to content

Commit

Permalink
Merge pull request #72 from davidwitk/fix-dbt-models
Browse files Browse the repository at this point in the history
Fix dbt and IMDb models
  • Loading branch information
davidwitk authored Nov 13, 2024
2 parents 3db402d + 6862f14 commit 0ccd878
Show file tree
Hide file tree
Showing 13 changed files with 72 additions and 3 deletions.
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions models/duckdb/stg_imdb.sql
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ base as (
extracted_at :: timestamp as extracted_at,
title,
first_value(title) over (partition by movie_id order by extracted_at :: timestamp) as title_first,
rank,
rank :: int as rank,
case
when rating_20230119_2215 is not null then rating_20230119_2215
else split_part(rating, chr(160), 1) :: double
end as rating,
rating_count,
year,
rating_count :: int as rating_count,
year :: int as year,
link
from source

Expand Down
1 change: 1 addition & 0 deletions models/postgres/admin/fct_dbt_invocations.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
select * from {{ ref('stg_dbt_invocations') }}
1 change: 1 addition & 0 deletions models/postgres/admin/fct_dbt_model_executions.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
select * from {{ ref('stg_dbt_model_executions') }}
File renamed without changes.
7 changes: 7 additions & 0 deletions models/postgres/staging/dbt/_dbt.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
sources:
- name: raw_dbt

tables:
- name: invocations
- name: model_executions

31 changes: 31 additions & 0 deletions models/postgres/staging/dbt/stg_dbt_invocations.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
with source as (
select * from {{ source('raw_dbt', 'invocations') }}
),

base as (

select
command_invocation_id,
dbt_version,
project_name,
run_started_at,
dbt_command,
full_refresh_flag,
target_profile_name,
target_name,
target_schema,
target_threads,
dbt_cloud_project_id,
dbt_cloud_job_id,
dbt_cloud_run_id,
dbt_cloud_run_reason_category,
dbt_cloud_run_reason,
env_vars,
dbt_vars,
invocation_args,
dbt_custom_envs
from source

)

select * from base
29 changes: 29 additions & 0 deletions models/postgres/staging/dbt/stg_dbt_model_executions.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
with source as (
select * from {{ source('raw_dbt', 'model_executions') }}
),

base as (

select
command_invocation_id || node_id as model_execution_id,
command_invocation_id,
node_id,
run_started_at,
was_full_refresh,
split_part(thread_id, '-', 2) as thread_id,
status,
compile_started_at,
query_completed_at,
total_node_runtime,
rows_affected
as materialization,
schema
as name,
alias,
message,
adapter_response
from source

)

select * from base
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 0ccd878

Please sign in to comment.