2019 GitHub 开源贡献排行榜新鲜出炉!微软谷歌领头,阿里跻身前 12!
数据来源
基础数据来自:https://www.gharchive.org
统计方法
获取 GitHub 2019 年的 PushEvent,通过分析 GitHub 用户提交记录中的邮件地址,分辨其所属组织。
具体方法参考:https://www.freecodecamp.org/news/the-top-contributors-to-github-2017-be98ab854e87
分析工具
•Google Big Query•Data Studio
SQL 语句
由于 Google Big Query 每月只能免费获取 1TB 的数据处理量,因此,为了充分利用它,我们将数据查询限制在一定的日期范围(20190301-20191001)内,确保数据处理量接近而不超过 1TB。
此日期范围内的数据可大致反映 2019 全年 GitHub 各组织开源贡献度情况。
SELECT *
FROM `githubarchive.month.2019*` a
WHERE _TABLE_SUFFIX BETWEEN '0301' AND '1001'
完整的 SQL 语句编写如下:
#standardSQL
WITH
period AS (
SELECT *
FROM `githubarchive.month.2019*` a
WHERE _TABLE_SUFFIX BETWEEN '0301' AND '1001'
),
repo_stars AS (
SELECT repo.id, COUNT(DISTINCT actor.login) stars, APPROX_TOP_COUNT(repo.name, 1)[OFFSET(0)].value repo_name
FROM period
WHERE type='WatchEvent'
GROUP BY 1
HAVING stars>20
),
pushers_guess_emails_and_top_projects AS (
SELECT *, REGEXP_EXTRACT(email, r'@(.*)') domain
FROM (
SELECT actor.id
, APPROX_TOP_COUNT(actor.login,1)[OFFSET(0)].value login
, APPROX_TOP_COUNT(JSON_EXTRACT_SCALAR(payload, '$.commits[0].author.email'),1)[OFFSET(0)].value email
, COUNT(*) c
, ARRAY_AGG(DISTINCT TO_JSON_STRING(STRUCT(b.repo_name,stars))) repos
FROM period a
JOIN repo_stars b
ON a.repo.id=b.id
WHERE type='PushEvent'
GROUP BY 1
HAVING c>3
)
)
SELECT * FROM (
SELECT domain
, githubers
, (SELECT COUNT(DISTINCT repo) FROM UNNEST(repos) repo) repos_contributed_to
, ARRAY(
SELECT AS STRUCT JSON_EXTRACT_SCALAR(repo, '$.repo_name') repo_name
, CAST(JSON_EXTRACT_SCALAR(repo, '$.stars') AS INT64) stars
, COUNT(*) githubers_from_domain FROM UNNEST(repos) repo
GROUP BY 1, 2
HAVING githubers_from_domain>1
ORDER BY stars DESC LIMIT 3
) top
, (SELECT SUM(CAST(JSON_EXTRACT_SCALAR(repo, '$.stars') AS INT64)) FROM (SELECT DISTINCT repo FROM UNNEST(repos) repo)) sum_stars_projects_contributed_to
FROM (
SELECT domain, COUNT(*) githubers, ARRAY_CONCAT_AGG(ARRAY(SELECT * FROM UNNEST(repos) repo)) repos
FROM pushers_guess_emails_and_top_projects
#WHERE domain IN UNNEST(SPLIT('google.com|microsoft.com|amazon.com', '|'))
WHERE domain NOT IN UNNEST(SPLIT('gmail.com|users.noreply.github.com|qq.com|hotmail.com|163.com|me.com|googlemail.com|outlook.com|yahoo.com|web.de|iki.fi|foxmail.com|yandex.ru', '|')) # email hosters
GROUP BY 1
HAVING githubers > 30
)
WHERE (SELECT MAX(githubers_from_domain) FROM (SELECT repo, COUNT(*) githubers_from_domain FROM UNNEST(repos) repo GROUP BY repo))>4 # second filter email hosters
)
ORDER BY githubers DESC
从下图中可以看到,本次查询统计将会处理 918.4GB 的数据。
统计结果
点击运行,经过 17.8s,我们可以看到查询结果。
顶级组织比较
从上图我们可以看出:
•微软谷歌在开源贡献度上遥遥领先,位列 3-5 位的分别是 redhat、intel 和 amazon;•微软谷歌均有超过 1000 名员工(githubers)向多个 GitHub 仓库(repos_contributed_to) push 代码;•对于微软,2019 Top3 仓库分别是 Terminal、vscode 和 TypeScript,而谷歌则是 flutter、tensorflow 和 kubernetes。
排在 6-10 位的分别是 Pivotal、Facebook、Apache、SAP 和 Shopify。
国内大厂比较
国内大厂开源贡献度最高的当属阿里员工,排在第十二位,top3 仓库分别是 flutter-go、nacos 和 sqlflow,所有项目共获得 stars 数超过 90000。
百度和腾讯则分列 21、23 位。
总览
开源贡献度前 38 位名单如下:
有什么想法,欢迎留言区与我互动。