x-lab2017/open-digger/open-digger-clickhouse-schema

Claude Code and agent skill by x-lab2017/open-digger

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

Reference for the OpenDigger ClickHouse database schema (database `opensource`). Use this skill when writing, reviewing, or debugging SQL against the OpenDigger backend store — e.g. querying the `events` table, OpenRank/contribution rankings (`global_openrank`, `community_openrank`, `normalized_community_openrank`), repo/user metadata (`repo_info`, `user_info`), labels, location data, or AI analysis tables (`issue_info`, `pull_info`). It explains every core table's purpose, engine, sort/partition keys, key columns, the materialized views, and how the tables relate, so you can write correct, performant ClickHouse queries.

Install

npx vskill@latest install x-lab2017/open-digger/open-digger-clickhouse-schema

SKILL.md

OpenDigger ClickHouse 数据库表结构

OpenDigger 使用 ClickHouse 作为核心数据存储,数据库名固定为 `opensource`。所有开源指标(OpenRank、活跃度、协作网络等)都从底层事件数据计算而来。

平台维度统一用 platform 字段标识,支持多平台:GitHub、Gitee、GitLab、AtomGit(字段值为对应平台名,如 'GitHub'、'Gitee'、'AtomGit')。

编写查询时务必带上 platform 条件,绝大多数表的排序键都以 platform 或包含 platform 来过滤。

1. 核心表总览

表名用途引擎
events最核心,所有平台事件日志,全部指标的数据源ReplacingMergeTree(from_api)
repo_info仓库元信息ReplacingMergeTree
user_info用户信息视图(标准化国家/省市,推荐查询用)MergeTree(物化视图)
global_openrank全局 OpenRank 排名MergeTree
community_openrank社区级贡献排名(Neo4j 图算法计算)MergeTree
normalized_community_openrank归一化社区贡献度(全域横向可比)MergeTree
normalized_community_openrank_with_bot上者的含 Bot 变体MergeTree
export_repo待导出静态文件的仓库列表ReplacingMergeTree
export_user待导出静态文件的用户列表ReplacingMergeTree
labels分层标签体系ReplacingMergeTree
location_info用户位置地理编码结果ReplacingMergeTree
issue_infoAI 生成的 Issue 质量分析ReplacingMergeTree
pull_infoAI 生成的 PR 质量分析ReplacingMergeTree
pull_diff缓存 PR diff 内容ReplacingMergeTree

2. events 表(最核心)

  • 用途: 存储所有平台的事件日志,是所有指标计算的基础数据源。
  • 引擎: ReplacingMergeTree(from_api) —— 以 from_api 作为版本列去重。
  • 分区: toYYYYMM(created_at)(按月分区)。
  • 主键/排序键:

(platform, org_id, repo_id, actor_id, type, action, toYear(created_at), toYYYYMM(created_at))

  • type 枚举值(12 种):

CommitCommentEvent、ForkEvent、ReleaseEvent、IssueCommentEvent、IssuesEvent、PullRequestEvent、PullRequestReviewCommentEvent、PushEvent、WatchEvent、PullRequestReviewEvent、IssuesReactionEvent、IssueCommentsReactionEvent

  • action 常见值: opened、closed、created、started、added、published 等(不同 type 对应不同 action)。
主要字段分组

events 表有 80+ 字段,按事件类型组织。完整字段列表见 [events-table-reference.md](events-table-reference.md)。分组概览:

  • 基础字段:platform、type、action、actor_id/login、repo_id/name、org_id/login、created_at
  • Issue/PR 通用字段:issue_id、issue_number、issue_title、body、issue_labels、issue_author_*、issue_assignee*、时间戳等
  • Issue Comment 字段:issue_comment_*
  • PR 特有字段:pull_commits、pull_additions、pull_deletions、pull_merged、pull_merged_*、pull_base_ref、pull_head_* 等
  • PR Review 字段:pull_review_state、pull_review_id、pull_review_author_association
  • PR Review Comment 字段:pull_review_comment_*
  • Push 字段:push_id、push_size、push_distinct_size、push_ref、push_head、push_commits
  • Fork 字段:fork_forkee_*
  • Release 字段:release_*
  • Commit Comment 字段:commit_comment_*
  • 元数据:from_api(0=日志采集,1=API采集)
关键提示:events 表很大,查询务必加 platform + 时间范围(created_at 或 toYYYYMM(created_at))+ type 条件以命中分区与排序键。同一记录可能因采集方式不同而存在多版本,统计精确值时按需用 argMax(..., created_at) 或子查询去重。对于仓库、组织、开发者的查询,除必要情况外尽量使用平台 ID 为条件查询。

3. repo_info 表

  • 用途: 仓库元信息(主要来自 GitHub API)。
  • 引擎: ReplacingMergeTree
  • 排序键: (platform, id, updated_at)
字段类型说明
platformLowCardinality(String)平台
idUInt64仓库 ID
statusEnum('normal'=1, 'not_found'=2)抓取状态
updated_atDateTime更新时间(版本列)
descriptionString仓库描述
default_branchLowCardinality(String)默认分支
homepage_urlString主页 URL
isForkUInt8是否 Fork 仓库
primary_languageString主语言
licenseLowCardinality(String)许可证
languagesArray(LowCardinality(String))语言列表
license_spdx_idLowCardinality(String)SPDX 许可证 ID
topicsArray(String)主题标签
readme_textStringREADME 文本
created_atDateTime仓库创建时间

4. user_info 视图(用户查询首选)

  • 用途: 标准化用户信息视图,国家/省市已通过 labels(Division 标签)标准化,可直接用于按地域聚合查询。
  • 类型: 物化视图(REFRESH EVERY 3 HOUR)
  • 引擎: MergeTree()
  • 排序键: (id, platform)
  • 数据来源: gh_user_info(GitHub 原始用户表)+ global_openrank(取最新 login)+ location_info(地理编码)+ labels(Division-0/1 国家/省份标签匹配)
字段类型说明
platformLowCardinality(String)平台
idUInt64用户 ID
loginString用户登录名(取最新)
bioString简介
emailString邮箱
nameString姓名
companyString公司
twitter_usernameStringTwitter 用户名
locationString原始位置文本
country_idLowCardinality(String)国家标签 ID(如 :divisions/China)
countryLowCardinality(String)国家英文名(标准化)
country_zhLowCardinality(String)国家中文名(标准化)
province_idLowCardinality(String)省份标签 ID
provinceLowCardinality(String)省份英文名(标准化)
province_zhLowCardinality(String)省份中文名(标准化)
cityString城市
注意:gh_user_info 是 GitHub 平台原始用户表(含未标准化的 location 文本),一般情况下不要直接查询 gh_user_info,而应查询 user_info 视图获取标准化后的地域信息。

5. global_openrank 表

  • 用途: 全局 OpenRank 排名,基于所有仓库的贡献行为计算。
  • 引擎: MergeTree
  • 排序键: (repo_id, actor_id, org_id, platform, created_at)
字段类型说明
platformLowCardinality(String)平台
repo_idUInt64仓库 ID
repo_nameLowCardinality(String)仓库全名
actor_idUInt64用户 ID
actor_loginLowCardinality(String)用户登录名
org_idUInt64组织 ID
org_loginLowCardinality(String)组织名
typeEnum('Repo'=1, 'User'=2)行类型
created_atDateTime月份时间(按月一条)
openrankFloatOpenRank 值

6. community_openrank 表

  • 用途: 社区级贡献排名,通过 Neo4j 图算法计算。
  • 引擎: MergeTree
  • 排序键: (repo_id, created_at)
字段类型说明
platformLowCardinality(String)平台
repo_idUInt64仓库 ID
repo_nameLowCardinality(String)仓库全名
org_idUInt64组织 ID
org_loginLowCardinality(String)组织名
actor_idUInt64用户 ID
actor_loginLowCardinality(String)用户登录名
issue_numberUInt32关联的 Issue/PR 编号
created_atDateTime月份时间
openrankFloat社区 OpenRank 值
refinedUInt8是否为精炼结果

7. normalized_community_openrank 表(重点)

  • 用途: 归一化社区贡献度,提供全域横向可比的归一化贡献度数据。
  • 来源脚本: src/scripts/importNormalizedCommunityOpenrank.ts
  • 计算依据: 基于 events + global_openrank + community_openrank 计算;当某仓库未计算社区 OpenRank 时,使用 activity(活跃度)作为兜底。
  • 引擎: MergeTree()
  • 排序键: (repo_id, platform)
字段类型说明
platformLowCardinality(String)平台
repo_idUInt64仓库 ID
repo_nameLowCardinality(String)仓库全名
org_idUInt64组织 ID
org_loginLowCardinality(String)组织名
actor_idUInt64用户 ID
actor_loginLowCardinality(String)用户登录名
openrankFloat归一化贡献度
yyyymmUInt32年月(如 202501)
created_atDateTime时间

变体表 `normalized_community_openrank_with_bot`:字段与上表完全一致,并在 openrank 之后额外包含一列 is_bot UInt8(是否为 Bot 账号)。排除 Bot 时查无 bot 表,需要含 Bot 数据时查 with_bot 表。

8. export_repo / export_user 表

标记需要导出到静态文件的对象(仓库 openrank > 5 或带标签的仓库)。

export_repo — 引擎 ReplacingMergeTree,排序键 (id, platform):

字段类型说明
idUInt64仓库 ID
platformLowCardinality(String)平台
repo_nameLowCardinality(String)仓库全名
org_idUInt64组织 ID

export_user — 引擎 ReplacingMergeTree,排序键 (id, platform):

字段类型说明
idUInt64用户 ID
platformLowCardinality(String)平台
actor_loginLowCardinality(String)用户登录名

9. labels 表

  • 用途: 分层标签体系,将仓库/组织/用户归类到 Project / Company / University / Foundation / Agency / Tech / Division 等类别。
  • 引擎: ReplacingMergeTree
  • 排序键: id
字段类型说明
idString标签 ID(如 :companies/alibaba)
typeLowCardinality(String)标签类型(如 Company、Division-0)
nameString名称
name_zhString中文名称
descriptionString描述
description_zhString中文描述
childrenArray(String)子标签 ID 列表(构成层级)
platformsNested(name, type, orgs Array(UInt64), repos Array(UInt64), users Array(UInt64))各平台下关联的组织/仓库/用户
dataStringJSON 扩展数据(见下方说明)
labels.data 字段重要内容

对于国家级标签(type = 'Division-0'),data JSON 中包含重要的 developers 数组,记录了该国家在 GitHub InnovationGraph 中从 2020 年 Q1 开始每季度的 GitHub 平台注册开发者总量。这是做宏观分析时非常有用的官方数据。

JSON 结构示例(labels.data 字段内容):

json
{
"developers": [
{"year": 2020, "quarter": 1, "count": "6709883"},
{"year": 2020, "quarter": 2, "count": "7200238"},
...
{"year": 2025, "quarter": 4, "count": "16099348"}
],
"includes": ["China", "CN", "156", "中国"],
...
}
  • developers[-1].count:该国家最新一个季度的 GitHub 注册开发者总量
  • includes:国家名称的多种写法(用于 user_info.country 匹配)

典型用途:计算 OpenDigger 已追踪开发者占各国 GitHub 总开发者的比例(“覆盖倍率”)。

10. location_info 表

  • 用途: 用户位置文本的地理编码结果(通过 Google Maps API)。
  • 引擎: ReplacingMergeTree
  • 排序键: (location)
字段类型说明
locationString原始位置文本(关联键)
statusEnum('normal'=1, 'invalid'=2)解析状态
countryLowCardinality(String)国家
administrative_area_level_1LowCardinality(String)一级行政区(省/州)
administrative_area_level_2LowCardinality(String)二级行政区(市)
localityLowCardinality(String)城市/地区
longitudeFloat32经度
latitudeFloat32纬度

11. issue_info 表(AI 分析)

  • 用途: AI(Qwen LLM)生成的 Issue 质量分析。
  • 引擎: ReplacingMergeTree,排序键 (id, platform)
字段类型说明
idUInt64Issue 平台 ID
platformLowCardinality(String)平台
information_qualityEnum(Very Low=1 ... Very High=5)信息质量(1-5)
is_automatically_generatedEnum('Yes'=1, 'Uncertain'=2, 'No'=3)是否自动生成
hostile_or_abusiveEnum('No'=1, 'Yes'=2)是否含敌意/辱骂

12. pull_info 表(AI 分析)

  • 用途: AI(Qwen LLM)生成的 PR 质量分析。
  • 引擎: ReplacingMergeTree,排序键 (id, platform)
字段类型说明
idUInt64PR 平台 ID
platformLowCardinality(String)平台
code_qualityUInt8代码质量(1-5)
pr_title_and_description_qualityUInt8标题与描述质量(1-5)
pr_typeLowCardinality(String)PR 类型
value_levelUInt8价值等级(1-5)
primary_languageLowCardinality(String)主语言
is_automatically_generatedEnum('Yes'=3, 'Uncertain'=2, 'No'=1)是否自动生成
hostile_or_abuseEnum('Yes'=2, 'No'=1)是否含敌意/辱骂
reasoningString分析理由

13. pull_diff 表

  • 用途: 缓存 PR 的 diff 内容供分析使用。
  • 引擎: ReplacingMergeTree,排序键 (id)
字段类型说明
idUInt64PR 平台 ID
platformLowCardinality(String)平台
statusEnum('normal'=1, 'not_found'=2)抓取状态
updated_atDateTime更新时间(版本列)
diffStringPR diff 内容

14. 物化视图(Materialized Views)

来源脚本 src/scripts/createViews.ts,均使用 ClickHouse REFRESH 周期刷新。

视图名用途刷新频率关键来源
user_info标准化用户画像(已在第 4 节详述)每 3 小时gh_user_info + global_openrank + location_info + labels
name_info仓库/组织/用户的名称与累计 OpenRank每天global_openrank
flatten_labels扁平化标签映射(entity_id / entity_type / platform)每天labels
pulls_with_label带标签仓库上的 PR 列表(2025+,已排除 Bot)每小时events + flatten_labels
issues_with_label带标签仓库上的 Issue 列表(2025+)每小时events + flatten_labels
label_hierarchy标签父子层级关系每天labels(递归 CTE)

flatten_labels 关键列:id(标签ID)、type、name、name_zh、platform、entity_id(UInt64)、entity_type(Enum8 Repo=1/Org=2/User=3)。它是把 labels 的 platforms 嵌套结构展开成「标签 ↔ 实体」一对一行的桥接视图,标签相关查询基本都走它。

15. 表关联关系

  • events.repo_id → repo_info.id / export_repo.id / global_openrank.repo_id
  • events.actor_id → user_info.id / export_user.id / global_openrank.actor_id
  • events.org_id → 标签(经 flatten_labels 关联到 labels)
  • global_openrank + community_openrank → normalized_community_openrank
  • gh_user_info → user_info(视图聚合了 gh_user_info + location_info + labels + global_openrank)
  • labels → flatten_labels → pulls_with_label / issues_with_label
  • events.issue_id → pull_info.id / issue_info.id / pull_diff.id(AI 分析与 diff 缓存)

This is the start of the file. Read the full SKILL.md on GitHub.

Security

  • Security scanPassed, 95 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

Repository stars
360
Repository forks
99
7-day trend score
29

Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/x-lab2017/open-digger/open-digger-clickhouse-schema/badge)](https://verified-skill.com/skills/x-lab2017/open-digger/open-digger-clickhouse-schema)

Something wrong with this skill or its page? Tell us.