I gave my text-to-SQL agent a ... Note

I gave my text-to-SQL agent a business glossary. One version helped a lot, one did nothing.

Text-to-SQL agents often struggle with understanding business terms that don't directly match table or column names, leading to incorrect query results. SchemaGate 1.2.0 introduces business terms to improve these agents' accuracy. These terms can be explicitly defined with synonyms, mappings to database columns, and associated filter rules. For example, "revenue" can be mapped to billing_invoice.total_net with a status filter. This process helps the agent identify relevant tables and understand the meaning of specific business concepts. Terms can also have hierarchical relationships, affecting table inclusion weights. Business terms can be imported from various sources like dbt, Snowflake, or CSV exports, and can also be learned from past question-SQL pairs. SchemaGate's primary function is access control, hiding unauthorized tables and columns before the agent sees them. To prevent data leakage, meaning lines for business terms are omitted if the caller cannot access all the underlying tables and columns. Experiments on the BIRD dataset showed a significant accuracy improvement of 10 percentage points when a complete glossary was provided, while terms learned from other questions had no impact. For the Retrieval task on Spider, learned terms improved table recall. In essence, manually defining key business terms is crucial for improving query accuracy, particularly for understanding formulas, and learned terms are more effective for table discovery. Adding terms to the prompt requires careful consideration of user permissions. SchemaGate is available as an open-source project, supporting multiple databases and integration options.