US patent US12801599
LLM-generated text-to-SQL verification via directional graphs
Abstract
Described is a system for updating an LLM-generated SQL query preventing double counting by receiving a natural language query from a user at a cloud-based server, where the query requests access to data in a database. The data platform identifies semantic data from the query and, using a large language model (LLM), generates a SQL query containing join functions. The SQL query is then parsed to identify operation types and data sources. An undirected graph is constructed from the parsed query, with nodes representing data sources and edges representing join functions. The undirected graph is converted to a directed graph by adding relationship characteristics to the edges. Based on this directed graph, the data platform validates the SQL query to detect and resolve potential double counting issues and updates the SQL query as necessary to ensure accurate results.