-
Notifications
You must be signed in to change notification settings - Fork 132
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added sources model and extracted additional columns from manifest json. * Dedupe artifacts, add docs and add dim_dbt__sources
- Loading branch information
kgpayne
authored
Mar 5, 2021
1 parent
413068e
commit 63550bd
Showing
7 changed files
with
181 additions
and
33 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,7 @@ | |
target/ | ||
dbt_modules/ | ||
logs/ | ||
|
||
.vscode/ | ||
Pipfile | ||
Pipfile.lock |
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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{{ config( materialized='incremental', unique_key='manifest_source_id' ) }} | ||
|
||
with dbt_sources as ( | ||
|
||
select * from {{ ref('stg_dbt__sources') }} | ||
|
||
), | ||
|
||
dbt_sources_incremental as ( | ||
|
||
select * | ||
from dbt_sources | ||
|
||
{% 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 %} | ||
|
||
), | ||
|
||
fields as ( | ||
|
||
select | ||
manifest_source_id, | ||
command_invocation_id, | ||
artifact_generated_at, | ||
node_id, | ||
name, | ||
source_name, | ||
source_schema, | ||
package_name, | ||
relation_name, | ||
source_path | ||
from dbt_sources_incremental | ||
|
||
) | ||
|
||
select * from fields |
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
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 |
---|---|---|
@@ -0,0 +1,51 @@ | ||
with base as ( | ||
|
||
select * | ||
from {{ ref('stg_dbt__artifacts') }} | ||
|
||
), | ||
|
||
manifests as ( | ||
|
||
select * | ||
from base | ||
where artifact_type = 'manifest.json' | ||
|
||
), | ||
|
||
flatten as ( | ||
|
||
select | ||
command_invocation_id, | ||
generated_at as artifact_generated_at, | ||
node.key as node_id, | ||
node.value:name::string as name, | ||
node.value:source_name::string as source_name, | ||
node.value:schema::string as source_schema, | ||
node.value:package_name::string as package_name, | ||
node.value:relation_name::string as relation_name, | ||
node.value:path::string as source_path | ||
from manifests, | ||
lateral flatten(input => data:sources) as node | ||
where node.value:resource_type = 'source' | ||
|
||
), | ||
|
||
surrogate_key as ( | ||
|
||
select | ||
{{ dbt_utils.surrogate_key(['command_invocation_id', 'node_id']) }} as manifest_source_id, | ||
command_invocation_id, | ||
artifact_generated_at, | ||
node_id, | ||
name, | ||
source_name, | ||
source_schema, | ||
package_name, | ||
relation_name, | ||
source_path | ||
from flatten | ||
|
||
) | ||
|
||
select * from surrogate_key |