Created
July 6, 2016 00:40
-
-
Save gerrywastaken/fa993de53f38b51fc3e41a6dab031d90 to your computer and use it in GitHub Desktop.
Getting a list of the most popular gems used in public gem projects on github: https://bigquery.cloud.google.com/dataset/bigquery-public-data:github_repos
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
SELECT | |
gem, | |
COUNT(*) c | |
FROM ( | |
SELECT | |
REGEXP_EXTRACT( | |
line, | |
r'.*dependency\s*[\'"]([^\'"]*)[\'"]' | |
) gem, | |
id | |
FROM ( | |
SELECT | |
SPLIT(content, '\n') line, | |
id | |
FROM [bigquery-public-data:github_repos.sample_contents] | |
WHERE | |
REGEXP_MATCH( | |
content, | |
r'.*dependency\s*[\'"][^\'"]*[\'"]' | |
) AND | |
sample_path LIKE '%.gemspec' | |
) | |
GROUP BY gem, id | |
) | |
GROUP BY 1 | |
ORDER BY c DESC | |
LIMIT 500; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm thinking there might be something wrong with the splitting part of this query as those numbers seem much lower than I would expect.