Skip to content

Instantly share code, notes, and snippets.

@swegner
Last active November 11, 2016 21:51
Show Gist options
  • Save swegner/477026625c98f507a7246bca4793ae51 to your computer and use it in GitHub Desktop.
Save swegner/477026625c98f507a7246bca4793ae51 to your computer and use it in GitHub Desktop.
2016 Top Repositories by Pull Requests Opened
WITH pull_requests AS (
SELECT
e.repo.name AS repo,
COUNT(*) AS pr_count
FROM `githubarchive.day.2016*` AS e
WHERE e.type = 'PullRequestEvent' AND STARTS_WITH(e.payload, '{"action":"opened"')
GROUP BY e.repo.name
)
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