# US 12,762,137 B2 · Executing differentially private query using structured language parsing

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 12,762,137 B2
- Document ID: US12762137B2
- Status: Granted
- Kind: B2
- Application number: 18/933,038
- Filed: 2024-10-31
- Published: 2026-02-05
- Granted: 2026-10-13
- Earliest claimed: 2024-07-30
- Assignees: Snowflake Inc.
- Applicants: Snowflake Inc.
- Inventors: Gustavo Ajzenman; Khalid Zaman Bijon; Yankai Liu; Oana Niculaescu
- Web page: https://patentgrep.com/patent/US12762137B2

## CPC

- G06F 16/248: Presentation of query results
- G06F 16/243: {Natural language query formulation}
- G06F 16/24553: {of query operations}
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

Various example embodiments described herein provide for systems, methods, devices, instructions, and the like for structured language parsing to execute a differentially private query on a database system. According to some example embodiments, a user (e.g., an analyst) submits to a data system (e.g., data platform) a differentially private query using a structured language interface (e.g., SQL interface), which causes the calling of one or more stored procedures on the data system, where the one or more stored procedures encapsulate or facilitate use of a differential privacy engine, which can execute the differentially private query and generate a differentially private query result.

## Claims

### Claim 1

A system comprising:
at least one hardware processor; and
at least one memory storing instructions that cause the at least one hardware processor to perform operations comprising:
receiving a user query for execution;
determining whether the user query is a differentially private query; and
in response to determining that the user query is a differentially private query:
determining input payload data for a privacy engine stored procedure that encapsulates a privacy engine, the input payload data being determined based on a parse tree of the user query;
generating a rewritten parse tree by rewriting the parse tree of the user query to call the privacy engine stored procedure with the input payload data;
processing the rewritten parse tree to execute the user query to generate a differential privacy-protected query result, the processing of the rewritten parse tree comprises executing the privacy engine stored procedure, the executing of the privacy engine stored procedure comprising the privacy engine:
generating and submitting one or more non-differentially-private queries to a data system based on the input payload data;
receiving one or more non-differentially-private query results from the data system; and
generating the differential privacy-protected query result based on the one or more non-differentially-private query results by generating noise and applying the noise to the one or more non-differentially-private query results; and
returning the differential privacy-protected query result in response to the user query.

### Claim 2 (depends on 1)

The system of claim 1, wherein the determining of whether the user query is a differentially private query comprises:
traversing a named resolved parse tree to determine whether a table or view referenced in the user query is protected by a privacy policy.

### Claim 3 (depends on 1)

The system of claim 1, wherein the determining of the input payload data comprises:
mapping one or more nodes in the parse tree to one or more fields of the input payload data.

### Claim 4 (depends on 1)

The system of claim 1, wherein the operations comprise:
validating one or more query patterns in the user query to ensure that the one or more query patterns are supported by the privacy engine.

### Claim 5 (depends on 1)

The system of claim 1, wherein the rewriting of the parse tree comprises:
serializing the input payload data to generate serialized input payload data; and
rewriting the parse tree to call the privacy engine stored procedure with the serialized input payload data.

### Claim 6 (depends on 1)

The system of claim 1, wherein the user query comprises multiple nested aggregate functions, and wherein the processing of the rewritten parse tree to execute the user query to generate the differential privacy-protected query result comprises:
processing an outermost aggregate function of the multiple nested aggregate functions as a private-aggregate function and all other aggregate functions of the multiple nested aggregate as non-private-aggregates, the processing of the outermost aggregate function comprises injecting noise.

### Claim 7 (depends on 1)

The system of claim 1, wherein the user query comprises a join function, and wherein the processing of the rewritten parse tree to execute the user query to generate to the differential privacy-protected query result comprises:
processing the join function such that a column of a privacy protected table is prevented from being joined with a column that has duplicate values.

### Claim 8 (depends on 1)

The system of claim 1, wherein the user query comprises a randomization interval function, and wherein the differential privacy-protected query result comprises randomization interval information that contextualizes an estimated magnitude of noise in the differential privacy-protected query result.

### Claim 9 (depends on 8)

The system of claim 8, wherein the user query comprises a differentially private aggregate function, and wherein the randomization interval information comprises at least one of:
a lower bound of a randomization interval for the differentially private aggregate function; or
an upper bound of the randomization interval for the differentially private aggregate.

### Claim 10 (depends on 1)

The system of claim 1, wherein the operations comprise:
validating one or more structured query language (SQL) constructs used in the user query to ensure they are supported by the privacy engine.

### Claim 11 (depends on 10)

The system of claim 10, wherein the validating of the SQL constructs comprises:
traversing a SQL abstract syntax tree and checking that nodes encountered in the SQL abstract syntax tree have valid corresponding nodes in a privacy engine abstract syntax tree.

### Claim 12

A method comprising:
receiving, by at least one processor, a user query for execution;
determining, by the at least one processor, whether the user query is a differentially private query; and
in response to determining that the user query is a differentially private query:
determining, by the at least one processor, input payload data for a privacy engine stored procedure that encapsulates a privacy engine, the input payload data being determined based on a parse tree of the user query;
generating, by the at least one processor, a rewritten parse tree by rewriting the parse tree of the user query to call the privacy engine stored procedure with the input payload data;
processing, by the at least one processor, the rewritten parse tree to execute the user query to generate a differential privacy-protected query result, the processing of the rewritten parse tree comprises executing the privacy engine stored procedure, the executing of the privacy engine stored procedure comprising the privacy engine:
generating and submitting one or more non-differentially-private queries to a data system based on the input payload data;
receiving one or more non-differentially-private query results from the data system; and
generating the differential privacy-protected query result based on the one or more non-differentially-private query results by generating noise and applying the noise to the one or more non-differentially-private query results; and
returning, by the at least one processor, the differential privacy-protected query result in response to the user query.

### Claim 13 (depends on 12)

The method of claim 12, wherein the determining of the whether the user query is a differentially private query comprises:
traversing a named resolved parse tree to determine whether a table or view referenced in the user query is protected by a privacy policy.

### Claim 14 (depends on 12)

The method of claim 12, wherein the determining of the input payload data comprises:
mapping one or more nodes in the parse tree to one or more fields of the input payload data.

### Claim 15 (depends on 12)

The method of claim 12, comprising:
validating query patterns in the user query to ensure they are supported by the privacy engine.

### Claim 16 (depends on 12)

The method of claim 12, wherein the rewriting of the parse tree comprises:
serializing the input payload data to generate serialized input payload data; and
rewriting the parse tree to call the privacy engine stored procedure with the serialized input payload data.

### Claim 17

A machine-storage medium, the machine-storage medium including instructions that when executed by a machine, cause the machine to perform operations comprising:
receiving a user query for execution;
determining whether the user query is a differentially private query; and
in response to determining that the user query is a differentially private query:
determining input payload data for a privacy engine stored procedure that encapsulates a privacy engine, the input payload data being determined based on a parse tree of the user query;
generating a rewritten parse tree by rewriting the parse tree of the user query to call the privacy engine stored procedure with the input payload data;
processing the rewritten parse tree to execute the user query to generate a differential privacy-protected query result, the processing of the rewritten parse tree comprises executing the privacy engine stored procedure, the executing of the privacy engine stored procedure comprising the privacy engine:
generating and submitting one or more non-differentially-private queries to a data system based on the input payload data;
receiving one or more non-differentially-private query results from the data system; and
generating the differential privacy-protected query result based on the one or more non-differentially-private query results by generating noise and applying the noise to the one or more non-differentially-private query results; and
returning the differential privacy-protected query result in response to the user query.

### Claim 18 (depends on 17)

The machine-storage medium of claim 17, wherein the determining of the whether the user query is a differentially private query comprises:
traversing a named resolved parse tree to determine whether a table or view referenced in the user query is protected by a privacy policy.

### Claim 19 (depends on 17)

The machine-storage medium of claim 17, wherein the determining of the input payload data comprises:
mapping one or more nodes in the parse tree to one or more fields of the input payload data.

### Claim 20 (depends on 17)

The machine-storage medium of claim 17, wherein the operations comprise:
validating query patterns in the user query to ensure they are supported by the privacy engine.
