SQL statement processing method, apparatus and device

By converting SQL statements into abstract syntax trees and performing sensitivity calculations, it solves the problem that SQL statements cannot directly execute differential privacy algorithms, achieves privacy protection for complex SQL statements, and ensures the stability of data statistical characteristics and the security of user privacy. .

WO2024183646A1PCT designated stage expired Publication Date: 2024-09-12BEIJING ZITIAO NETWORK TECH CO LTD

Patent Information

Application Number
PCT/CN2024/079634
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2023-03-03
Filing Date
2024-03-01
Publication Date
2024-09-12

AI Technical Summary

Technical Problem

Existing SQL statements cannot directly execute differential privacy algorithms, especially for complex SQL statements, which cannot be structured to perform differential privacy protection.

Method used

Convert the SQL statement into an abstract syntax tree (AST) structure, find the aggregate expression node in the expression node of the AST, and call the sensitivity calculation function to perform the differential privacy algorithm.

Benefits of technology

It implements differential privacy protection for complex SQL statements, ensuring the stability of data statistical characteristics, while protecting user privacy and avoiding data leakage.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2024079634_12092024_PF_FP_ABST
    Figure CN2024079634_12092024_PF_FP_ABST
Patent Text Reader

Abstract

The present disclosure provides an SQL statement processing method, apparatus and device, for use in converting an SQL statement into an AST structure, and then realizing execution of a differential privacy algorithm using the structure. The method comprises: acquiring an SQL statement; converting the SQL statement into an AST according to an AST conversion rule corresponding to the type of the SQL statement, node types of the AST comprising a statement node, a block node, and an expression node, the statement node comprising at least one block node, and the block node comprising at least one expression node; searching for a first target node belonging to an aggregation expression in the expression node of the AST; and calling a sensitivity calculation function of an internal node of the first target node to obtain the sensitivity of the internal node of the first target node, the sensitivity of the internal node of the first target node being used for executing a differential privacy algorithm for the first target node.
Need to check novelty before this filing date? Find Prior Art

Description

SQL statement processing method, device and equipment

[0001] This application claims priority to Chinese Patent Application No. 202310201045.4 filed on March 3, 2023, and the contents of the above-mentioned Chinese patent application disclosure are hereby incorporated by reference in their entirety as a part of this application. Technical Field

[0002] Embodiments of the present disclosure relate to a method, apparatus, and device for processing SQL (Structured Query Language) statements. Background Art

[0003] Differential Privacy (DP) is a privacy protection method primarily used to protect aggregated statistical data. It can safeguard sensitive individual information while maintaining the stability of the overall statistical characteristics of the data. DP primarily involves adding a moderate amount of noise to the statistical results to ensure that modifying a single individual record does not significantly affect the results. This approach aims to address the issue of user privacy leaks during the statistical publication process.

[0004] Currently, SQL statements can be used to query data tables in the database, but differential privacy algorithms cannot be directly executed on SQL statements that are strings.

[0005] Summary of the Invention

[0006] In view of this, the embodiments of the present disclosure provide a method, apparatus, and device for processing SQL statements, which can convert SQL statements into an intermediate representation structure and then use this structure to implement the execution of a differential privacy algorithm.

[0007] To solve the above problems, the technical solutions provided by the embodiments of the present disclosure are as follows:

[0008] In a first aspect, an embodiment of the present disclosure provides a method for processing a structured query language (SQL) statement, the method comprising:

[0009] Get SQL statements;

[0010] Convert the SQL statement into an AST according to an abstract syntax tree (AST) conversion rule corresponding to the type of the SQL statement; the node types of the AST include statement nodes, block nodes, and expression nodes, the statement nodes include at least one block node, and the block nodes include at least one expression node;

[0011] Searching for a first target node belonging to an aggregate expression in the expression nodes of the AST;

[0012] Calling a sensitivity calculation function of an internal node of the first target node to obtain the sensitivity of the internal node of the first target node, where the sensitivity of the internal node of the first target node is used to execute a differential privacy algorithm for the first target node.

[0013] In a second aspect, an embodiment of the present disclosure provides a device for processing a structured query language SQL statement, the device comprising:

[0014] A first acquisition unit is used to acquire SQL statements;

[0015] a conversion unit, configured to convert the SQL statement into an AST according to an abstract syntax tree (AST) conversion rule corresponding to the type of the SQL statement; the node types of the AST include statement nodes, block nodes, and expression nodes, the statement nodes include at least one block node, and the block nodes include at least one expression node;

[0016] A first search unit is used to search for a first target node belonging to an aggregate expression in the expression nodes of the AST;

[0017] A calling unit is used to call the sensitivity calculation function of the internal node of the first target node to obtain the sensitivity of the internal node of the first target node, and the sensitivity of the internal node of the first target node is used to execute the differential privacy algorithm for the first target node.

[0018] In a third aspect, an embodiment of the present disclosure provides a device for processing structured query language SQL statements, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the method for processing SQL statements as described above is implemented.

[0019] In a fourth aspect, an embodiment of the present disclosure provides a computer-readable storage medium, wherein instructions are stored in the computer-readable storage medium. When the instructions are executed on a terminal device, the terminal device executes the processing method of the SQL statement as described above. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] FIG1 is a schematic diagram of an exemplary application scenario provided by an embodiment of the present disclosure;

[0021] FIG2 is a flowchart of a method for processing an SQL statement provided by an embodiment of the present disclosure;

[0022] FIG3 is a schematic diagram of generating an AST according to an embodiment of the present disclosure;

[0023] FIG4 is a schematic diagram of a device for processing SQL statements provided by an embodiment of the present disclosure; and

[0024] FIG5 is a schematic diagram of an electronic device provided by an embodiment of the present disclosure. DETAILED DESCRIPTION

[0025] In order to make the above-mentioned objects, features and advantages of the present disclosure more obvious and easy to understand, the embodiments of the present disclosure are further described in detail below with reference to the accompanying drawings and specific implementation methods.

[0026] In order to facilitate understanding and explanation of the technical solutions provided by the embodiments of the present disclosure, the background technology of the present disclosure will be described below.

[0027] Differential Privacy (DP) is a privacy protection method that is mainly used to protect aggregated statistical data. It can protect individual sensitive information while keeping the overall statistical characteristics of the data stable.

[0028] For example, imagine a database of user information records, using Boolean values ​​to record whether each person possesses a certain user characteristic. Possessing the user characteristic is a 1, while not possessing it is a 2. Imagine a malicious user (often called an attacker) wants to know whether a person possesses that user characteristic. Suppose the attacker knows which row in the database the person is in, say, row 10. The attacker uses a specific query to sum the Boolean values ​​of the first 10 rows and the first 9 rows in the user information record database. Then, they calculate the difference between the two queries to determine whether the person possesses the user characteristic. This is a differential privacy attack. If the results of a query for information on 9 and 10 people are the same, the attacker has no way of determining the information about the 10th person. This is differential privacy protection.

[0029] The main approach to differential privacy protection is to add an appropriate amount of noise to the aggregated statistical results to ensure that modifying an individual record in the data will not have a significant impact on the statistical results. It aims to solve the problem of user privacy leakage during the statistical release of data.

[0030] Currently, SQL statements can be used to query database tables and obtain aggregated query results. However, SQL statements are strings, making it difficult to present complex SQL statements in a structured manner, nor to identify which queries require differential privacy algorithms. Therefore, it is currently impossible to directly apply differential privacy algorithms to SQL statements that are strings.

[0031] Based on this, the embodiments of the present disclosure provide a method, apparatus, and device for processing SQL statements, which convert SQL statements into an intermediate representation structure AST for representation, and then use this structure to implement the execution of a differential privacy algorithm.

[0032] To facilitate understanding of the SQL statement processing method provided by the embodiment of the present disclosure, the following description is made with reference to the scenario example shown in Figure 1. Referring to Figure 1, this figure is a schematic diagram of an exemplary application scenario provided by the embodiment of the present disclosure.

[0033] The differential privacy protection system of the embodiment of the present disclosure takes SQL statements as input and converts the SQL statements into AST. The AST includes three levels of nodes: statement nodes, block nodes, and expression nodes. When executing the differential privacy algorithm, the first target node belonging to the aggregate expression that needs to execute the differential privacy algorithm is found from each expression node of the AST, such as the node expression with shading in Figure 1. Then, the sensitivity calculation function of the internal node of the first target node is called to calculate the sensitivity of the internal node of the first target node, so that the differential privacy algorithm such as noise addition can be executed on the first target node according to the sensitivity of the internal node of the first target node.

[0034] Those skilled in the art will appreciate that the framework diagram shown in FIG1 is merely an example in which the embodiments of the present disclosure may be implemented, and the scope of application of the embodiments of the present disclosure is not limited in any way by the framework.

[0035] To facilitate understanding of the present disclosure, a method for processing an SQL statement provided by an embodiment of the present disclosure is described below with reference to the accompanying drawings.

[0036] Referring to FIG. 2 , which is a flow chart of a method for processing an SQL statement provided by an embodiment of the present disclosure, as shown in FIG. 2 , the method may include S201 to S204:

[0037] S201: Obtain SQL statements.

[0038] SQL statements can be used to query database tables. In practice, there are different types of SQL statements, or dialects, such as MySQL and Hive. Each type of SQL statement has its own unique syntax and relatively flexible writing methods, which poses challenges to SQL statement parsing.

[0039] S202: Convert the SQL statement into an AST according to the abstract syntax tree (AST) conversion rules corresponding to the type of the SQL statement. AST node types include statement nodes, block nodes, and expression nodes. A statement node includes at least one block node, and a block node includes at least one expression node.

[0040] To facilitate subsequent understanding, we first explain the structure of the AST provided in the embodiments of this disclosure. The AST consists of three levels of nodes: statement nodes, block nodes, and expression nodes. A statement node includes at least one block node, and a block node includes at least one expression node.

[0041] A statement node represents a statement. Different SQL statements have different syntaxes, and a single statement may contain different content. Therefore, different statement nodes are constructed for each type of SQL statement to handle different types of SQL statements. A statement node is internally composed of different block nodes, and different statement nodes can contain different block nodes. For example, statement nodes include ClickHouseStatement (a statement node corresponding to ClickHouse-type SQL statements), HiveStatement (a statement node corresponding to Hive-type SQL statements), MySQLStatement (a statement node corresponding to MySQL-type SQL statements), SparkStatement (a statement node corresponding to Spark-type SQL statements), and OtherStatement (a statement node corresponding to other types of SQL statements). ClickHouse-type SQL statements may contain a prewhere syntax block, while Hive-type SQL statements do not syntactically support it. In this case, when creating a ClickHouseStatement, you can enter the prewhere block node, but not the HiveStatement. That is, a ClickHouseStatement includes a prewhere block node, while a HiveStatement does not. Only one identical block node can exist within a statement node.

[0042] A block node represents a relatively independent block structure in an SQL statement, similar to a short sentence (different parts of a sentence separated by commas). In the current AST representation system, in order to support different types of SQL statements, the grammatical parts of different characteristics contained in each type of SQL statement are encapsulated as independent block nodes. For example, block nodes include SelectBlock (Select block node), FromBlock (From block node), WhereBlock (Where block node), GroupByBlock (GroupBy block node), HavingBlock (Having block node), OrderByBlock (OrderBy block node), LimitByBlock (LimitByt block node), LimitBlock (Limit syntax block), TeaLimitBlock (TeaLimit block node), WithBlock (With block node), PrewhereBlock (Prewhere block node), SettingBlock (Setting block node), SampleBlock (Sample block node), etc.

[0043] A block node can also include other block nodes. For example, WithBlock includes WithFromExpressionBlock (WithFromExpression block node) and WithAsQueryBlock (WithAsQuery block node). Block nodes are composed of different expression nodes. Expression nodes within a block node can be freely combined, and a block node can have multiple identical expression nodes.

[0044] An expression node represents a single field or compound field expression and has the largest node type in the current AST representation system. Expression nodes can include multiple expression-type nodes of broad categories, each of which is further divided into further expression nodes. For example, expression nodes include BaseExpr (Base-type expression nodes), AggFunctionExpr (AggFunction-type expression nodes), ArithmeticExpr (Arithmetic-type expression nodes), CondExpr (Cond-type expression nodes), FunctionExpr (Function-type expression nodes), LogicalExpr (Logical-type expression nodes), and BoolExpr (Bool-type expression nodes). Taking BaseExpr as an example, it can be further divided into different expression nodes, such as LiteralExpr (constant expression nodes), IdentifierExpr (identifier expression nodes), NumberExprExpr (numeric expression nodes), and so on.

[0045] In the embodiment of the present disclosure, in order to achieve the correct parsing of SQL statements, AST conversion rules corresponding to different types of SQL statements are pre-established to convert SQL statements into AST. The AST conversion rules for each type of SQL statement can be understood as the nodes in the AST that may be included in the SQL statement of that type and the node hierarchical relationship between each node. For example, the AST conversion rules for ClickHouse's SQL statements indicate that ClickHouse's SQL statements may include ClickHouseStatement, ClickHouseStatement includes SelectBlock, FromBlock, PrewhereBlock, etc., and each block node includes which expression nodes. By matching the SQL statement with the corresponding AST conversion rules, it is possible to identify which nodes the SQL statement includes and the node hierarchical relationship between these nodes, thereby establishing the AST corresponding to the SQL statement.

[0046] In a possible implementation, S202 converts the SQL statement into an AST according to an abstract syntax tree (AST) conversion rule corresponding to the type of the SQL statement. Specifically, the conversion may include:

[0047] A1: Parse the SQL statement into a SQL statement word stream.

[0048] An SQL statement is a string of characters. A parser using grammar rules corresponding to the SQL statement type can identify the SQL statement's corresponding word stream, which consists of multiple words. For example, the SQL statement "select age from table" can be parsed to obtain a word stream consisting of the four words "select, age, from, table." A grammar rule parser can be used as an SQL statement parsing tool in practical applications.

[0049] A2: Match the words in the SQL statement word stream with the abstract syntax tree (AST) conversion rules corresponding to the SQL statement type to determine the node type of the word and the node hierarchical relationship between each word.

[0050] A3: Convert the SQL statement into AST based on the node type of the word and the node hierarchical relationship between each word.

[0051] By matching the words in the SQL statement word stream with the corresponding AST conversion rules, we can find out which type of node each word belongs to in the AST and what node hierarchy relationship these nodes have. By assembling these words according to the node type and the corresponding node hierarchy relationship, we can get the AST corresponding to the SQL statement. For example, the SQL statement of the Mysql type is "select age from table", where "age" is an expression node, "table" is an expression node, "select" is a Select block node, and "from" is a From block node. Then the age expression node belongs to the Select block node, the table expression node belongs to the From block node, and the Select block node and the From block node belong to the MysqlStatement node, thereby establishing the AST of the SQL statement.

[0052] Referring to FIG3 , there is shown a schematic diagram of a process of converting an SQL statement into an AST in actual application.

[0053] For the input of different types of SQL statements, use the corresponding grammar rule parser to identify the individual words in the SQL statement to form a SQL statement word stream, and then use the corresponding ASTBuilder to assemble these words into the currently designed AST. The corresponding AST conversion rules are stored in ASTBuilder. When a new type of SQL statement needs to be adapted, it is only necessary to implement its corresponding grammar rule parser and ASTBuilder, and finally implement different types of SQL statements using the corresponding ASTBuilder to build a unified AST. For example, obtain a SQL statement of the Mysql type, use the Mysql grammar rule parser to parse the SQL statement into a SQL statement word stream, input the SQL statement word stream into the Mysql ASTBuilder, and convert the SQL statement into an AST. The same process is used for other types of SQL statements, which will not be repeated here.

[0054] Thus, in the disclosed embodiment, different statement nodes are constructed for different types of SQL statements in the AST. Each type of SQL statement is directly parsed into a corresponding statement node during parsing. Relatively independent statements and grammatical features are encapsulated into block nodes, and different block node combinations are used to populate different statement nodes. Finally, various basic expressions are encapsulated into expression nodes, and expression node combinations are used to populate the expression nodes themselves and the block nodes. This allows upper-level AST nodes to handle different syntaxes, while lower-level AST nodes are used as general nodes for populating, thereby resolving the compatibility issues of different types of SQL statements on the AST.

[0055] S203: Search for the first target node belonging to the aggregate expression in the expression nodes of the AST.

[0056] During implementation, the differential privacy algorithm requires calculating the sensitivity of internal nodes belonging to aggregate expressions. To implement the differential privacy algorithm, you can pre-set a list of aggregate expressions and then search for nodes belonging to the aggregate expressions in the AST expression nodes as the first target node. For example, if you pre-set the need to execute the differential privacy algorithm on the sum expression, then the sum expression is the aggregate expression, and the sum expression node is searched for as the first target node in each expression node in the AST.

[0057] Since the first target node belongs to an aggregate expression, it also includes internal nodes. The first target node can include one level of internal nodes or multiple levels of internal nodes. For example, the sum(age) part in the SQL statement is converted into a sum expression node and an age expression node in the AST. The sum expression node is the first target node, and its internal nodes are the age expression node. For another example, the sum(id+age) part in the SQL statement is converted into a sum expression node, an addition expression node, an id expression node, and an age expression node in the AST tree. The sum expression node is the first target node, and its internal nodes are addition expression nodes. The internal nodes of the addition expression node are the id expression node and the age expression node.

[0058] S204: Calling the sensitivity calculation function of the internal nodes of the first target node to obtain the sensitivity of the internal nodes of the first target node. The sensitivity of the internal nodes of the first target node is used to execute the differential privacy algorithm on the first target node.

[0059] After determining the first target node, the internal nodes of the first target node can be determined through AST. In the disclosed embodiment, a corresponding sensitivity calculation function is pre-set for the internal nodes of the first target node. According to the execution logic of the sensitivity calculation function, the sensitivity of the internal nodes of the first target node can be obtained, and the differential privacy algorithm is executed on the first target node using the sensitivity of the internal nodes of the target node.

[0060] In a possible implementation, S204 calls the sensitivity calculation function of the internal nodes of the first target node to obtain the sensitivity of the internal nodes of the first target node. The specific implementation may include:

[0061] The sensitivity calculation function of the internal node of the first target node is called to obtain metadata information of the internal node of the first target node, and the sensitivity of the internal node of the first target node is calculated using the metadata information; the metadata information is obtained by querying the data table through an SQL statement.

[0062] When calculating the sensitivity of the internal nodes of the first target node, it is necessary to use the metadata information of the internal nodes of the first target node, which can be obtained by querying from the data table corresponding to the internal node. Specifically, the metadata information may include the data type, maximum value, minimum value, data occurrence frequency, etc. in the data table corresponding to the internal node. For example, based on the above example, from sum(age), it can be known that the sum expression node is the first target node, and the corresponding internal node is the age expression node. The age expression node queries the age (age) column in the data table, and the metadata information of the age expression node can be obtained from the data table, including the data type, maximum value, minimum value, etc. of the column in the data table. When calling the sensitivity calculation function of the age expression node, the metadata information of the age expression node can be used to calculate the sensitivity of the age expression node, thereby executing the differential privacy algorithm on the query result corresponding to the sum expression node according to the sensitivity of the age expression node.

[0063] In some possible implementations, since the first target node may include multiple levels of internal nodes, a sensitivity calculation function of the internal nodes of the first target node is called to obtain metadata information of the internal nodes of the first target node. The specific implementation of calculating the sensitivity of the internal nodes of the first target node using the metadata information may include:

[0064] The sensitivity calculation function of the first-level internal node of the target node is called to obtain the metadata information of the second-level internal node of the target node, and the sensitivity of the first-level internal node of the target node is calculated using the metadata information of the second-level internal node of the target node.

[0065] That is, when the first target node includes multiple levels of internal nodes, the second-level internal node can be understood as the node at the next level of the first internal node. The sensitivity calculation function of the first-level internal node is called to obtain the metadata information of the next-level internal node (i.e., the second internal node) of the first-level internal node, and the sensitivity of the first-level internal node can be calculated.

[0066] When the first target node includes three or more levels of internal nodes, the sensitivity calculation function of the second-to-last level internal node can be called first to obtain the metadata information of the last level internal node. The sensitivity of the second-to-last level internal node can be calculated using the metadata information of the last level internal node. The sensitivity of the second-to-last level internal node can be used as the metadata information of the second-to-last level internal node. Continue to call the sensitivity calculation function of the internal node one level above the second-to-last level internal node, and use the metadata information of the second-to-last level internal node to calculate the sensitivity of the internal node one level above the second-to-last level internal node. And so on, the sensitivity of the next level internal node of the first target node can be obtained, thereby executing the differential privacy algorithm on the query result of the first target node.

[0067] For example, based on the above example, sum(id+age), the sum expression node is the first target node, the addition expression node is the first-level internal node, and the id expression node and the age expression node are the second-level internal nodes. The sensitivity calculation function of the addition expression node is called to obtain the metadata information of the id expression node and the age expression node. According to the pre-set sensitivity calculation function of the addition expression node, the minimum value corresponding to the id expression node and the age expression node are added as the minimum value of the addition expression node, and the maximum value corresponding to the id expression node and the age expression node are added as the maximum value of the addition expression node, and the sensitivity of the addition expression node is calculated.

[0068] For another example, in the sum(power(salary, 2)) part of the SQL statement, the sum expression node is the first target node, its first-level internal node is the power (exponential calculation) expression node, and its second-level internal node is the salary (salary) expression node. Call the sensitivity calculation function of the power expression node to obtain the metadata information of the salary expression node. According to the pre-set sensitivity calculation function of the power expression node, when the minimum value corresponding to the salary expression node is a non-negative number, the square of the minimum value is used as the minimum value of the power expression node, and the square of the maximum value corresponding to the salary expression node is used as the maximum value of the power expression node; when the maximum value corresponding to the salary expression node is a non-positive number, the square of the maximum value is used as the minimum value of the power expression node, and the square of the minimum value corresponding to the salary expression node is used as the maximum value of the power expression node; when the minimum value corresponding to the salary expression node is a negative number and the maximum value is a positive number, the minimum value of the power expression node is 0, and the larger of the square of the minimum value and the square of the maximum value corresponding to the salary expression node is used as the maximum value of the power expression node, completing the sensitivity calculation of the power expression node.

[0069] The embodiment of the present disclosure pre-encapsulates sensitivity calculation logic for expression nodes that require sensitivity calculation. The specific logic varies depending on the expression node, and on this basis, the differential privacy result output of the first target node is achieved.

[0070] Based on the description of S201-S204, the embodiment of the present disclosure pre-establishes AST conversion rules corresponding to different SQL statement types, which can be compatible with different types of SQL statements and convert SQL statements into AST. The AST is represented by a three-level node structure of statement nodes, block nodes, and expression nodes. Then, the first target node belonging to the aggregate expression that needs to execute the differential privacy algorithm is determined in the expression node in the AST, and the sensitivity calculation function of the internal node of the first target node is called to calculate the sensitivity of the internal node of the first target node. The sensitivity of the internal node of the first target node can be used to execute the differential privacy algorithm for the first target node. This realizes the execution of the differential privacy algorithm after the SQL statement is input.

[0071] Based on the above embodiment, in order to calculate the sensitivity of the internal nodes of the first target node, it is necessary to query the data table corresponding to the internal nodes of the first target node to obtain metadata information of the corresponding database, data table, data column, etc. To improve the efficiency of obtaining metadata information and reduce the number of database queries, the embodiment of the present disclosure can pre-bind the metadata information with the expression nodes in the AST.

[0072] In a possible implementation, based on the above embodiment, the embodiment of the present disclosure may further include:

[0073] B1: Search for the second target node of the preset type in the expression node of the AST.

[0074] The second target node can be understood as an expression node that may need to obtain metadata information. There are three types of second target nodes in the AST: table type, column type, and map expression type. A second target node of table type indicates that the expression node needs to query a data table, a second target node of data column type indicates that the expression node needs to query a data column, and a second target node of map expression type indicates that the expression node needs to query a map expression. That is, the second target node of the preset type is searched in each expression node of the AST. The preset types are table type, column type, and map expression type.

[0075] B2: Obtain metadata information in the data table corresponding to the second target node according to the execution order of the SQL statements.

[0076] In the order in which SQL statements are executed, the data table, data column, or corresponding node corresponding to the corresponding second target node is queried to obtain metadata information for the second target node. For example, in the SQL statement select name,sum(age)as sa,float_params{'_slot_param_1'}as fp1 from table1, table1 is parsed as a second target node of table type, name and age are parsed as second target nodes of column type, and float_params{'_slot_param_1'} is parsed as a second target node of map expression type.

[0077] According to the execution order of SQL statements, as in the above example, the table1 expression node in the From block node first obtains metadata information, and then the three expression nodes in the Select block node obtain metadata information.

[0078] In a possible implementation, when the second target node is of table type, the metadata information in the data table corresponding to the second target node is metadata information of a corresponding table in the data table corresponding to the second target node;

[0079] When the second target node is of column type, the metadata information in the database corresponding to the second target node is the metadata information of the corresponding column in the data table corresponding to the second target node;

[0080] When the second target node is of a Map expression type, the metadata information in the data table corresponding to the second target node is the metadata information of the corresponding node in the data table corresponding to the second target node.

[0081] In the disclosed embodiment, when the second target node is of table type, the metadata information of the data table corresponding to the second target node is queried (including metadata information of all columns of the data table). When the second target node is of column type, the metadata information of the data column corresponding to the second target node is queried. When the second target node is of map expression type, the metadata information of the corresponding node in the data table corresponding to the second target node is queried.

[0082] B3: Bind the metadata information corresponding to the second target node to the second target node in the AST.

[0083] Finally, the metadata information of each second target node is bound to the second target node, so that when the metadata information of the second target node needs to be obtained, it can be directly obtained from the AST without repeatedly querying the database again.

[0084] In a possible implementation, S204 calls the sensitivity calculation function of the internal nodes of the first target node to obtain the sensitivity of the internal nodes of the first target node. The specific implementation may include:

[0085] The sensitivity calculation function of the internal node of the first target node is called, the metadata information of the internal node of the first target node is obtained from the AST, and the sensitivity of the internal node of the first target node is calculated using the metadata information; the internal node of the first target node is matched with the second target node.

[0086] After metadata information is bound in AST, when it is necessary to obtain metadata information of an internal node of the first target node, if the internal node belongs to the second target node, that is, it is bound with metadata information, the metadata information of the internal node can be obtained directly from AST without querying the database, thereby improving implementation efficiency.

[0087] Based on the method for processing an SQL statement provided in the above method embodiment, the embodiment of the present disclosure further provides a device for processing an SQL statement, which will be described below with reference to the accompanying drawings.

[0088] See Figure 4, which is a schematic diagram of the structure of a SQL statement processing device provided by an embodiment of the present disclosure. As shown in Figure 4, the SQL statement processing device includes:

[0089] The first acquisition unit 401 is used to acquire SQL statements;

[0090] A conversion unit 402 is configured to convert the SQL statement into an AST according to an abstract syntax tree (AST) conversion rule corresponding to the type of the SQL statement; the node types of the AST include statement nodes, block nodes, and expression nodes, the statement nodes include at least one block node, and the block nodes include at least one expression node;

[0091] A first search unit 403 is configured to search for a first target node belonging to an aggregate expression in the expression nodes of the AST;

[0092] The calling unit 404 is used to call the sensitivity calculation function of the internal node of the first target node to obtain the sensitivity of the internal node of the first target node, and the sensitivity of the internal node of the first target node is used to execute the differential privacy algorithm for the first target node.

[0093] In a possible implementation, the conversion unit includes:

[0094] A parsing subunit, configured to parse the SQL statement into an SQL statement word stream;

[0095] A matching subunit is used to match the words in the SQL statement word stream with the abstract syntax tree (AST) conversion rules corresponding to the type of the SQL statement, and determine the node type of the words and the node hierarchical relationship between each of the words;

[0096] The conversion subunit is used to convert the SQL statement into AST according to the node type of the word and the node hierarchical relationship between each of the words.

[0097] In a possible implementation, the calling unit is specifically configured to:

[0098] Calling a sensitivity calculation function of an internal node of the first target node, obtaining metadata information of the internal node of the first target node, and using the metadata information to calculate the sensitivity of the internal node of the first target node; the metadata information is obtained by querying a data table through the SQL statement.

[0099] In a possible implementation, when the first target node includes multiple levels of internal nodes, the calling unit is specifically configured to include:

[0100] The sensitivity calculation function of the first-level internal node of the target node is called to obtain the metadata information of the second-level internal node of the target node, and the sensitivity of the first-level internal node of the target node is calculated using the metadata information of the second-level internal node of the target node.

[0101] In a possible implementation, the apparatus further includes:

[0102] A second search unit, configured to search for a second target node of a preset type in the expression node of the AST;

[0103] A second acquiring unit, configured to acquire metadata information in a data table corresponding to the second target node according to the execution order of the SQL statements;

[0104] A binding unit is used to bind the metadata information corresponding to the second target node with the second target node in the AST.

[0105] In a possible implementation, the preset type is a table type, a column type, and a Map expression type;

[0106] When the second target node is of table type, the metadata information in the data table corresponding to the second target node is the metadata information of the corresponding table in the data table corresponding to the second target node;

[0107] When the second target node is of column type, the metadata information in the database corresponding to the second target node is the metadata information of the corresponding column in the data table corresponding to the second target node;

[0108] When the second target node is of a Map expression type, the metadata information in the data table corresponding to the second target node is the metadata information of the corresponding node in the data table corresponding to the second target node.

[0109] In a possible implementation, the calling unit is specifically configured to:

[0110] Call the sensitivity calculation function of the internal nodes of the first target node, obtain the metadata information of the internal nodes of the first target node from the AST, and use the metadata information to calculate the sensitivity of the internal nodes of the first target node; the internal nodes of the first target node are matched with the second target node.

[0111] Based on the method for processing SQL statements provided in the above method embodiments, the present disclosure also provides an electronic device, including: one or more processors; a storage device on which one or more programs are stored, and when the one or more programs are executed by the one or more processors, the one or more processors implement the method for processing SQL statements described in any of the above embodiments.

[0112] Reference is now made to FIG5 , which illustrates a schematic diagram of the structure of an electronic device 1300 suitable for implementing an embodiment of the present disclosure. The terminal devices in the embodiments of the present disclosure may include, but are not limited to, mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (portable Android devices), PMPs (Portable Media Players), in-vehicle terminals (e.g., in-vehicle navigation terminals), and fixed terminals such as digital televisions (TVs) and desktop computers. The electronic device illustrated in FIG5 is merely an example and should not limit the functionality and scope of use of the embodiments of the present disclosure.

[0113] As shown in FIG5 , the electronic device 1300 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 1301, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 1302 or a program loaded from a storage device 1306 into a random access memory (RAM) 1303. Various programs and data required for the operation of the electronic device 1300 are also stored in the RAM 1303. The processing device 1301, the ROM 1302, and the RAM 1303 are connected to each other via a bus 1304. An input / output (I / O) interface 1305 is also connected to the bus 1304.

[0114] Typically, the following devices may be connected to the I / O interface 1305: an input device 1306 including, for example, a touch screen, a touchpad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 1307 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 1306 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 1309. The communication device 1309 may allow the electronic device 1300 to communicate with other devices wirelessly or by wire to exchange data. Although FIG. 5 illustrates the electronic device 1300 with various devices, it should be understood that not all of the illustrated devices are required to be implemented or present. More or fewer devices may alternatively be implemented or present.

[0115] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication device 1309, or installed from the storage device 1306, or installed from the ROM 1302. When the computer program is executed by the processing device 1301, the above-mentioned functions defined in the method of the embodiment of the present disclosure are performed.

[0116] The electronic device provided by the embodiment of the present disclosure and the method for processing SQL statements provided by the above embodiment belong to the same inventive concept. For technical details not fully described in this embodiment, please refer to the above embodiment, and this embodiment has the same beneficial effects as the above embodiment.

[0117] Based on the method for processing an SQL statement provided in the above method embodiment, an embodiment of the present disclosure provides a computer-readable medium having a computer program stored thereon, wherein when the program is executed by a processor, the method for processing an SQL statement as described in any of the above embodiments is implemented.

[0118] It should be noted that the computer-readable medium mentioned above in the present disclosure may be a computer-readable signal medium or a computer-readable storage medium, or any combination of the two. A computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or component, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, device, or component. In the present disclosure, a computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, which carries computer-readable program code. Such a propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium that can transmit, propagate, or transport a program for use by or in conjunction with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium may be transmitted using any suitable medium, including but not limited to wires, optical cables, RF (radio frequency), etc., or any suitable combination thereof.

[0119] In some embodiments, the client and server can communicate using any currently known or later developed network protocol, such as HTTP (HyperText Transfer Protocol), and can be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), an internet (e.g., the Internet), and a peer-to-peer network (e.g., an ad hoc peer-to-peer network), as well as any currently known or later developed network.

[0120] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.

[0121] The computer-readable medium carries one or more programs. When the one or more programs are executed by the electronic device, the electronic device executes the method for processing the SQL statement.

[0122] Computer program code for performing the operations of the embodiments of the present disclosure may be written in one or more programming languages, or a combination thereof, including but not limited to object-oriented programming languages ​​such as Java, Smalltalk, C++, and conventional procedural programming languages ​​such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a stand-alone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0123] The flowcharts and block diagrams in the accompanying drawings illustrate the possible implementation architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each box in the flowchart or block diagram can represent a module, program segment, or a part of code, and the module, program segment, or a part of code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order than that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart, and the combination of the boxes in the block diagram and / or flowchart, can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0124] The units involved in the embodiments described in this disclosure may be implemented in software or hardware. The names of the units / modules do not, in some cases, limit the units themselves. For example, the first acquisition unit may also be described as a "first acquisition module."

[0125] The functions described above herein may be performed, at least in part, by one or more hardware logic components. For example, and without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chip (SOCs), complex programmable logic devices (CPLDs), and the like.

[0126] In the context of the embodiments of the present disclosure, a machine-readable medium can be a tangible medium that can contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium can include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0127] According to one or more embodiments of the present disclosure, Example 1 provides a method for processing an SQL statement, the method comprising:

[0128] Get SQL statements;

[0129] Convert the SQL statement into an AST according to an abstract syntax tree (AST) conversion rule corresponding to the type of the SQL statement; the node types of the AST include statement nodes, block nodes, and expression nodes, the statement nodes include at least one block node, and the block nodes include at least one expression node;

[0130] Searching for a first target node belonging to an aggregate expression in the expression nodes of the AST;

[0131] Calling a sensitivity calculation function of an internal node of the first target node to obtain the sensitivity of the internal node of the first target node, where the sensitivity of the internal node of the first target node is used to execute a differential privacy algorithm for the first target node.

[0132] According to one or more embodiments of the present disclosure, Example 2 provides a method for processing an SQL statement, wherein the method converts the SQL statement into an AST according to an abstract syntax tree (AST) conversion rule corresponding to the type of the SQL statement, including:

[0133] Parsing the SQL statement into a SQL statement word stream;

[0134] Match the words in the SQL statement word stream with the abstract syntax tree (AST) conversion rules corresponding to the type of the SQL statement, and determine the node type of the words and the node hierarchical relationship between each of the words;

[0135] The SQL statement is converted into AST according to the node type of the word and the node hierarchical relationship between each of the words.

[0136] According to one or more embodiments of the present disclosure, Example 3 provides a method for processing an SQL statement, wherein calling a sensitivity calculation function of an internal node of the first target node to obtain the sensitivity of the internal node of the first target node includes:

[0137] Calling a sensitivity calculation function of an internal node of the first target node, obtaining metadata information of the internal node of the first target node, and using the metadata information to calculate the sensitivity of the internal node of the first target node; the metadata information is obtained by querying a data table through the SQL statement.

[0138] According to one or more embodiments of the present disclosure, Example 4 provides a method for processing an SQL statement, wherein when the first target node includes multiple levels of internal nodes, calling a sensitivity calculation function of the internal nodes of the first target node, obtaining metadata information of the internal nodes of the first target node, and calculating the sensitivity of the internal nodes of the first target node using the metadata information includes:

[0139] The sensitivity calculation function of the first-level internal node of the target node is called to obtain the metadata information of the second-level internal node of the target node, and the sensitivity of the first-level internal node of the target node is calculated using the metadata information of the second-level internal node of the target node.

[0140] According to one or more embodiments of the present disclosure, Example 5 provides a method for processing an SQL statement, the method further comprising:

[0141] Searching for a second target node of a preset type in the expression node of the AST;

[0142] Obtain metadata information in the data table corresponding to the second target node according to the execution order of the SQL statements;

[0143] The metadata information corresponding to the second target node is bound to the second target node in the AST.

[0144] According to one or more embodiments of the present disclosure, Example 6 provides a method for processing an SQL statement, wherein the preset types are a table type, a column type, and a Map expression type;

[0145] When the second target node is of table type, the metadata information in the data table corresponding to the second target node is the metadata information of the corresponding table in the data table corresponding to the second target node;

[0146] When the second target node is of column type, the metadata information in the database corresponding to the second target node is the metadata information of the corresponding column in the data table corresponding to the second target node;

[0147] When the second target node is of a Map expression type, the metadata information in the data table corresponding to the second target node is the metadata information of the corresponding node in the data table corresponding to the second target node.

[0148] According to one or more embodiments of the present disclosure, Example 7 provides a method for processing an SQL statement, wherein calling a sensitivity calculation function of an internal node of the first target node to obtain the sensitivity of the internal node of the first target node includes:

[0149] Call the sensitivity calculation function of the internal nodes of the first target node, obtain the metadata information of the internal nodes of the first target node from the AST, and use the metadata information to calculate the sensitivity of the internal nodes of the first target node; the internal nodes of the first target node are matched with the second target node.

[0150] According to one or more embodiments of the present disclosure, Example 8 provides a device for processing an SQL statement, the device comprising:

[0151] A first acquisition unit is used to acquire SQL statements;

[0152] a conversion unit, configured to convert the SQL statement into an AST according to an abstract syntax tree (AST) conversion rule corresponding to the type of the SQL statement; the node types of the AST include statement nodes, block nodes, and expression nodes, the statement nodes include at least one block node, and the block nodes include at least one expression node;

[0153] A first search unit is used to search for a first target node belonging to an aggregate expression in the expression nodes of the AST;

[0154] A calling unit is used to call the sensitivity calculation function of the internal node of the first target node to obtain the sensitivity of the internal node of the first target node, and the sensitivity of the internal node of the first target node is used to execute the differential privacy algorithm for the first target node.

[0155] According to one or more embodiments of the present disclosure, Example 9 provides a device for processing an SQL statement, wherein the conversion unit includes:

[0156] A parsing subunit, configured to parse the SQL statement into an SQL statement word stream;

[0157] A matching subunit is used to match the words in the SQL statement word stream with the abstract syntax tree (AST) conversion rules corresponding to the type of the SQL statement, and determine the node type of the words and the node hierarchical relationship between each of the words;

[0158] The conversion subunit is used to convert the SQL statement into AST according to the node type of the word and the node hierarchical relationship between each of the words.

[0159] According to one or more embodiments of the present disclosure, Example 10 provides a device for processing an SQL statement, wherein the calling unit is specifically configured to:

[0160] Calling a sensitivity calculation function of an internal node of the first target node, obtaining metadata information of the internal node of the first target node, and using the metadata information to calculate the sensitivity of the internal node of the first target node; the metadata information is obtained by querying a data table through the SQL statement.

[0161] According to one or more embodiments of the present disclosure, Example 11 provides a device for processing an SQL statement, wherein when the first target node includes multiple levels of internal nodes, the calling unit is specifically configured to include:

[0162] The sensitivity calculation function of the first-level internal node of the target node is called to obtain the metadata information of the second-level internal node of the target node, and the sensitivity of the first-level internal node of the target node is calculated using the metadata information of the second-level internal node of the target node.

[0163] According to one or more embodiments of the present disclosure, Example 12 provides a device for processing SQL statements, the device further comprising:

[0164] A second search unit, configured to search for a second target node of a preset type in the expression node of the AST;

[0165] A second acquiring unit, configured to acquire metadata information in a data table corresponding to the second target node according to the execution order of the SQL statements;

[0166] A binding unit is used to bind the metadata information corresponding to the second target node with the second target node in the AST.

[0167] According to one or more embodiments of the present disclosure, Example 13 provides a device for processing SQL statements, wherein the preset types are table type, column type, and Map expression type;

[0168] When the second target node is of table type, the metadata information in the data table corresponding to the second target node is the metadata information of the corresponding table in the data table corresponding to the second target node;

[0169] When the second target node is of column type, the metadata information in the database corresponding to the second target node is the metadata information of the corresponding column in the data table corresponding to the second target node;

[0170] When the second target node is of a Map expression type, the metadata information in the data table corresponding to the second target node is the metadata information of the corresponding node in the data table corresponding to the second target node.

[0171] According to one or more embodiments of the present disclosure, Example 14 provides a device for processing an SQL statement, wherein the calling unit is specifically configured to:

[0172] Call the sensitivity calculation function of the internal nodes of the first target node, obtain the metadata information of the internal nodes of the first target node from the AST, and use the metadata information to calculate the sensitivity of the internal nodes of the first target node; the internal nodes of the first target node are matched with the second target node.

[0173] According to one or more embodiments of the present disclosure, Example 15 provides a device for processing SQL statements, including: a memory, a processor, and a computer program stored on the memory and executable on the processor. When the processor executes the computer program, it implements the method for processing SQL statements as described in any one of Examples 1 to 7.

[0174] According to one or more embodiments of the present disclosure, Example 16 provides a computer-readable storage medium, characterized in that the computer-readable storage medium stores instructions, and when the instructions are executed on a terminal device, the terminal device executes the SQL statement processing method described in any one of Examples 1 to 7.

[0175] It should be noted that the various embodiments of this disclosure are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. Reference can be made to the descriptions of the systems or devices disclosed in the embodiments for similarities and differences between them. Since the systems or devices disclosed in the embodiments correspond to the methods disclosed in the embodiments, their descriptions are relatively simple, and reference can be made to the descriptions of the methods for any related details.

[0176] It should be understood that in the present disclosure, "at least one (item)" refers to one or more, and "plurality" refers to two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the previous and next associated objects are in an "or" relationship. "At least one of the following items" or similar expressions refers to any combination of these items, including any combination of single items or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.

[0177] It should also be noted that, in this document, relational terms such as first and second, etc., are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprise," "include," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or device. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not preclude the presence of additional identical elements in the process, method, article, or device comprising the element.

[0178] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), internal memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.

[0179] The above description of the disclosed embodiments is intended to enable one skilled in the art to implement or use the present disclosure. Various modifications to these embodiments will be readily apparent to one skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present disclosure. Therefore, the present disclosure is not limited to the embodiments shown herein, but is intended to be construed in the widest manner consistent with the principles and novel features disclosed herein.

Claims

1. A method for processing a structured query language SQL statement, comprising: Get SQL statements; Convert the SQL statement into an AST according to an abstract syntax tree (AST) conversion rule corresponding to the type of the SQL statement; The node types of the AST include statement nodes, block nodes and expression nodes, the statement node includes at least one block node, and the block node includes at least one expression node; Searching for a first target node belonging to an aggregate expression in the expression nodes of the AST; A sensitivity calculation function of an internal node of the first target node is called to obtain the sensitivity of the internal node of the first target node, where the sensitivity of the internal node of the first target node is used to execute a differential privacy algorithm for the first target node.

2. The method according to claim 1, wherein: The converting the SQL statement into an AST according to an abstract syntax tree AST conversion rule corresponding to the type of the SQL statement includes: Parsing the SQL statement into a SQL statement word stream; Match the words in the SQL statement word stream with the abstract syntax tree (AST) conversion rules corresponding to the type of the SQL statement, and determine the node type of the words and the node hierarchical relationship between each of the words; The SQL statement is converted into AST according to the node type of the word and the node level relationship between each of the words.

3. The method according to claim 1, wherein: The calling of the sensitivity calculation function of the internal node of the first target node to obtain the sensitivity of the internal node of the first target node includes: Calling a sensitivity calculation function of the internal nodes of the first target node, obtaining metadata information of the internal nodes of the first target node, and using the metadata information to calculate the sensitivity of the internal nodes of the first target node; the metadata information is obtained by querying a data table through the SQL statement.

4. The method according to claim 3, wherein: When the first target node includes multiple levels of internal nodes, calling the sensitivity calculation function of the internal nodes of the first target node, obtaining metadata information of the internal nodes of the first target node, and calculating the sensitivity of the internal nodes of the first target node using the metadata information includes: The sensitivity calculation function of the first-level internal nodes of the target node is called to obtain metadata information of the second-level internal nodes of the target node, and the sensitivity of the first-level internal nodes of the target node is calculated using the metadata information of the second-level internal nodes of the target node.

5. The method according to any one of claims 1 to 4, further comprising: Searching for a second target node of a preset type in the expression node of the AST; Obtaining metadata information in the data table corresponding to the second target node according to the execution order of the SQL statements; The metadata information corresponding to the second target node is bound to the second target node in the AST.

6. The method according to claim 5, wherein: The preset types are table type, column type and Map expression type; When the second target node is of table type, the metadata information in the data table corresponding to the second target node is the metadata information of the corresponding table in the data table corresponding to the second target node; When the second target node is of column type, the metadata information in the database corresponding to the second target node is the metadata information of the corresponding column in the data table corresponding to the second target node; When the second target node is of a Map expression type, the metadata information in the data table corresponding to the second target node is the metadata information of the corresponding node in the data table corresponding to the second target node.

7. The method according to claim 5 or 6, wherein: The calling of the sensitivity calculation function of the internal node of the first target node to obtain the sensitivity of the internal node of the first target node includes: Call the sensitivity calculation function of the internal nodes of the first target node, obtain the metadata information of the internal nodes of the first target node from the AST, and use the metadata information to calculate the sensitivity of the internal nodes of the first target node; the internal nodes of the first target node are matched with the second target node.

8. A structured query language SQL statement processing device, comprising: A first acquisition unit is configured to acquire an SQL statement; The conversion unit is configured to convert the SQL statement into an AST according to an abstract syntax tree AST conversion rule corresponding to the type of the SQL statement; the node type of the AST includes a statement node points, block nodes and expression nodes, the statement node includes at least one block node, and the block node includes at least one expression node; A first search unit is configured to search for a first target node belonging to an aggregate expression in the expression nodes of the AST; A calling unit is configured to call a sensitivity calculation function of an internal node of the first target node to obtain the sensitivity of the internal node of the first target node, and the sensitivity of the internal node of the first target node is used to execute a differential privacy algorithm for the first target node.

9. A structured query language SQL statement processing device, comprising: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the method for processing an SQL statement according to any one of claims 1 to 7 is implemented.

10. A computer-readable storage medium, wherein: The computer-readable storage medium stores instructions, and when the instructions are executed on a terminal device, the terminal device executes the method for processing SQL statements according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Dynamic desensitization method based on full syntax tree analysis

    CN111125758A

  • Privacy protection query language PQL and system thereof

    CN112162998A

  • Data desensitization method and device, electronic equipment and storage medium

    CN112765658A

  • SQL statement processing method, device and equipment

    CN116226169A

  • Systems and methods for privacy-enhancing transformation of a SQL query

    US20200380159A1

Cited By

  • Data desensitization method, device and equipment for distributed database

    CN119128995A

  • Multi-source heterogeneous database SQL statement sensitivity calculation method

    CN119166671A

  • Self-adaptive SQL (Structured Query Language) differential privacy noise adding method

    CN119201981A

  • Stream processing method and system based on graph structure and SQL (Structured Query Language) statement

    CN120849417A