.claude/skills/debug-sql/SKILL.md
Debug SQL errors and unexpected results. Use when pipeline fails or produces wrong data.
npx skillsauth add praveenmaiya/holley-rec debug-sqlInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Diagnoses and fixes SQL issues in the recommendation pipeline.
| Error Pattern | Likely Cause | Fix | |---------------|--------------|-----| | "Column not found" | Case sensitivity (ProductId vs ProductID) | Check exact column name | | "Division by zero" | Missing NULLIF or SAFE_DIVIDE | Use SAFE_DIVIDE() | | "Invalid regex" | BigQuery regex syntax | Use [0-9] not \d | | "Bytes exceeded" | Missing partition filter | Add date filter early | | "Duplicate rows" | Missing DISTINCT or GROUP BY | Add dedup logic | | "No matching signature" | Type mismatch | Check COALESCE(string_value, long_value) | | "Resources exceeded" | Query too complex | Break into smaller CTEs |
Run CTEs incrementally to find which step fails:
# Test step 0 - users with vehicles
bq query --use_legacy_sql=false "
WITH users_with_v1_vehicles AS (
SELECT DISTINCT
LOWER(email) as email_lower,
v1_year, v1_make, v1_model
FROM \`auxia-gcp.company_1950.ingestion_unified_attributes_schema_incremental\`
WHERE email IS NOT NULL
AND v1_year IS NOT NULL
AND v1_make IS NOT NULL
AND v1_model IS NOT NULL
LIMIT 100
)
SELECT COUNT(*) as user_count FROM users_with_v1_vehicles
"
# Test step 1 - eligible parts
bq query --use_legacy_sql=false "
-- Run eligible_parts CTE and count
SELECT COUNT(*) FROM ... LIMIT 1
"
Case 1: Empty results
-- Check if source tables have data
SELECT COUNT(*) FROM `source_table` WHERE date_filter
Case 2: Too many rows (explosion)
-- Check for missing join keys causing cross join
SELECT COUNT(*) as row_count, COUNT(DISTINCT key) as key_count FROM table
Case 3: Wrong values
-- Sample data to inspect
SELECT * FROM intermediate_cte LIMIT 10
Always dry-run before full execution:
bq query --dry_run --use_legacy_sql=false < sql/recommendations/v5_17_*.sql
Then run QA checks after:
bq query --use_legacy_sql=false < sql/validation/qa_checks.sql
agent_docs/bigquery.md - Known gotchas and patternssql/recommendations/v5_17_vehicle_fitment_recommendations.sql - Pipelinesql/validation/qa_checks.sql - Validation suitetesting
Generate a team-facing weekly status update from STATUS_LOG.md and git history.
testing
Run QA validation checks on the recommendation pipeline output. Use after pipeline runs to verify data quality.
research
Compare Personalized vs Static treatment performance with unbiased methodology. Use for A/B analysis and treatment comparison.
testing
Show current pipeline and deployment status. Use for quick health check.