# US 11,120,018 B2 · Spark query method and system supporting trusted computing

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

- Number: US 11,120,018 B2
- Document ID: US11120018B2
- Status: Granted
- Kind: B2
- Application number: 16/600,717
- Filed: 2019-10-14
- Published: 2020-05-14
- Granted: 2021-09-14
- Earliest claimed: 2018-11-14
- Assignees: Baidu Online Network Technology (Beijing) Co., Ltd.
- Applicants: Baidu Online Network Technology (Beijing) Co., Ltd.
- Inventors: Zhi Feng; Yu Zhang; Ran Duan
- Web page: https://patentgrep.com/patent/US11120018B2

## CPC

- G06F 16/2448: {for particular applications; for extensibility, e.g. user defined types}
- G06F 21/123: {by using dedicated hardware, e.g. dongles, smart cards, cryptographic processors, global positioning systems [GPS] devices}
- G06F 16/24545: {Selectivity estimation or determination}
- G06F 16/2471: {Distributed queries}
- G06F 16/252: {between a Database Management System and a front-end application}
- G06F 16/27: Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
- G06F 21/53: by executing in a restricted environment, e.g. sandbox or secure virtual machine
- G06F 21/57: Certifying or maintaining trusted computer platforms, e.g. secure boots or power-downs, version controls, system software checks, secure updates or assessing vulnerabilities
- G06F 21/6227: {where protection concerns the structure of data, e.g. records, types, queries}
- G06F 21/76: in application-specific integrated circuits [ASIC] or field-programmable devices, e.g. field-programmable gate arrays [FPGA] or programmable logic devices [PLD]
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

The present disclosure provides a spark query method and system supporting trusted computing. The method comprises receiving a SQL query statement input by a user; performing parsing, logical plan analysis, logical plan optimization and physical plan generation for the SQL query statement; re-implementing an operator in the physical plan by using SGX API, and generating an execution code; invoking an enclave trusted environment to implement trusted computing for the operator, and executing the execution code. Through the present disclosure, safety of data during the calculation is ensured while the query request is processed in parallel through the spark architecture. Moreover, the spark interface provides the user with more available service and is user-friendly.

## Claims

### Claim 1

A trusted computing-based spark query method, wherein the method comprises:
receiving a SQL query statement input by a user;
performing parsing, logical plan analysis, logical plan optimization and physical plan generation for the SQL query statement;
re-implementing an operator in the physical plan by using Intel Software Guard Extensions Application Program Interface (SGX API), and generating an execution code;
invoking an enclave trusted environment to implement trusted computing for the operator, and executing the execution code,
wherein the performing parsing, logical plan analysis, logical plan optimization and physical plan generation for the SQL query statement comprises:
an SQL parser performing parsing for the SQL query statement, and generating an unparsed logical plan;
a Catalyst analyzer performing binding in conjunction with a data dictionary, and generating a parsed logical plan;
a Catalyst optimizer performing optimization for the parsed logical plan, and obtaining an optimized logical plan according to optimization rules; and
using a Spark Planner to convert the optimized logical plan into a physical plan.

### Claim 2 (depends on 1)

The method according to claim 1, wherein the receiving a SQL query statement input by a user comprises:
a spark scheduling server receiving a query statement which is input by the user through a spark client and described in SQL.

### Claim 3 (depends on 1)

The method according to claim 1, wherein the re-implementing an operator in the physical plan by using SGX API comprises:
locating and extracting an operator from the physical plan;
re-implementing the extracted operator by using the SGX API and generating an execution code;
segmenting and packaging a data file corresponding to the execution code.

### Claim 4 (depends on 3)

The method according to claim 3, wherein segmenting and packaging a data file corresponding to the execution code comprises:
setting a size of segmented data blocks according to a size of heaps configured in a memory in the enclave trusted environment, and packaging the segmented data blocks in a protobuf format.

### Claim 5 (depends on 1)

The method according to claim 1, wherein the invoking an enclave trusted environment to implement trusted computing for the operator, and executing the execution code comprise:
sending the execution code to a spark node server, so that the spark node server executes the execution code;
invoking the enclave trusted environment for SGX remote authentication;
invoking the enclave trusted environment to calculate the re-implemented operator, and performing the spark operation according to a calculation result.

### Claim 6

A computer device, comprising a memory, a processor and a computer program which is stored on the memory and runs on the processor, wherein the processor, upon executing the program, implements a trusted computing-based spark query method, wherein the method comprises:
receiving a SQL query statement input by a user;
performing parsing, logical plan analysis, logical plan optimization and physical plan generation for the SQL query statement;
re-implementing an operator in the physical plan by using Intel Software Guard Extensions Application Program Interface (SGX API), and generating an execution code;
invoking an enclave trusted environment to implement trusted computing for the operator, and executing the execution code,
wherein the performing parsing, logical plan analysis, logical plan optimization and physical plan generation for the SQL query statement comprises:
an SQL parser performing parsing for the SQL query statement, and generating an unparsed logical plan;
a Catalyst analyzer performing binding in conjunction with a data dictionary, and generating a parsed logical plan;
a Catalyst optimizer performing optimization for the parsed logical plan, and obtaining an optimized logical plan according to optimization rules; and
using a Spark Planner to convert the optimized logical plan into a physical plan.

### Claim 7

A non-transitory computer-readable storage medium on which a computer program is stored, wherein the program, when executed by a processor, implements a trusted computing-based spark query method, wherein the method comprises:
receiving a SQL query statement input by a user;
performing parsing, logical plan analysis, logical plan optimization and physical plan generation for the SQL query statement;
re-implementing an operator in the physical plan by using Intel Software Guard Extensions Application Program Interface (SGX API), and generating an execution code;
invoking an enclave trusted environment to implement trusted computing for the operator, and executing the execution code,
wherein the performing parsing, logical plan analysis, logical plan optimization and physical plan generation for the SQL query statement comprises:
an SQL parser performing parsing for the SQL query statement, and generating an unparsed logical plan;
a Catalyst analyzer performing binding in conjunction with a data dictionary, and generating a parsed logical plan;
a Catalyst optimizer performing optimization for the parsed logical plan, and obtaining an optimized logical plan according to optimization rules; and
using a Spark Planner to convert the optimized logical plan into a physical plan.
