IP Library › Granted Patent US 12,657,187
Granted Patent B2
US 12,657,187 · App. 18/805,437 · Granted Jun 16, 2026

Text-to-structured query language query generation using query logs and data profiling

Inventors: Theodore Johnson (New York, NY); Vladislav Shkapenyuk (New York, NY); Divesh Srivastava (Summit, NJ)
Assignee: AT&T Intellectual Property I, L.P.
G06F16/24522G06F16/243
View Patent ↗
Loading inventors, assignments & file history…
Monitor This Case
Get email alerts when status or documents change.
Order Certified Copies
Most orders are placed with the USPTO same day — all within 24 business hours.
Order via The Patent Place →
Pre-filled with this patent's details
Quick Facts
Patent No.
US 12,657,187
App. No.
18/805,437
Granted
Jun 16, 2026
Kind
B2
Abstract

In one example, a method performed by a processing system including at least one processor includes automatically inferring metadata about a structured query language database, constructing, based on the metadata, a prompt for generating a new structured query language query to be executed against the structured query language database, and providing the prompt to a language model for use in generating the new structured query language query.

Claims (38)

1 . A method comprising:

performing, by a processing system including at least one processor, a statistical analysis over a plurality of fields of a plurality of tables contained in a structured query language database to generate a profile for the structured query language database, wherein the statistical analysis comprises:

collecting, by the processing system, a plurality of sample values from a field of the plurality of fields, wherein the plurality of sample values is collected using an approximation technique to minimize an amount of memory needed to store the plurality of sample values;

submitting, by the processing system to a language model, a description of contents of a table of the plurality of tables in which the field is contained, a name of the field, and a request to summarize the plurality of sample values; and

receiving, by the processing system from the language model, a summarization of the field, wherein the summarization of the field is used to generate a prompt; and

constructing, by the processing system, the prompt for the language model, wherein the language model is trained to generate a new structured query language query to be executed against the structured query language database, using data from the profile.

2 . The method of claim 1 , wherein the performing statistical analysis comprises determining:

a number of records in a table of the plurality of tables.

3 . The method of claim 1 , wherein the plurality of values comprises at least one of: a count of distinct values contained in the each field or a most frequent value contained in the each field.

4 . The method of claim 1 , wherein the performing statistical analysis comprises determining, for each field of the plurality of fields that is contained in the table, a count of non-null values contained in the each field.

5 . The method of claim 1 , wherein the performing statistical analysis comprises determining, for each field of the plurality of fields that is contained in the table, a count of distinct values contained in the each field.

6 . The method of claim 1 , wherein the performing statistical analysis comprises determining, for each field of the plurality of fields that is contained in the table, a minimum value contained in the each field.

7 . The method of claim 1 , wherein the performing statistical analysis comprises determining, for each field of the plurality of fields that is contained in the table, a maximum value contained in the each field.

8 . The method of claim 1 , wherein the performing statistical analysis comprises determining, for each field of the plurality of fields that is contained in the table, a most frequent value contained in the each field.

9 . The method of claim 8 , wherein a skewness of the each field is estimated from the most frequent value contained in the each field.

10 . The method of claim 9 , wherein the each field is assumed to be skewed when a top number of most frequent values occur in the each field at least a threshold number of times that is expected from a uniform distribution of values.

11 . The method of claim 1 , wherein the performing statistical analysis comprises determining a data pattern occurring across the plurality of fields.

12 . The method of claim 11 , wherein the data pattern comprises an observed typical field length.

13 . The method of claim 11 , wherein the data pattern comprises a use of uppercase versus lowercase characters.

14 . The method of claim 11 , wherein the data pattern comprises an occurrence of characters that are neither alphabetic nor numeric.

15 . The method of claim 11 , wherein the data pattern comprises repeated prefixes or suffixes.

16 . The method of claim 1 , wherein the performing statistical analysis comprises determining, for each pair of fields in the plurality of fields, a resemblance between the each pair of fields.

17 . The method of claim 16 , wherein the resemblance is calculated as a min hash.

18 . The method of claim 17 , wherein the min hash is expanded to estimate a containment of the each pair of fields.

19 . A non-transitory computer readable medium storing instructions which, when executed by a processing system including at least one processor, cause the processing system to perform operations, the operations comprising:

performing a statistical analysis over a plurality of fields of a plurality of tables contained in a structured query language database to generate a profile for the structured query language database, wherein the statistical analysis comprises:

collecting a plurality of sample values from a field of the plurality of fields, wherein the plurality of sample values is collected using an approximation technique to minimize an amount of memory needed to store the plurality of sample values;

submitting, to a language model, a description of contents of a table of the plurality of tables in which the field is contained, a name of the field, and a request to summarize the plurality of sample values; and

receiving, from the language model, a summarization of the field, wherein the summarization of the field is used to generate a prompt; and

constructing the prompt for the language model, wherein the language model is trained to generate a new structured query language query to be executed against the structured query language database, using data from the profile.

20 . An apparatus comprising:

a processing system including at least one processor; and

a non-transitory computer readable medium storing instructions which, when executed by the processing system, cause the processing system to perform operations, the operations comprising:

performing a statistical analysis over a plurality of fields of a plurality of tables contained in a structured query language database to generate a profile for the structured query language database, wherein the statistical analysis comprises:

collecting a plurality of sample values from a field of the plurality of fields, wherein the plurality of sample values is collected using an approximation technique to minimize an amount of memory needed to store the plurality of sample values;

submitting, to a language model, a description of contents of a table of the plurality of tables in which the field is contained, a name of the field, and a request to summarize the plurality of sample values; and

receiving, from the language model, a summarization of the field, wherein the summarization of the field is used to generate a prompt; and

constructing the prompt for the language model, wherein the language model is trained to generate a new structured query language query to be executed against the structured query language database, using data from the profile.

Assignments (1)
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Aug 15, 2024
From: JOHNSON, THEODORE; SHKAPENYUK, VLADISLAV; SRIVASTAVA, DIVESH
To: AT&T INTELLECTUAL PROPERTY I, L.P.
Reel/Frame 068299/0653 →
Continuity (1)
Related Publication 20260050591A1 · Feb 19, 2026
References Cited (10)
US 20220198294A1 · Schneuwly · 2022 [cited by examiner]
US 20220261228A1 · Schneuwly · 2022 [cited by examiner]
US 20230128200A1 · Clement · 2023 [cited by examiner]
US 20230186161A1 · Arthur · 2023 [cited by examiner]
CN 114020768A · 2022 [cited by examiner]
Liu, A Survey of NL2SQL with Large Language Models: Where are we, and where are we going? pp. 1-31, Aug. 9, 2024. [cited by examiner]
Maamari, End-to-end Text-to-SQL Generation within an Analytics Insight Engine, pp. 1-6, Jun. 17, 2024. [cited by examiner]
Yu, SyntaxSQLNet: Syntax Tree Networks for Complex and Cross-Domain Text-to-SQL Task, pp. 1-11, Oct. 25, 2018. [cited by examiner]
Kumar, Deep Learning Driven Natural Languages Text to SQL Query Conversion: A Survey, pp. 1-18 (Year: 2022). [cited by examiner]
Pourreza DIN-SQL: Decomposed In-Context Learning of Text-to-SQL with Self-Correction, pp. 1-34, Nov. 2, 2023. [cited by examiner]