Forked from swegner/2016 Top Repositories by Pull Requests Opened.sql
Last active
March 31, 2017 00:52
-
-
Save dhalperi/56ac92edac8bf0bcd76b3e51d726429d to your computer and use it in GitHub Desktop.
2016 Top Repositories by Pull Requests Opened
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
WITH since_incubation AS ( | |
SELECT * FROM `githubarchive.day.201*` | |
WHERE _TABLE_SUFFIX > '60131' -- after 2016-01-31 since Beam started incubating on 2016-02-01 | |
), | |
pull_requests AS ( | |
SELECT | |
-- map a podling to its final name | |
replace(e.repo.name, "incubator-", "") AS repo, | |
COUNT(*) AS pr_count | |
FROM since_incubation AS e | |
WHERE e.type = 'PullRequestEvent' AND STARTS_WITH(e.payload, '{"action":"opened"') | |
AND e.org.login = 'apache' | |
GROUP BY repo | |
) | |
SELECT | |
pr.repo, | |
pr.pr_count, | |
RANK() OVER w AS `rank`, | |
100 * PERCENT_RANK() OVER w AS percentile | |
FROM pull_requests pr | |
WINDOW w AS (ORDER BY pr.pr_count DESC) | |
ORDER BY pr.pr_count DESC | |
LIMIT 200 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment