Write and validate Databricks SQL queries for game analytics. Use when user needs to (1) query game event data from Databricks, (2) analyze user behavior metrics (retention, funnel, DAU), (3) explore table schemas, (4) validate SQL syntax, (5) get sample data from production tables, or (6) research log event specifications. Covers litemeta, linkpang, pkpkg, matchflavor, matchwitch, traincf games.
View on GitHubFebruary 4, 2026
Select agents to install to:
npx add-skill https://github.com/treenod-IDQ/treenod-market/blob/main/plugins/util/skills/sql-writer/SKILL.md -a claude-code --skill sql-writerInstallation paths:
.claude/skills/sql-writer/## Prerequisites
Environment variables: `DATABRICKS_HOST`, `DATABRICKS_TOKEN`
For log spec lookup: Google Cloud auth via `gcloud auth application-default login`
## Scripts
Run from skill directory.
### log_spec.py - Log Specification Lookup
```bash
uv run scripts/log_spec.py --list-games # List available games
uv run scripts/log_spec.py --game litemeta --list-sheets # List spec sheets
uv run scripts/log_spec.py --game litemeta --event stageClose # Get event spec
uv run scripts/log_spec.py --game litemeta --field playId # Search field
uv run scripts/log_spec.py --game litemeta --event login --cache # Use cache
```
### schema.py - Table Metadata
```bash
uv run scripts/schema.py <table> # Get schema
uv run scripts/schema.py --list-databases # List databases
uv run scripts/schema.py --list-tables <database> # List tables
```
### validate.py - Query Validation
```bash
uv run scripts/validate.py -q "<sql>" # Validate query
uv run scripts/validate.py -f query.sql --check-tables # Check tables exist
```
### sample.py - Execute Query
Requires partition filter (`dt`, `log_date`) to prevent full table scans.
```bash
uv run scripts/sample.py -q "SELECT * FROM table WHERE dt = '2024-01-01' LIMIT 10"
uv run scripts/sample.py -f query.sql --limit 100 --output results.csv
uv run scripts/sample.py -q "..." --no-filter-check # Skip filter check (caution)
```
## References
- `references/index.md` - Database overview and common schema
- `references/log-specs.md` - Log specification sources and event documentation
- `references/{game}_production.md` - Table catalogs per game
Database catalogs:
- `litemeta_production.md` - 46 tables
- `linkpang_production.md` - 39 tables
- `pkpkg_production.md` - 36 tables
- `matchflavor_production.md` - 10 tables
- `matchwitch_production.md` - 4 tables
- `traincf_production.md` - 4 tables
## Workflow
### Standar