github_meta / README.md
yilinxia's picture
Update README.md
a39ec68 verified
|
Raw
History Blame Contribute Delete
1.35 kB
---
license: osl-3.0
---
# Process to Generate DuckDB Dataset
## 1. Load Repository Metadata
- Read `repo_metadata.json` from [GitHub Public Repository Metadata](https://www.kaggle.com/datasets/pelmers/github-repository-metadata-with-5-stars/data)
- Normalize JSON into three lists:
- **Repositories** → general metadata (stars, forks, license, etc.).
- **Languages** → repo-language mappings with size.
- **Topics** → repo-topic mappings.
- Convert lists into Pandas DataFrames: `df_repos`, `df_languages`, `df_topics`.
## 2. Enhance with BigQuery Data
- Create a temporary BigQuery table (`repo_list`) containing repository names.
- Query **GitHub Archive (`githubarchive.month.2024*`)**:
- Collect contributors from `PullRequestEvent`.
- Collect stargazers from `WatchEvent`.
- Merge BigQuery results back into `df_repos`.
## 3. Preprocess for DuckDB
- Aggregate topics by repository:
- Join multiple topics into a single pipe-separated string.
- Create `df_topics_agg`.
## 4. Write to DuckDB
- Connect to DuckDB using **SQLAlchemy**.
- Write DataFrames into DuckDB:
- `repos` → enriched repository metadata.
- `repo_languages` → repo-language relations.
- `repo_topics` → aggregated topics.
- Add index on `repo_topics.topics` for faster querying:
```sql
CREATE INDEX topic_idx ON repo_topics (topics);