diff --git a/models/duckdb/models.yml b/models/duckdb/_models.yml similarity index 100% rename from models/duckdb/models.yml rename to models/duckdb/_models.yml diff --git a/models/duckdb/sources.yml b/models/duckdb/_sources.yml similarity index 100% rename from models/duckdb/sources.yml rename to models/duckdb/_sources.yml diff --git a/models/duckdb/stg_imdb.sql b/models/duckdb/stg_imdb.sql index 8330364..797c297 100644 --- a/models/duckdb/stg_imdb.sql +++ b/models/duckdb/stg_imdb.sql @@ -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 diff --git a/models/postgres/admin/fct_dbt_invocations.sql b/models/postgres/admin/fct_dbt_invocations.sql new file mode 100644 index 0000000..b078515 --- /dev/null +++ b/models/postgres/admin/fct_dbt_invocations.sql @@ -0,0 +1 @@ +select * from {{ ref('stg_dbt_invocations') }} diff --git a/models/postgres/admin/fct_dbt_model_executions.sql b/models/postgres/admin/fct_dbt_model_executions.sql new file mode 100644 index 0000000..ca3c93e --- /dev/null +++ b/models/postgres/admin/fct_dbt_model_executions.sql @@ -0,0 +1 @@ +select * from {{ ref('stg_dbt_model_executions') }} diff --git a/models/postgres/analytics/facts.yml b/models/postgres/analytics/_facts.yml similarity index 100% rename from models/postgres/analytics/facts.yml rename to models/postgres/analytics/_facts.yml diff --git a/models/postgres/staging/dbt/_dbt.yml b/models/postgres/staging/dbt/_dbt.yml new file mode 100644 index 0000000..8ccae61 --- /dev/null +++ b/models/postgres/staging/dbt/_dbt.yml @@ -0,0 +1,7 @@ +sources: + - name: raw_dbt + + tables: + - name: invocations + - name: model_executions + diff --git a/models/postgres/staging/dbt/stg_dbt_invocations.sql b/models/postgres/staging/dbt/stg_dbt_invocations.sql new file mode 100644 index 0000000..a95b142 --- /dev/null +++ b/models/postgres/staging/dbt/stg_dbt_invocations.sql @@ -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 diff --git a/models/postgres/staging/dbt/stg_dbt_model_executions.sql b/models/postgres/staging/dbt/stg_dbt_model_executions.sql new file mode 100644 index 0000000..53e377c --- /dev/null +++ b/models/postgres/staging/dbt/stg_dbt_model_executions.sql @@ -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 diff --git a/models/postgres/staging/github/github.yml b/models/postgres/staging/github/_github.yml similarity index 100% rename from models/postgres/staging/github/github.yml rename to models/postgres/staging/github/_github.yml diff --git a/models/postgres/staging/imdb/imdb.yml b/models/postgres/staging/imdb/_imdb.yml similarity index 100% rename from models/postgres/staging/imdb/imdb.yml rename to models/postgres/staging/imdb/_imdb.yml diff --git a/models/postgres/staging/mubi/mubi.yml b/models/postgres/staging/mubi/_mubi.yml similarity index 100% rename from models/postgres/staging/mubi/mubi.yml rename to models/postgres/staging/mubi/_mubi.yml diff --git a/models/postgres/staging/openweathermap/openweathermap.yml b/models/postgres/staging/openweathermap/_openweathermap.yml similarity index 100% rename from models/postgres/staging/openweathermap/openweathermap.yml rename to models/postgres/staging/openweathermap/_openweathermap.yml