Skip to content

v0.1.0

Choose a tag to compare

@rustyconover rustyconover released this 02 Oct 16:52
· 34 commits to main since this release

GitHub as DuckDB tables: repositories, issues, pull requests, commits, releases, contributors and Actions runs, all read-only, and every per-repository function works inside a LATERAL join.

INSTALL vgi FROM community;
LOAD vgi;
ATTACH 'github' (TYPE vgi,
  LOCATION 'uvx --from git+https://github.com/Query-farm/vgi-github@v0.1.0 vgi-github');
CREATE SECRET github (TYPE github, token 'ghp_...');   -- optional, see below

Search, then fan out

The search functions take GitHub's own query syntax and stream results, so they make a good starting point. Each row's full_name then feeds any per-repository function:

-- Open issues across an organization's five most-starred repositories
SELECT r.full_name, count(i.number) AS open_issues
FROM (SELECT full_name FROM github.search_repositories('org:duckdb', sort => 'stars') LIMIT 5) r,
     LATERAL github.issues(r.full_name, state => 'open') i
GROUP BY r.full_name
ORDER BY open_issues DESC;

-- Where a project's top contributors say they work
SELECT c.login, c.contributions, u.company, u.location
FROM github.contributors('duckdb/duckdb', max_rows => 10) c,
     LATERAL github.user(c.login, cache_ttl => 3600) u
ORDER BY c.contributions DESC;

-- CI failure rate per workflow
SELECT name, count(*) FILTER (WHERE conclusion = 'failure') / count(*) AS failure_rate
FROM github.workflow_runs('duckdb/duckdb', status => 'completed')
GROUP BY name ORDER BY failure_rate DESC;

List functions return up to max_rows rows per input row (100 by default, which is one request). Filter with their arguments, like state =>, since => and branch =>, rather than WHERE, because a WHERE only sees the rows that were already fetched.

Authentication

Without a token GitHub allows 60 requests an hour; with one, 5,000, and private repositories become visible. Use a DuckDB secret of type github; it can have any name. Attach with auth 'required' if a missing token should be an error rather than a quiet fall back to anonymous access.

Serving over HTTP

Run one long-lived server instead of a worker per connection:

uvx --from git+https://github.com/Query-farm/vgi-github@v0.1.0 vgi-github-http --port 8000
ATTACH 'github' (TYPE vgi, LOCATION 'http://localhost:8000');
CREATE SECRET github (TYPE github, token 'ghp_...');

Each client sends its own token, and one client's token never authorizes another's queries. The server doesn't authenticate clients itself, though, so keep it on localhost or put it behind a proxy, and don't set VGI_GITHUB_TOKEN on a shared server unless you mean every client to use that token. The README covers --host, --prefix and the other options.

Known issues

  • On macOS, DuckDB 1.5's duckdb_functions() can show named arguments with each other's types. Queries are unaffected, and vgi_function_arguments() reports them correctly. A fix is proposed upstream in duckdb/duckdb#26409.
  • stargazers() only works for repositories your token administers, because GitHub refuses the listing for anyone else's. repo() still gives you stargazers_count.