-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
18 additions
and
0 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
warehouse/dbt/models/intermediate/directory/int_project_owners.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,18 @@ | ||
WITH ranked_repos AS ( | ||
SELECT | ||
project_id, | ||
owner, | ||
star_count, | ||
ROW_NUMBER() OVER ( | ||
PARTITION BY project_id ORDER BY star_count DESC | ||
) AS row_number, | ||
COUNT(DISTINCT owner) OVER (PARTITION BY project_id) AS num_github_owners | ||
FROM {{ ref('stg_ossd__repositories_by_project') }} | ||
) | ||
|
||
SELECT | ||
project_id, | ||
num_github_owners, | ||
LOWER(owner) AS primary_github_owner | ||
FROM ranked_repos | ||
WHERE row_number = 1 |