-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(dbt): mart registry for dependency graph #2623
Merged
Merged
Changes from 10 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
06feda5
fix(dbt): point to better source for latest package owner in deps.dev
ccerv1 abc53a1
feat(dbt): staging model for latest package owner
ccerv1 109f94e
feat(dbt): int model to see if we have a package's owner repo already
ccerv1 8f5b0d6
fix(dbt): add model to resolve deps.dev and sbom source names
ccerv1 fb26cbb
feat(dbt): parse package lineage and determine if historic owner is c…
ccerv1 6caae64
fix(dbt): refactor to use int_packages
ccerv1 db9e748
fix(dbt): use int_packages to join on sbom package sources
ccerv1 c84679b
fix(dbt): lookup deps.dev package owner artifact_id if it exists
ccerv1 0582d12
fix(dbt): rename field
ccerv1 a8c9985
feat(dbt): add sbom mart model
ccerv1 9dda453
feat(dbt): add project id to int model
ccerv1 5404dbf
refactor(dbt): break sboms_v0 into two models
ccerv1 e8d6370
Merge branch 'main' into deps-projects
ccerv1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
31 changes: 31 additions & 0 deletions
31
warehouse/dbt/models/intermediate/directory/int_artifacts_in_deps_dev_by_project.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,31 @@ | ||
with latest_package as ( | ||
select distinct | ||
package_artifact_source, | ||
package_artifact_name, | ||
package_github_owner, | ||
package_github_repo | ||
from {{ ref('int_packages') }} | ||
where is_current_owner = true | ||
) | ||
|
||
select | ||
github_repos.project_id, | ||
github_repos.artifact_id, | ||
github_repos.artifact_source_id, | ||
github_repos.artifact_source, | ||
latest_package.package_github_owner as artifact_namespace, | ||
latest_package.package_github_repo as artifact_name, | ||
all_packages.artifact_id as package_artifact_id, | ||
latest_package.package_artifact_source as package_artifact_source, | ||
latest_package.package_artifact_name as package_artifact_name | ||
from latest_package | ||
left outer join {{ ref('int_all_artifacts') }} as github_repos | ||
on | ||
latest_package.package_github_owner = github_repos.artifact_namespace | ||
and latest_package.package_github_repo = github_repos.artifact_name | ||
and github_repos.artifact_source = 'GITHUB' | ||
left outer join {{ ref('int_all_artifacts') }} as all_packages | ||
on | ||
latest_package.package_artifact_name = all_packages.artifact_name | ||
and latest_package.package_artifact_source = all_packages.artifact_source | ||
where github_repos.project_id is not null |
47 changes: 47 additions & 0 deletions
47
warehouse/dbt/models/intermediate/directory/int_packages.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 @@ | ||
with deps_dev as ( | ||
select | ||
`Version` as package_version, | ||
upper(`System`) as package_artifact_source, | ||
lower(`Name`) as package_artifact_name, | ||
lower(split(`ProjectName`, '/')[0]) as package_github_owner, | ||
lower(split(`ProjectName`, '/')[1]) as package_github_repo | ||
from {{ ref('stg_deps_dev__packages') }} | ||
), | ||
|
||
latest_versions as ( | ||
select | ||
package_artifact_source, | ||
package_artifact_name, | ||
package_github_owner as current_owner, | ||
package_github_repo as current_repo | ||
from deps_dev | ||
qualify row_number() over ( | ||
partition by package_artifact_name, package_artifact_source | ||
order by package_version desc | ||
) = 1 | ||
) | ||
|
||
select | ||
deps_dev.package_artifact_source, | ||
deps_dev.package_artifact_name, | ||
deps_dev.package_version, | ||
deps_dev.package_github_owner, | ||
deps_dev.package_github_repo, | ||
case | ||
when deps_dev.package_artifact_source = 'CARGO' then 'RUST' | ||
when deps_dev.package_artifact_source = 'NPM' then 'NPM' | ||
when deps_dev.package_artifact_source = 'PYPI' then 'PIP' | ||
when deps_dev.package_artifact_source = 'GO' then 'GO' | ||
when deps_dev.package_artifact_source = 'MAVEN' then 'MAVEN' | ||
when deps_dev.package_artifact_source = 'NUGET' then 'NUGET' | ||
else 'UNKNOWN' | ||
end as sbom_artifact_source, | ||
( | ||
deps_dev.package_github_owner = latest_versions.current_owner | ||
and deps_dev.package_github_repo = latest_versions.current_repo) | ||
as is_current_owner | ||
from deps_dev | ||
left join latest_versions | ||
on | ||
deps_dev.package_artifact_source = latest_versions.package_artifact_source | ||
and deps_dev.package_artifact_name = latest_versions.package_artifact_name |
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,28 @@ | ||
{{ | ||
config( | ||
materialized='table', | ||
meta = { | ||
'sync_to_db': True, | ||
'index': { | ||
'idx_artifact_id': ["from_artifact_id"], | ||
'idx_artifact_name': ["from_artifact_source", "from_artifact_namespace", "from_artifact_name"], | ||
'idx_package_artifact': ["to_package_artifact_source", "to_package_artifact_name"], | ||
'idx_package_github': ["to_package_github_owner", "to_package_github_repo"] | ||
} | ||
} | ||
) | ||
}} | ||
|
||
|
||
select distinct | ||
artifact_id as from_artifact_id, | ||
artifact_source as from_artifact_source, | ||
artifact_namespace as from_artifact_namespace, | ||
artifact_name as from_artifact_name, | ||
package_artifact_id as to_package_artifact_id, | ||
package_artifact_source as to_package_artifact_source, | ||
package_artifact_name as to_package_artifact_name, | ||
package_github_owner as to_package_github_owner, | ||
package_github_repo as to_package_github_repo, | ||
package_github_artifact_id as to_package_github_artifact_id | ||
from {{ ref('int_sbom_artifacts') }} |
40 changes: 40 additions & 0 deletions
40
warehouse/dbt/models/staging/deps-dev/stg_deps_dev__packages.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,40 @@ | ||
{{ config( | ||
materialized='incremental', | ||
partition_by={ | ||
'field': 'SnapshotAt', | ||
'data_type': 'timestamp', | ||
'granularity': 'day' | ||
}, | ||
) }} | ||
|
||
{% set is_production = target.name == 'production' %} | ||
|
||
{% if is_production %} | ||
with base as ( | ||
select | ||
`SnapshotAt`, | ||
`System`, | ||
`ProjectName`, | ||
`Name`, | ||
`Version` | ||
from {{ source("deps_dev", "package_version_to_project_latest") }} | ||
where | ||
`ProjectName` is not null | ||
and `ProjectType` = 'GITHUB' | ||
and `RelationType` = 'SOURCE_REPO_TYPE' | ||
) | ||
{% if is_incremental() %} | ||
select * from base | ||
where `SnapshotAt` > (select max(`SnapshotAt`) from {{ this }}) | ||
{% else %} | ||
select * from base | ||
{% endif %} | ||
{% else %} | ||
select | ||
'NPM' as `System`, | ||
'opensource-observer/oso' as `ProjectName`, | ||
'@example/oso' as `Name`, | ||
'0.0.16' as `Version`, | ||
current_timestamp() as `SnapshotAt` | ||
limit 1 | ||
{% endif %} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd try to keep it simple, rather than add a bunch of columns now unless you absolutely need it.
FWIW, it might make more sense to have a separate model for package_ownership, rather than have this single model try to do multiple things