DataBrain Intelligence Text2SQL
Translate natural language questions about game market intelligence into executable BigQuery SQL using the DataLab HTTP API.
Hard Constraints
- Read-only:
SELECT/WITH ... SELECTonly — neverINSERT,UPDATE,DELETE,DROP,CREATE,MERGE,TRUNCATE - Always end with
LIMIT(default 5000) datemust always be filtered — allintelligencetables partition bydate; omitting it causes full-table scans and timeouts. Exception:benchmarkschema tables (especiallybenchmark.benchmark_detail) have nodatepartition — uselast_update_dateonly when freshness matters; never addWHERE date = ...on benchmark tables.- Data reliability: always use an explicit date range (
WHERE date BETWEEN '<start>' AND '<end>'), never query without a time boundary. Without a date range, the result is an opaque all-time aggregate — the user cannot tell what time period the numbers cover, making the data uninterpretable and untrustworthy. Exception: same as above —benchmarktables have nodatecolumn; apply this rule only tointelligenceschema tables. - BigQuery only — all
FROMclauses requireschema.tableprefix; never bare table names
Core Tools
| Script | Purpose |
|--------|---------|
| scripts/execute_sql.py | Execute read-only SQL, returns results |
| scripts/search_entity.py | Search DataBrain entities by name — games AND companies/developers/publishers (e.g. "SYBO", "miHoYo"). Returns mobile_id / pc_id / combine_id / entity_id depending on entity_type. Faster & more accurate than SQL LIKE. |
| scripts/fetch_steam_ccu.py | Live Steam CCU via Steam Web API (GetNumberOfCurrentPlayers). Resolve combined_id → steam_id via SQL, then HTTP. Pair with warehouse SQL for trends — see