Public dataset · Web, code and analytics
GitHub Repos in BigQuery
The github_repos dataset holds file contents, file paths, commits, languages and licenses from about 2.9 million open source GitHub repositories. The full tables run to 2.4 TiB for contents alone, so a code search can cost over $16, while the sample_* tables let you test the same SQL for cents.
bigquery-public-data.github_repos is a snapshot of public, open source licensed repositories on GitHub: about 2.9 million of them, according to the dataset description, which gives 2022-11-27 as the last data update. The files, contents, languages and licenses tables were last modified in November 2022; commits was last modified in October 2025.
files lists every file at HEAD with its repository and path. contents stores the text of each unique file under 1 MiB, keyed by id, so you join files to contents on id to search code. commits has one row per unique commit with author, committer, message and the list of changed paths, and repo_name is an array because the same commit can appear in several repositories. languages and licenses have one row per repository.
The four sample_* tables were built in 2016 for cheap experiments: sample_repos is 400,000 popular repositories, sample_files holds their files, sample_contents is a random 10% of matching contents, and sample_commits covers six large projects (tensorflow, react, bootstrap, swift, vscode and the Linux kernel). None of the tables is partitioned or clustered.
Tables and sizes
| Table | Rows | Size | Full scan | Layout |
|---|---|---|---|---|
contentsText of unique files under 1 MiB on the HEAD branch. Join to `files` on `id`. | 281,191,977 | 2.4 TiB | $15.25 | None |
commitsUnique commits, with `repo_name` as an array of repositories that contain them. | 265,419,190 | 848 GiB | $5.18 | None |
filesPath, mode and content `id` of every file at HEAD. | 2,309,424,945 | 321 GiB | $1.96 | None |
sample_contentsRandom 10% of contents for files in `sample_files` (2016). | 2,905,870 | 24.0 GiB | $0.15 | None |
sample_filesFiles of the 400,000 repositories in `sample_repos` (2016). | 72,879,442 | 10.0 GiB | $0.06 | None |
sample_commitsCommits of six large repositories (2016). | 672,309 | 2.5 GiB | $0.02 | None |
languagesLanguages per repository with bytes of code, from the GitHub API. | 3,325,634 | 195 MiB | under $0.01 | None |
licensesSPDX license code per repository. | 3,325,634 | 103 MiB | under $0.01 | None |
sample_repos400,000 repositories with more than 2 stars in January to May 2016. | 400,000 | 12.5 MiB | under $0.01 | None |
Example queries
Most common languages by repository count
language is a repeated record, so UNNEST it first. A repository counts once for every language GitHub detected in it.
SELECT
lang.name AS language,
COUNT(*) AS repos
FROM `bigquery-public-data.github_repos.languages`,
UNNEST(language) AS lang
GROUP BY language
ORDER BY repos DESC
LIMIT 10;Repositories per license
One of the cheapest useful queries on the dataset: licenses is about 100 MiB.
SELECT
license,
COUNT(*) AS repos
FROM `bigquery-public-data.github_repos.licenses`
GROUP BY license
ORDER BY repos DESC;Commits per year
Reads one nested field, committer.time_sec, out of an 848 GiB table. Git timestamps come from the committer's machine, so expect a few commits with impossible years.
SELECT
EXTRACT(YEAR FROM TIMESTAMP_SECONDS(committer.time_sec)) AS year,
COUNT(*) AS commits
FROM `bigquery-public-data.github_repos.commits`
GROUP BY year
ORDER BY year;Find Python files that import the BigQuery client (full tables)
This is the expensive version. The LIKE on content forces a read of the whole content column, and LIMIT 100 does not stop the scan. It is more than the free monthly TiB on its own.
SELECT f.repo_name, f.path
FROM `bigquery-public-data.github_repos.files` AS f
JOIN `bigquery-public-data.github_repos.contents` AS c
ON f.id = c.id
WHERE f.path LIKE '%.py'
AND c.content LIKE '%from google.cloud import bigquery%'
LIMIT 100;The same search on the sample tables
Identical SQL against sample_files and sample_contents. It covers only a sample of popular repositories, but it costs about 1% of the full search, which makes it the right place to debug the pattern before a single full run.
SELECT f.repo_name, f.path
FROM `bigquery-public-data.github_repos.sample_files` AS f
JOIN `bigquery-public-data.github_repos.sample_contents` AS c
ON f.id = c.id
WHERE f.path LIKE '%.py'
AND c.content LIKE '%from google.cloud import bigquery%'
LIMIT 100;Querying it cheaply
contents.contentis where the bytes are: 2.4 TiB of file text. AnyLIKE,REGEXP_CONTAINSorSELECT *oncontentsreads all of it, whateverWHEREorLIMITyou add.- No table is partitioned or clustered, so filtering on
repo_nameorpathdoes not cut bytes. Only the columns you select change the cost. - Write and test code searches on
sample_filesandsample_contents(about 34 GiB together), then run the full query once. - For repeated analysis of one slice, such as Python files only, save it once with CREATE TABLE AS SELECT and query your copy. You then pay storage for the slice instead of rescanning 2.4 TiB.
- Set a maximum bytes billed on exploratory queries. A query over the limit fails before it runs and costs nothing (see the bytes billed limit error).
FAQ
How much does it cost to query the GitHub dataset in BigQuery?
It depends on the columns. Counting languages or licenses reads under 200 MiB, which fits easily in the free tier. Searching file text joins files and contents and reads about 2.7 TiB, roughly $16.82 at the $6.25 per TiB on-demand list price before your free TiB.
Is the github_repos dataset free?
Yes for storage: the table sits in the bigquery-public-data project and Google pays to store it. You pay for the queries you run from your own project. On-demand, the first 1 TiB scanned each month is free, then you pay per TiB scanned (see BigQuery pricing).
Is the GitHub dataset up to date?
No. The dataset description gives 2022-11-27 as the last data update, and the file and content tables have not changed since November 2022. Treat it as a historical snapshot of open source code, not a live mirror of GitHub.
Why does LIMIT not make my github_repos query cheaper?
On-demand billing counts the bytes of every column BigQuery reads, and LIMIT is applied after the scan. To pay less, select fewer columns or use the sample_* tables.
Related datasets
All public datasets · BigQuery cost queries · Pricing calculator
