This repository has been archived by the owner on Oct 30, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement dbt models for dbt 1.0 (#32)
- Loading branch information
Showing
42 changed files
with
1,222 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
|
||
target/ | ||
dbt_modules/ | ||
dbt_packages/ | ||
logs/ | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
...odels/marts/v4/run_results_v4/generic_test_run_results_v4/generic_test_run_results_v4.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
{% set project = var('dbt_artifacts_loader')['project'] %} | ||
{% set dataset = var('dbt_artifacts_loader')['dataset'] %} | ||
|
||
{{ | ||
config( | ||
enabled=true, | ||
full_refresh=none, | ||
materialized="view", | ||
database=project, | ||
schema=dataset, | ||
alias="generic_test_run_results_v4", | ||
persist_docs={"relation": true, "columns": true}, | ||
labels={ | ||
"modeled_by": "dbt", | ||
"app": "dbt-artifacts-loader", | ||
}, | ||
) | ||
}} | ||
|
||
WITH run_results AS ( | ||
SELECT | ||
run_results.*, | ||
(SELECT AS STRUCT generic_tests.*) AS generic_test, | ||
FROM {{ ref("expanded_run_results_v4") }} AS run_results | ||
LEFT OUTER JOIN {{ ref("parsed_generic_test_node_v4") }} AS generic_tests | ||
ON run_results.unique_id = generic_tests.unique_id | ||
AND ABS(DATETIME_DIFF(run_results.metadata.generated_at, generic_tests.metadata.generated_at, DAY)) <= 2 | ||
WHERE generic_tests.unique_id IS NOT NULL | ||
AND timing_name IN ("execute") | ||
) | ||
-- Extract only run results whose metadata is the most close to that of model. | ||
, nearest_manifests AS ( | ||
SELECT | ||
ROW_NUMBER() OVER (PARTITION BY unique_id, metadata.invocation_id ORDER BY generated_at_diff) AS rank, | ||
* EXCEPT(generated_at_diff) | ||
FROM ( | ||
SELECT | ||
ABS(DATETIME_DIFF(metadata.generated_at, generic_test.metadata.generated_at, SECOND)) AS generated_at_diff, | ||
*, | ||
FROM run_results | ||
) | ||
) | ||
|
||
SELECT | ||
* EXCEPT(rank) | ||
FROM nearest_manifests | ||
WHERE rank = 1 |
29 changes: 29 additions & 0 deletions
29
dbt_artifacts_models/models/marts/v4/run_results_v4/generic_test_run_results_v4/schema.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
--- | ||
version: 2 | ||
|
||
models: | ||
- name: generic_test_run_results_v4 | ||
description: | | ||
This is a denormalized schema test run results v4. | ||
tests: | ||
- dbt_utils.unique_combination_of_columns: | ||
combination_of_columns: | ||
- metadata.invocation_id | ||
- unique_id | ||
- timing_name | ||
|
||
columns: | ||
- name: metadata.invocation_id | ||
description: "invocation ID" | ||
tests: | ||
- not_null | ||
- name: unique_id | ||
description: "unique test ID" | ||
tests: | ||
- not_null | ||
- name: timing_name | ||
description: "timing name" | ||
tests: | ||
- accepted_values: | ||
values: ["execute"] |
30 changes: 30 additions & 0 deletions
30
...s/v4/run_results_v4/last_generic_test_run_results_v4/last_generic_test_run_results_v4.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{% set project = var('dbt_artifacts_loader')['project'] %} | ||
{% set dataset = var('dbt_artifacts_loader')['dataset'] %} | ||
|
||
{{ | ||
config( | ||
enabled=true, | ||
full_refresh=none, | ||
materialized="view", | ||
database=project, | ||
schema=dataset, | ||
alias="last_generic_test_run_results_v4", | ||
persist_docs={"relation": true, "columns": true}, | ||
labels={ | ||
"modeled_by": "dbt", | ||
"app": "dbt-artifacts-loader", | ||
}, | ||
) | ||
}} | ||
|
||
WITH run_results AS ( | ||
SELECT | ||
ROW_NUMBER() OVER (PARTITION BY unique_id ORDER BY completed_at DESC) AS rank, | ||
*, | ||
FROM {{ ref("generic_test_run_results_v4") }} | ||
) | ||
|
||
SELECT | ||
* EXCEPT(rank) | ||
FROM run_results | ||
WHERE rank = 1 |
30 changes: 30 additions & 0 deletions
30
...tifacts_models/models/marts/v4/run_results_v4/last_generic_test_run_results_v4/schema.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
--- | ||
version: 2 | ||
|
||
models: | ||
- name: last_generic_test_run_results_v4 | ||
description: | | ||
The table contains only the latest record of data test run results v4. | ||
tests: | ||
- dbt_utils.unique_combination_of_columns: | ||
combination_of_columns: | ||
- metadata.invocation_id | ||
- unique_id | ||
- timing_name | ||
|
||
columns: | ||
- name: metadata.invocation_id | ||
description: "invocation ID" | ||
tests: | ||
- not_null | ||
- name: unique_id | ||
description: "unique test ID" | ||
tests: | ||
- not_null | ||
- unique | ||
- name: timing_name | ||
description: "timing name" | ||
tests: | ||
- accepted_values: | ||
values: ["execute"] |
30 changes: 30 additions & 0 deletions
30
...ls/models/marts/v4/run_results_v4/last_model_run_results_v4/last_model_run_results_v4.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{% set project = var('dbt_artifacts_loader')['project'] %} | ||
{% set dataset = var('dbt_artifacts_loader')['dataset'] %} | ||
|
||
{{ | ||
config( | ||
enabled=true, | ||
full_refresh=none, | ||
materialized="view", | ||
database=project, | ||
schema=dataset, | ||
alias="last_model_run_results_v4", | ||
persist_docs={"relation": true, "columns": true}, | ||
labels={ | ||
"modeled_by": "dbt", | ||
"app": "dbt-artifacts-loader", | ||
}, | ||
) | ||
}} | ||
|
||
WITH run_results AS ( | ||
SELECT | ||
ROW_NUMBER() OVER (PARTITION BY unique_id ORDER BY completed_at DESC) AS rank, | ||
*, | ||
FROM {{ ref("model_run_results_v4") }} | ||
) | ||
|
||
SELECT | ||
* EXCEPT(rank) | ||
FROM run_results | ||
WHERE rank = 1 |
30 changes: 30 additions & 0 deletions
30
dbt_artifacts_models/models/marts/v4/run_results_v4/last_model_run_results_v4/schema.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
--- | ||
version: 2 | ||
|
||
models: | ||
- name: last_model_run_results_v4 | ||
description: | | ||
The table contains only the latest record of model run results v4. | ||
tests: | ||
- dbt_utils.unique_combination_of_columns: | ||
combination_of_columns: | ||
- metadata.invocation_id | ||
- unique_id | ||
- timing_name | ||
|
||
columns: | ||
- name: metadata.invocation_id | ||
description: "invocation ID" | ||
tests: | ||
- not_null | ||
- name: unique_id | ||
description: "unique test ID" | ||
tests: | ||
- not_null | ||
- unique | ||
- name: timing_name | ||
description: "timing name" | ||
tests: | ||
- accepted_values: | ||
values: ["execute"] |
30 changes: 30 additions & 0 deletions
30
...v4/run_results_v4/last_singular_test_run_results_v4/last_singular_test_run_results_v4.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{% set project = var('dbt_artifacts_loader')['project'] %} | ||
{% set dataset = var('dbt_artifacts_loader')['dataset'] %} | ||
|
||
{{ | ||
config( | ||
enabled=true, | ||
full_refresh=none, | ||
materialized="view", | ||
database=project, | ||
schema=dataset, | ||
alias="last_singular_test_run_results_v4", | ||
persist_docs={"relation": true, "columns": true}, | ||
labels={ | ||
"modeled_by": "dbt", | ||
"app": "dbt-artifacts-loader", | ||
}, | ||
) | ||
}} | ||
|
||
WITH run_results AS ( | ||
SELECT | ||
ROW_NUMBER() OVER (PARTITION BY unique_id ORDER BY completed_at DESC) AS rank, | ||
*, | ||
FROM {{ ref("singular_test_run_results_v4") }} | ||
) | ||
|
||
SELECT | ||
* EXCEPT(rank) | ||
FROM run_results | ||
WHERE rank = 1 |
30 changes: 30 additions & 0 deletions
30
...ifacts_models/models/marts/v4/run_results_v4/last_singular_test_run_results_v4/schema.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
--- | ||
version: 2 | ||
|
||
models: | ||
- name: last_singular_test_run_results_v4 | ||
description: | | ||
The table contains only the latest record of schema test run results v4. | ||
tests: | ||
- dbt_utils.unique_combination_of_columns: | ||
combination_of_columns: | ||
- metadata.invocation_id | ||
- unique_id | ||
- timing_name | ||
|
||
columns: | ||
- name: metadata.invocation_id | ||
description: "invocation ID" | ||
tests: | ||
- not_null | ||
- name: unique_id | ||
description: "unique test ID" | ||
tests: | ||
- not_null | ||
- unique | ||
- name: timing_name | ||
description: "timing name" | ||
tests: | ||
- accepted_values: | ||
values: ["execute"] |
30 changes: 30 additions & 0 deletions
30
...els/marts/v4/run_results_v4/last_snapshot_run_results_v4/last_snapshot_run_results_v4.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{% set project = var('dbt_artifacts_loader')['project'] %} | ||
{% set dataset = var('dbt_artifacts_loader')['dataset'] %} | ||
|
||
{{ | ||
config( | ||
enabled=true, | ||
full_refresh=none, | ||
materialized="view", | ||
database=project, | ||
schema=dataset, | ||
alias="last_snapshot_run_results_v4", | ||
persist_docs={"relation": true, "columns": true}, | ||
labels={ | ||
"modeled_by": "dbt", | ||
"app": "dbt-artifacts-loader", | ||
}, | ||
) | ||
}} | ||
|
||
WITH run_results AS ( | ||
SELECT | ||
ROW_NUMBER() OVER (PARTITION BY unique_id ORDER BY completed_at DESC) AS rank, | ||
*, | ||
FROM {{ ref("snapshot_run_results_v4") }} | ||
) | ||
|
||
SELECT | ||
* EXCEPT(rank) | ||
FROM run_results | ||
WHERE rank = 1 |
30 changes: 30 additions & 0 deletions
30
dbt_artifacts_models/models/marts/v4/run_results_v4/last_snapshot_run_results_v4/schema.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
--- | ||
version: 2 | ||
|
||
models: | ||
- name: last_snapshot_run_results_v4 | ||
description: | | ||
The table contains only the latest record of snapshot run results v4. | ||
tests: | ||
- dbt_utils.unique_combination_of_columns: | ||
combination_of_columns: | ||
- metadata.invocation_id | ||
- unique_id | ||
- timing_name | ||
|
||
columns: | ||
- name: metadata.invocation_id | ||
description: "invocation ID" | ||
tests: | ||
- not_null | ||
- name: unique_id | ||
description: "unique test ID" | ||
tests: | ||
- not_null | ||
- unique | ||
- name: timing_name | ||
description: "timing name" | ||
tests: | ||
- accepted_values: | ||
values: ["execute"] |
Oops, something went wrong.