Information query method, device, computer equipment and computer readable storage medium

By splitting the query task into single-party subqueries and federated subqueries, using appropriate execution engine processing, the problem of inefficiency of cross-database queries is solved, and data isolation and efficiency improvement is achieved.

CN114443699BActive Publication Date: 2024-11-22TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202210099919.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-01-27
Publication Date
2024-11-22
Estimated Expiration
2042-01-27

AI Technical Summary

Technical Problem

In cross-database information query, the prior art requires transferring data to a closed domain for querying, resulting in inefficient query, and traditional SQL execution engines are unable to handle data isolation problems between multiple databases, affecting query efficiency.

Method used

By splitting the query task into single-party subqueries and federated subqueries, the traditional SQL execution engine and the federated secure SQL execution engine process are used respectively to achieve data isolation and improve query efficiency.

Benefits of technology

There is no need to transfer the data of multiple databases to a closed domain for querying, which significantly improves the efficiency of information query and solves the problem of data isolation between multiple databases.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114443699B_ABST
    Figure CN114443699B_ABST
Patent Text Reader

Abstract

The present application discloses an information query method, device, computer equipment and computer-readable storage medium. The method obtains a query task; splits the query task to obtain a first number of first sub-query tasks and a second number of second sub-query tasks, wherein the first sub-query task is a query task based on a single database, and the second sub-query task is a query task based on at least two databases; uses a first execution engine to execute the first sub-query task, and uses a second execution engine to execute the second sub-query task, and when the second execution engine executes the second sub-query task, the data between the databases associated with the second sub-query task is isolated; and determines the query result corresponding to the query task according to the execution result of the sub-query task. The method can greatly improve the efficiency of information query on the basis of ensuring data security.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to an information query method, device, computer equipment and computer-readable storage medium. Background Art

[0002] In recent years, the rapid development of Internet technology has greatly reduced the cost of obtaining information, and has led society into the big data era of knowledge explosion.

[0003] In the era of big data, various data query methods can be used to find the information needed in various databases. Among them, Structured Query Language (SQL) is a database language with multiple functions such as data manipulation and data definition. This language is interactive and can provide great convenience. Database management systems can make full use of SQL language to improve the work quality and efficiency of computer application systems.

[0004] At present, in order to ensure the security of data use, when cross-database information query is involved, the closed domain method is generally used to store the information in the database involved in the closed domain for query operation. When the query results need to be exported, further review is required, and the query results can only be exported after the review is passed. This method leads to very low efficiency of security information query. Summary of the invention

[0005] The embodiments of the present application provide an information query method, an apparatus, a computer-readable storage medium, and a computer device. The information query method can effectively improve the efficiency of information query.

[0006] The first aspect of the present application provides an information query method, the method comprising:

[0007] Get query tasks;

[0008] Splitting the query task to obtain a first number of first sub-query tasks and a second number of second sub-query tasks, wherein the first sub-query tasks are query tasks based on a single database, and the second sub-query tasks are query tasks based on at least two databases;

[0009] A first execution engine is used to execute the first sub-query task, and a second execution engine is used to execute the second sub-query task. When the second execution engine executes the second sub-query task, data between databases associated with the second sub-query task are isolated;

[0010] The query result corresponding to the query task is determined according to the execution result of the sub-query task.

[0011] Accordingly, the second aspect of the present application provides an information query device, the device comprising:

[0012] An acquisition unit, used for acquiring query tasks;

[0013] a splitting unit, configured to split the query task to obtain a first number of first sub-query tasks and a second number of second sub-query tasks, wherein the first sub-query tasks are query tasks based on a single database, and the second sub-query tasks are query tasks based on at least two databases;

[0014] an execution unit, configured to use a first execution engine to execute the first sub-query task, and use a second execution engine to execute the second sub-query task, wherein when the second execution engine executes the second sub-query task, data between databases associated with the second sub-query task are isolated;

[0015] The determination unit is used to determine the query result corresponding to the query task according to the execution result of the sub-query task.

[0016] In some embodiments, the splitting unit comprises:

[0017] A first acquisition subunit, used to acquire the query data included in the query task;

[0018] The analysis subunit is used to perform semantic analysis on the query data, and split the query task into a first number of first sub-query tasks and a second number of second sub-query tasks according to the semantic analysis result.

[0019] In some embodiments, the analysis subunit comprises:

[0020] A parsing module, used to parse the query data and obtain a syntax tree corresponding to the query data;

[0021] A splitting module, used for splitting the syntax tree to obtain a plurality of sub-query data;

[0022] The detection module is used to detect the multiple sub-query data, and when the sub-query data meets the preset classification condition, generate a second sub-query task according to the sub-query data; when the sub-query data does not meet the preset classification condition, generate a first sub-query task according to the sub-query data.

[0023] In some embodiments, the detection module comprises:

[0024] A first generating submodule is used to generate a second subquery task according to the subquery data when there is an operator for cross-database query in the subquery data;

[0025] The second generating submodule is used to generate a first subquery task according to the subquery data when there is no cross-database query operator in the subquery data.

[0026] In some embodiments, the parsing module includes:

[0027] An identification submodule, used to identify query operators and data objects in the query data;

[0028] A construction submodule is used to construct a syntax tree with the query operator as a non-leaf node and the data object as a leaf node.

[0029] In some embodiments, the information query device provided by the present application further includes:

[0030] A second acquisition subunit, configured to acquire the logical relationship between the sub-query tasks according to the query data;

[0031] The determining unit is further configured to:

[0032] The query result corresponding to the query task is determined according to the execution result of the sub-query task and the logical relationship.

[0033] In some embodiments, the determining unit includes:

[0034] A generating sub-unit, used for generating a graph network of a sub-query task according to the logical relationship;

[0035] The execution subunit is used to execute each sub-query task in sequence according to the graph network to obtain the query result corresponding to the query task.

[0036] In some embodiments, the generating subunit comprises:

[0037] An acquisition module, used for acquiring the execution order between sub-query tasks from the logical relationship;

[0038] A generation module is used to generate a graph network of sub-query tasks with each sub-query task as a node and the execution order as an edge.

[0039] The third aspect of the present application also provides a computer-readable storage medium, which stores multiple instructions, and the instructions are suitable for a processor to load to execute the steps in the information query method provided in the first aspect of the present application.

[0040] The fourth aspect of the present application provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the information query method provided in the first aspect of the present application when executing the computer program.

[0041] The fifth aspect of the present application provides a computer program product, including a computer program / instruction, which, when executed by a processor, implements the steps in the information query method provided in the first aspect.

[0042] The information query method provided in the embodiment of the present application obtains a query task; splits the query task to obtain a first number of first sub-query tasks and a second number of second sub-query tasks, wherein the first sub-query task is a query task based on a single database, and the second sub-query task is a query task based on at least two databases; uses a first execution engine to execute the first sub-query task, and uses a second execution engine to execute the second sub-query task, and when the second execution engine executes the second sub-query task, the data between the databases associated with the second sub-query task are isolated; and determines the query result corresponding to the query task according to the execution result of the sub-query task.

[0043] In this way, the information query method provided by the present application can split the query task into a unilateral sub-query task involving only one database and a multi-party sub-query task involving multiple databases. For the multi-party sub-query task involving multiple databases, a data-isolated secure query execution engine is used for processing, so that there is no need to transfer the data of the multiple databases involved to a closed domain for query, which can greatly improve the efficiency of information query. BRIEF DESCRIPTION OF THE DRAWINGS

[0044] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. Other drawings can be obtained based on these drawings without creative work.

[0045] Figure 1 It is a schematic diagram of a scenario for information query in this application;

[0046] Figure 2 It is a flowchart of the information query method provided by this application;

[0047] Figure 3 is another flow chart of the information query method provided by the present application;

[0048] Figure 4A It is a schematic diagram of the abstract syntax tree of the SQL query statement;

[0049] Figure 4B It is a schematic diagram of the directed acyclic graph of SQL query statements;

[0050] Figure 5 It is a structural schematic diagram of the information query device provided by this application;

[0051] Figure 6 It is a structural schematic diagram of the computer device provided by this application. DETAILED DESCRIPTION

[0052] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained without creative work are within the scope of protection of the present invention.

[0053] The embodiments of the present invention provide an information query method, device, computer equipment and computer-readable storage medium. Among them, the information query method can be used in an information query device. The information query device can be integrated in a computer device, and the computer device can be a terminal or a server. Among them, the terminal can be a mobile phone, a tablet computer, a laptop computer, a smart TV, a wearable smart device, a desktop computer, and a vehicle-mounted terminal. The server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, network acceleration services (Content Delivery Network, CDN), and big data. Among them, the server can be a node in a blockchain.

[0054] See also Figure 1 , which is a schematic diagram of a scenario of the information query method provided in the present application. As shown in the figure, server A receives the query task sent by terminal B, and then server A splits the query task into multiple sub-tasks, wherein the multiple sub-tasks include a first number of first sub-query tasks and a second number of second sub-query tasks. The first sub-query task is a query task based on a single database, and the second sub-query task is a query task based on at least Liangge database. Then, server A uses the first execution engine to execute the first sub-query task, and uses the second execution engine to execute the second sub-query task. Among them, when the second execution engine is used to execute the second sub-query task, the data between the databases associated with the second sub-query task are isolated. Then, the query result of the query task is determined according to the execution result of the sub-query task. Further, server A can send the query result of the query task to terminal B.

[0055] It should be noted that Figure 1The information query scenario diagram shown is only an example. The information query scenario described in the embodiment of this application is to more clearly illustrate the technical solution of this application and does not constitute a limitation on the technical solution provided by this application. With the evolution of information query scenarios and the emergence of new business scenarios, the technical solution provided by this application is also applicable to similar technical problems.

[0056] Based on the above implementation scenarios, detailed descriptions are given below.

[0057] In related technologies, when a data query task involves multiple databases, in order to ensure the data security in each database, it is often necessary to transfer the data in multiple databases to a closed domain for query. After the query task is completed, the query results need to be further reviewed. Only after the review is passed can the query results be queried everywhere. This method results in very low query efficiency for cross-database security query tasks. The present application provides an information query method that can improve the query efficiency of information query in a targeted manner.

[0058] The embodiments of the present application will be described from the perspective of an information query device, which can be integrated in a computer device. The computer device can be a terminal or a server. The terminal can be a mobile phone, a tablet computer, a laptop computer, a smart TV, a wearable smart device, a desktop computer, a vehicle-mounted terminal and other devices. The server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers. It can also be a cloud server that provides cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, network acceleration services (Content Delivery Network, CDN), and big data and other basic cloud computing services. Figure 2 FIG. 1 is a flow chart of an information query method provided by the present application, and the method includes:

[0059] Step 101, obtaining a query task.

[0060] The query task may be a query task received from other terminals, or may be a query task generated according to input query data.

[0061] Among them, the query data can be Structured Query Language (SQL). SQL is a special purpose programming language, a database query and programming language, used to access data as well as query, update and manage relational database systems. Structured Query Language is a non-procedural programming language that allows users to work on high-level data structures. It does not require the specification of data storage methods, nor does it require understanding of specific data storage methods, so different database systems with completely different underlying structures can use the same structured query language as an interface for data input and management. Structured Query Language statements can be nested, which gives it great flexibility and powerful functions. SQL can be functionally divided into three parts: data definition, data manipulation and data control.

[0062] In the related art, when executing SQL query tasks, a single execution engine is often used to execute SQL query tasks. That is, when receiving input SQL query data, the input SQL query data is directly input into a suitable execution engine to execute the query task, and then the query result output by the execution engine is received. In traditional SQL query tasks, data query is generally performed in one database, and the execution engine that performs data query in only one database can be called a traditional SQL execution engine. Specifically, for example, a relational database management system (MySQL) is a typical traditional SQL execution engine. Relational databases store data in different tables instead of putting all data in a large warehouse, which increases speed and flexibility. However, since traditional SQL execution engines can only execute query tasks in one database, it is necessary to transfer candidate data to the same database for query before the query task is executed. For example, when the query task involves both data in database A and data in database B, it is necessary to first transfer the data in any database to another database for aggregation, and then execute the query task in the database containing the aggregated data, which will reduce the query efficiency.

[0063] Among them, the database can be simply regarded as an electronic filing cabinet - a place to store electronic files, where users can add, query, update, delete, etc. The so-called "database" is a collection of data that is stored together in a certain way, can be shared with multiple users, has as little redundancy as possible, and is independent of the application program.

[0064] A database management system (DBMS) is a computer software system designed for managing databases. It generally has basic functions such as storage, retrieval, security, and backup. Database management systems can be classified according to the database model they support, such as relational, XML (Extensible Markup Language); or according to the type of computer they support, such as server clusters, mobile phones; or according to the query language used, such as SQL (Structured Query Language), XQuery; or according to performance focus, such as maximum scale, maximum operating speed; or other classification methods. Regardless of the classification method used, some DBMS can cross categories, for example, supporting multiple query languages ​​at the same time.

[0065] Moreover, in some cases, for data security reasons, such as data protection regulations and commercial interest competition, data between different databases need to be isolated to prevent data leakage, which leads to the emergence of "data islands". For example, database A stores all data related to a certain game, including player information, character information, prop information, and gameplay information; database B stores all data related to a certain instant messaging application, such as friend information, function information, and communication record information. Among them, it is understandable that when it comes to using user information and other related data, the user's permission or consent is required, and the collection, use and processing of relevant data must comply with relevant laws, regulations and standards of relevant countries and regions. Since the data in database A and database B cannot be shared with each other, if it is necessary to analyze the operation of the game by the player in the instant messaging application, and the data in the two databases need to be used, the traditional SQL execution engine cannot complete the task.

[0066] This makes it impossible to transfer data from different databases to the same database for query, or it can only be transferred to a closed domain for query. After using the traditional SQL execution engine to execute query tasks in a closed domain, when the query results need to be output, it is necessary to further submit an application, and the corresponding reviewer will review and output the query results, which greatly affects the query efficiency. In this regard, a federal security SQL execution engine that can cross databases and execute query tasks securely can be developed specifically. The federal security SQL execution engine is based on secure joint analysis technology. In the federal security SQL execution engine, independent tasks are started locally to complete the federal table connection together. Each independent task exchanges intermediate data or encrypts data to ensure that the other party's detailed data cannot be inferred from these data.

[0067] The federal secure SQL execution engine can solve the problem of data islands and execute secure query tasks across databases. However, since the federal secure SQL execution engine needs to ensure data isolation between databases, it needs to run certain algorithms to encrypt data and perform other processing. This will also lead to a decrease in the query efficiency of the query task. For this reason, the present application provides an information query method that can improve the efficiency of information query to a certain extent. The information query method provided by the present application is further introduced in detail below.

[0068] Step 102: split the query task to obtain a first number of first sub-query tasks and a second number of second sub-query tasks.

[0069] Among them, in the embodiment of the present application, after obtaining the query task, it is no longer necessary to directly call a suitable single SQL execution engine to execute the query task as a whole, but the query task can be split into multiple sub-query tasks and then each sub-query task is executed separately, and then the query results of the sub-query tasks are combined to determine the final query result of the query task. The sub-query task may include a first number of first sub-query tasks and a second number of second sub-query tasks. The first sub-query task can be a query task based on a single database, which can also be called a unilateral sub-query; the second sub-query task can be a query task based on at least two databases, which can be called a federated sub-query. Among them, the sub-query can be a query block. In the SQL language, a SELECT-FROM-WHERE statement is called a query block.

[0070] The first number and the second number may be 0 or a positive integer, but the first number and the second number may not be 0 at the same time.

[0071] In some embodiments, splitting a query task to obtain a first number of first sub-query tasks and a second number of second sub-query tasks includes:

[0072] 1. Get the query data contained in the query task;

[0073] 2. Perform semantic analysis on the query data, and split the query task into a first number of first sub-query tasks and a second number of second sub-query tasks according to the semantic analysis result.

[0074] Among them, in an embodiment of the present application, when the information query device obtains a query task, the input SQL query data can be extracted from the query task. Since the SQL query data is a structured query language written in a certain format, the query data contains a plurality of special words about the query, such as selection (SELECT), union (UNION) and connection (JOIN), etc. The information query device can perform semantic analysis on the input query data based on these special words, wherein the semantic analysis includes lexical analysis and grammatical analysis. Among them, lexical analysis is to perform word segmentation operation on the SQL query statement, and grammatical analysis refers to grammatical analysis of the word segmentation result to obtain the corresponding class. Among them, grammatical analysis can be implemented using the language recognition tool ANLTR, the full name of ANLTR in English is Another Tool For Language Recognition, which is an open source grammatical analyzer. Then, the query task can be further split into a first number of first sub-queries and a second number of second sub-queries according to the results of the semantic analysis.

[0075] In some embodiments, performing semantic analysis on query data and splitting the query task into a first number of first sub-query tasks and a second number of second sub-query tasks according to the semantic analysis result includes:

[0076] 2.1. Parse the query data and obtain the syntax tree corresponding to the query data;

[0077] 2.2. Split the syntax tree to obtain multiple subquery data;

[0078] 2.3. Detect multiple sub-query data. When the sub-query data meets the preset classification condition, generate a second sub-query task according to the sub-query data. When the sub-query data does not meet the preset classification condition, generate a first sub-query task according to the sub-query data.

[0079] In the embodiment of the present application, semantic analysis is performed on the input query data to obtain a syntax tree corresponding to the query data, which may be an abstract syntax tree (AST). The semantic analysis of the input query data to obtain the corresponding syntax tree may be implemented using the aforementioned language recognition tool ANLTR, which may automatically generate a syntax tree based on the input query data and display it visually.

[0080] When a single execution engine is used to execute a query task, after generating the syntax tree corresponding to the query data, the execution engine can traverse the syntax tree, generate the corresponding logical plan, and then further generate the physical plan and execute the physical plan to execute the query task. In the embodiment of the present application, it is necessary to further split the syntax tree corresponding to the query data to obtain multiple branches, that is, to obtain multiple sub-query data, where each sub-query data corresponds to a sub-query task. Then, these sub-query data are classified into data corresponding to unilateral sub-queries and data corresponding to federated sub-queries. Furthermore, corresponding unilateral sub-queries and federated sub-queries are generated respectively according to the sub-query data.

[0081] In some embodiments, parsing the query data to obtain a syntax tree corresponding to the query data includes:

[0082] 2.1.1. Identify query operators and data objects in query data;

[0083] 2.1.2. Construct a syntax tree with query operators as non-leaf nodes and data objects as leaf nodes.

[0084] Wherein, as mentioned above, since SQL query data is a structured query language written in a certain format, the query data contains a plurality of special words about the query, such as selection (SELECT), union (UNION) and joining (JOIN) etc. In the embodiment of the present application, these special words can be determined as query operators. Further, in addition to the above-mentioned query operators, the SQL language also includes a data object of the query, which can be an identifier of a specific data table (such as a table ID). In the embodiment of the present application, when constructing a syntax tree corresponding to the query data, the query operator can be a non-leaf node, and the data object can be a leaf node to create a syntax tree corresponding to the query data. Wherein, the non-leaf node here is a node other than a leaf node in the syntax tree.

[0085] In some embodiments, multiple sub-query data are detected, and when the sub-query data meets the preset classification condition, a second sub-query task is generated according to the sub-query data, and when the sub-query data does not meet the preset classification condition, a first sub-query task is generated according to the sub-query data, including:

[0086] 2.3.1. When there are cross-database query operators in the subquery data, a second subquery task is generated based on the subquery data;

[0087] 2.3.2. When there is no cross-database query operator in the subquery data, a first subquery task is generated according to the subquery data.

[0088] In an embodiment of the present application, a method of detecting whether there is an operator of cross-database query in the subquery data can be used to determine whether the subquery task corresponding to the subquery data is a unilateral subquery or a federated subquery. Specifically, when there is an operator of cross-database query in the subquery data, it can be determined that the query task corresponding to the subquery data is a federated subquery, that is, a federated subquery can be generated based on the subquery data, that is, the aforementioned second subquery task. On the contrary, if there is no operator of cross-database query in the subquery data, a unilateral subquery is generated based on the subquery data, that is, the aforementioned first subquery task.

[0089] In some embodiments, after detecting that the sub-query data contains an operator for cross-database query, it cannot be determined that the sub-query task corresponding to the sub-query data is a federated sub-query, and it is necessary to further detect whether the query operator accesses multiple tables across sources. If the detection determines that the query operator accesses multiple tables across sources, then the sub-query task corresponding to the sub-query data is determined to be a federated sub-query; otherwise (that is, the query operator does not access multiple tables across sources), then the sub-query task corresponding to the sub-query data is determined to be a unilateral sub-query.

[0090] Step 103: Use the first execution engine to execute the first sub-query task, and use the second execution engine to execute the second sub-query task.

[0091] Among them, after the information query device splits the query task into a first number of first sub-query tasks and a second number of second sub-query tasks, different execution engines can be used to execute the first sub-query task and the second sub-query task. Specifically, according to the above description, it can be known that the first sub-query task is a unilateral sub-query, and the second sub-query task is a federated sub-query. Then the first execution engine that executes the first sub-query task can be the above-mentioned traditional SQL execution engine, and the second execution engine that executes the second sub-query task can be the above-mentioned federated security SQL execution engine.

[0092] In this way, this application can encapsulate as much query logic related to local operations as possible into unilateral subqueries by splitting the unilateral subqueries and federated subqueries in the query task, and then hand it over to the existing traditional SQL execution engine for processing. In this way, the capabilities of the existing traditional SQL execution engine can be reused, the query workload can be reduced (no need to encrypt the relevant data or perform other security processing), and then the development efficiency and information query efficiency can be improved. Moreover, by splitting the overall query task into multiple subquery tasks, the execution engine can be decoupled, and the most suitable execution engine can be used to execute the query task for each subquery task, thereby further improving the information query efficiency.

[0093] Step 104: determine the query result corresponding to the query task according to the execution result of the sub-query task.

[0094] Among them, after using different execution engines to process multiple sub-query tasks obtained by splitting the query task and obtaining the execution result of each sub-query task, the query result corresponding to the query task can be further generated according to the execution result of the sub-query task.

[0095] In some embodiments, the information query method provided by the present application further includes:

[0096] 1. Obtain the logical relationship between sub-query tasks based on query data;

[0097] The query result corresponding to the query task is determined according to the execution result of the subquery task, including:

[0098] 2. Determine the query result corresponding to the query task based on the execution result and logical relationship of the sub-query task.

[0099] In the embodiment of the present application, the query task not only includes multiple sub-query tasks obtained by splitting, but also includes the logical relationship between the sub-query tasks. After obtaining the execution result of each sub-query task executed by the corresponding SQL execution engine, the execution result of each sub-query task can be fused according to the logical relationship between the sub-query tasks to obtain the query result of the query task.

[0100] In some embodiments, determining the query result corresponding to the query task according to the execution result and the logical relationship of the sub-query task includes:

[0101] 2.1. Generate a graph network for subquery tasks based on logical relationships;

[0102] 2.2. Execute each sub-query task sequentially according to the graph network to obtain the query result corresponding to the query task.

[0103] In an embodiment of the present application, after obtaining the logical relationship between the sub-query tasks, a graph network of the sub-query tasks can be generated according to the logical relationship between the sub-query tasks. The graph network here can be a directed acyclic graph (DAG). In mathematics, especially in graph theory and computer science, a directed acyclic graph refers to a directed graph without loops, and the partial order relationship of the directed acyclic graph can play a role in scheduling system tasks with sequence restrictions. The directed acyclic graph of the sub-query task can include multiple sub-views. When executing a query task, each sub-view in the directed acyclic graph can be traversed, and each sub-query task can be executed according to the node flow order in the sub-view to obtain the query result corresponding to the query task.

[0104] In some embodiments, generating a graph network of subquery tasks according to logical relationships includes:

[0105] 2.1.1. Obtain the execution order between subquery tasks from the logical relationship;

[0106] 2.1.2. Generate a graph network of subquery tasks with each subquery task as a node and the execution order as an edge.

[0107] Among them, in the embodiment of the present application, after splitting the query task into multiple sub-query tasks and obtaining the logical relationship between the sub-query tasks, the execution order of the sub-query tasks can be determined from the logical relationship between the sub-query tasks. Then, the graph network of the sub-query tasks can be constructed with the sub-query tasks as nodes of the graph network and the execution order between the sub-query tasks as edges of the graph network.

[0108] According to the above description, the information query method provided in the embodiment of the present application obtains a query task; splits the query task to obtain a first number of first sub-query tasks and a second number of second sub-query tasks, the first sub-query task is a query task based on a single database, and the second sub-query task is a query task based on at least two databases; uses a first execution engine to execute the first sub-query task, and uses a second execution engine to execute the second sub-query task, and when the second execution engine executes the second sub-query task, the data between the databases associated with the second sub-query task are isolated; determines the query result corresponding to the query task according to the execution result of the sub-query task.

[0109] In this way, the information query method provided by the present application can split the query task into a unilateral sub-query task involving only one database and a multi-party sub-query task involving multiple databases. For the multi-party sub-query task involving multiple databases, a data-isolated secure query execution engine is used for processing, so that there is no need to transfer the data of the multiple databases involved to a closed domain for query, which can greatly improve the efficiency of information query.

[0110] The present application also provides an information query method, which can be used in a computer device, which can be a terminal or a server. In the present application, the computer device can be used as a server as an example for detailed description. Figure 3 FIG. 1 is another flow chart of the information query method provided by the present application, and the method specifically includes:

[0111] Step 201: The computer device receives input SQL data.

[0112] Among them, for traditional SQL execution engines, commonly used ways to connect two tables T1 and T2 include join, union, and implicit table join. The following Table 1 shows examples of different connection methods.

[0113] Connection Example Join Select max(T1.count)from T1 join T2 on T1.id=T2.id Union (Select*from T1)Union(Select*from T2) Implicit table join Select max(T1.count)from T1,T2 where T1.id=T2.id

[0114] Table 1 Connection method examples

[0115] Moreover, the traditional SQL execution engine requires that the two tables are stored in the same database at the same time to execute the corresponding query task. If the two tables T1 and T2 belong to different databases, and the data between the two databases is sensitive, the plain text data cannot be directly synchronized to each other. In this case, the traditional SQL execution engine cannot solve the problem of federated table connection, and a federated secure SQL execution engine is needed to execute the relevant query tasks. Specifically, the federated secure SQL execution engine can be PowerFL-SQL (a federated secure SQL execution engine).

[0116] The federated secure SQL execution engine, also known as secure federated analysis technology, is a computing-based secure SQL execution engine that can solve data analysis problems in "data island" scenarios. In the federated table connection scenario, independent tasks are started locally to complete the federated table connection together. Each independent task exchanges intermediate data or encrypted data, and the detailed data of the other party cannot be inferred from these data.

[0117] There are different implementation methods for secure joins, secure unions, secure implicit table joins, and other secure operations in federated scenarios. For example, secure joins or secure implicit table joins can be implemented based on private set intersection (PSI). PSI means that both parties obtain the intersection of the data held by both parties without leaking any additional information. Here, additional information refers to any information other than the intersection of the data of both parties. Secure Union can be implemented based on private set intersection (PSU), which means that both parties obtain the union of the data held by both parties without leaking any additional information.

[0118] The information query method provided in this application mainly provides a subquery-based secure joint analysis solution. This solution mainly focuses on secure operators that need to be federated, such as secure Join, secure implicit table join, and secure Union. For operators that do not need to be federated, the capabilities of the existing traditional SQL execution engine can be reused. Therefore, it is necessary to encapsulate as much logic related to local operations as possible into one-way subqueries and hand them over to the traditional SQL execution engine for processing. One-way subqueries can not only reuse the capabilities of traditional SQL execution engines, reduce unnecessary workload, and improve development efficiency and service capabilities, but also decouple the execution engine so that different subqueries can be executed using an adapted execution engine to improve query efficiency.

[0119] In an embodiment of the present application, the input SQL query data may include both unilateral query operators and federated query operators.

[0120] Step 202: The computer device parses the SQL data and generates an abstract syntax tree according to the parsing result.

[0121] After receiving the input SQL statement, the computer device parses the SQL data. The parsing of SQL data includes lexical analysis and grammatical analysis. The lexical analysis segments the input SQL statement to obtain the segmentation result. Then the grammatical analysis is used to process the segmentation result to obtain the abstract syntax tree corresponding to the SQL statement. The language recognition tool ANLTR can be used to process the segmentation result to obtain the abstract syntax tree corresponding to the SQL statement. ANLTR can automatically generate a syntax tree based on the input SQL statement and display it visually. Figure 4A As shown, it is a schematic diagram of the abstract syntax tree corresponding to the SQL query statement provided in this application. Among them, non-leaf nodes such as Select, Expression, Count, etc. represent query operators in SQL statements, or are called keywords or reserved characters in SQL statements. Leaf nodes such as pa.ta.id and pb.tb.id represent data objects, which can be different tables, such as T1 and T2 mentioned above, or field names, values ​​or strings, etc.

[0122] Step 203: The computer device partitions the abstract syntax tree to obtain a plurality of unilateral subqueries and a plurality of federated subqueries.

[0123] Among them, after the abstract syntax tree corresponding to the input SQL query statement is generated, the abstract syntax tree can be divided according to certain division rules to obtain two types of subqueries. Among them, one of the two types of subqueries is a unilateral subquery, and the other is a federated subquery. Among them, the method of distinguishing whether a subquery is a unilateral subquery or a federated subquery can be specifically to first detect whether the subquery contains a federated operator; if the subquery contains a federated operator, then further detect whether the federated operator accesses multiple data tables across sources. If the federated operator in the subquery accesses multiple data tables across sources, it can be determined that the subquery is a federated subquery. If the subquery does not meet any of the above two conditions, the subquery is determined to be a unilateral subquery.

[0124] After the abstract syntax tree is divided to obtain a plurality of unilateral subqueries and a plurality of federated subqueries, the unilateral subqueries and the federated subqueries are encapsulated separately.

[0125] Step 204: The computer device connects the multiple unilateral sub-queries and the multiple federated sub-queries in series into a directed acyclic graph according to the logical relationship between the sub-queries in the abstract syntax tree.

[0126] There is a certain dependency relationship between the multiple subqueries obtained by dividing the abstract syntax tree of the input SQL query statement. The dependency relationship is the execution logic relationship between different subqueries. The execution logic relationship between different subqueries is the edge of the graph network, and the different subqueries are the nodes of the graph network. The graph network corresponding to the input SQL query statement can be generated. The graph network can be a directed acyclic graph. The directed acyclic graph can include multiple subviews, such as Figure 4B As shown, it is a schematic diagram of a subview in a directed acyclic graph provided by the present application, which is composed of multiple subqueries as nodes and the dependency relationship between subqueries as edges. In this subview, four unilateral subqueries are included: a first unilateral subquery 10, a second unilateral subquery 20, a third unilateral subquery 40, and a fourth unilateral subquery 50; and a federated subquery: a first federated subquery 30. Among them, the first unilateral subquery 10 depends on the second unilateral subquery 20, the second unilateral subquery 20 depends on the first federated subquery 30, and the first federated subquery 30 depends on the third unilateral subquery 40 and the fourth unilateral subquery 50.

[0127] Step 205 : The computer device traverses the directed acyclic graph to execute the query task corresponding to the SQL data.

[0128] After constructing the directed acyclic graph corresponding to the input SQL query statement, each sub-view in the directed acyclic graph can be traversed to execute the query task. The execution steps of the sub-query can be determined according to the dependency relationship in the sub-view. For example, Figure 4B In the sub-view shown, the third unilateral sub-query 40 and the fourth unilateral sub-query 50 are executed first, then the first federated sub-query 30 is executed, then the second unilateral sub-query 20 is executed, and finally the first unilateral sub-query 10 is executed.

[0129] Step 206: When a unilateral sub-query is executed, the computer device uses a traditional SQL execution engine to execute the query task.

[0130] When traversing each sub-view in the directed acyclic graph to execute the query task, if the sub-query task to be executed is a unilateral sub-query, a traditional SQL execution engine is used to execute the sub-query task.

[0131] Step 207: When a federated subquery is executed, the computer device uses a federated secure SQL execution engine to execute the query task.

[0132] When the subquery task to be executed is a federated subquery, a federated secure SQL execution engine is used to execute the subquery task.

[0133] Step 208: The computer device determines a query result according to the execution result of the sub-query.

[0134] After traversing all subviews in the directed acyclic graph and obtaining the execution result corresponding to each subview, the query result corresponding to the input SQL query statement can be determined according to the execution result of each subview, and then the query result is output.

[0135] In this way, the information query method provided by the present application obtains a query task; splits the query task to obtain a first number of first sub-query tasks and a second number of second sub-query tasks, the first sub-query task is a query task based on a single database, and the second sub-query task is a query task based on at least two databases; uses a first execution engine to execute the first sub-query task, and uses a second execution engine to execute the second sub-query task, and when the second execution engine executes the second sub-query task, the data between the databases associated with the second sub-query task are isolated; and determines the query result corresponding to the query task according to the execution result of the sub-query task.

[0136] The subquery-based security data analysis method provided in this application automatically splits the input SQL, splits a complete SQL into multiple subqueries, including unilateral subqueries and federated subqueries, and then sends them to the traditional SQL execution engine and the federated security SQL execution engine respectively. SQL can be automatically converted into a subquery DAG, which not only applies the federation capability of the security SQL execution engine, but also reuses the unilateral query capability of the traditional SQL execution engine. The efficiency of information query is improved.

[0137] In this way, the information query method provided by the present application can split the query task into a unilateral sub-query task involving only one database and a multi-party sub-query task involving multiple databases. For the multi-party sub-query task involving multiple databases, a data-isolated secure query execution engine is used for processing, so that there is no need to transfer the data of the multiple databases involved to a closed domain for query, which can greatly improve the efficiency of information query.

[0138] In order to better implement the above method, an embodiment of the present application further provides an information query device, which can be integrated in a terminal or a server.

[0139] For example, Figure 5 As shown, it is a schematic diagram of the structure of the information query device provided in an embodiment of the present application. The information query device may include an acquisition unit 301, a splitting unit 302, an execution unit 303 and a determination unit 304, as follows:

[0140] An acquisition unit 301 is used to acquire a query task;

[0141] A splitting unit 302 is used to split the query task to obtain a first number of first sub-query tasks and a second number of second sub-query tasks, where the first sub-query tasks are query tasks based on a single database, and the second sub-query tasks are query tasks based on at least two databases;

[0142] An execution unit 303 is used to use a first execution engine to execute a first sub-query task, and use a second execution engine to execute a second sub-query task. When the second execution engine executes the second sub-query task, data between databases associated with the second sub-query task are isolated;

[0143] The determining unit 304 is configured to determine the query result corresponding to the query task according to the execution result of the sub-query task.

[0144] In some embodiments, the splitting unit comprises:

[0145] A first acquisition subunit is used to acquire the query data included in the query task;

[0146] The analysis subunit is used to perform semantic analysis on the query data, and split the query task into a first number of first sub-query tasks and a second number of second sub-query tasks according to the semantic analysis result.

[0147] In some embodiments, the analysis subunit comprises:

[0148] A parsing module is used to parse the query data and obtain the syntax tree corresponding to the query data;

[0149] The split module is used to split the syntax tree to obtain multiple sub-query data;

[0150] The detection module is used to detect multiple sub-query data, and when the sub-query data meets the preset classification conditions, a second sub-query task is generated according to the sub-query data; when the sub-query data does not meet the preset classification conditions, a first sub-query task is generated according to the sub-query data.

[0151] In some embodiments, the detection module includes:

[0152] A first generating submodule is used to generate a second subquery task according to the subquery data when there is an operator for cross-database query in the subquery data;

[0153] The second generating submodule is used to generate a first subquery task according to the subquery data when there is no cross-database query operator in the subquery data.

[0154] In some embodiments, the parsing module includes:

[0155] An identification submodule, used to identify query operators and data objects in query data;

[0156] The construction submodule is used to construct a syntax tree with query operators as non-leaf nodes and data objects as leaf nodes.

[0157] In some embodiments, the information query device provided by the present application further includes:

[0158] A second acquisition subunit is used to acquire the logical relationship between the sub-query tasks according to the query data;

[0159] Determines the unit, also used for:

[0160] The query result corresponding to the query task is determined according to the execution result and logical relationship of the sub-query task.

[0161] In some embodiments, the determining unit includes:

[0162] A generation subunit, used to generate a graph network of a subquery task according to a logical relationship;

[0163] The execution subunit is used to execute each sub-query task according to the graph network sequence to obtain the query result corresponding to the query task.

[0164] In some embodiments, generating a subunit comprises:

[0165] The acquisition module is used to obtain the execution order between sub-query tasks from the logical relationship;

[0166] A generation module is used to generate a graph network of subquery tasks with each subquery task as a node and the execution order as an edge.

[0167] In specific implementation, the above units can be implemented as independent entities, or can be arbitrarily combined to be implemented as the same or several entities. The specific implementation of the above units can refer to the previous method embodiments, which will not be repeated here.

[0168] According to the above description, the information query device provided in the embodiment of the present application obtains a query task through the acquisition unit 301; splits the query task to obtain a first number of first sub-query tasks and a second number of second sub-query tasks, the first sub-query task is a query task based on a single database, and the second sub-query task is a query task based on at least two databases; adopts a first execution engine to execute the first sub-query task, and adopts a second execution engine to execute the second sub-query task, when the second execution engine executes the second sub-query task, the data between the databases associated with the second sub-query task are isolated; determines the query result corresponding to the query task according to the execution result of the sub-query task.

[0169] In this way, the information query method provided by the present application can split the query task into a unilateral sub-query task involving only one database and a multi-party sub-query task involving multiple databases. For the multi-party sub-query task involving multiple databases, a data-isolated secure query execution engine is used for processing, so that there is no need to transfer the data of the multiple databases involved to a closed domain for query, which can greatly improve the efficiency of information query.

[0170] The present application also provides a computer device, which may be a terminal or a server. Figure 6 The figure is a schematic diagram of the structure of the computer device provided by this application. Specifically:

[0171] The computer device may include components such as a processing unit 401 of one or more processing cores, a storage unit 402 of one or more storage media, a power module 403 and an input module 404. Figure 6 The computer device structure shown in the figure does not constitute a limitation on the computer device, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently. Among them:

[0172] The processing unit 401 is the control center of the computer device. It uses various interfaces and lines to connect various parts of the entire computer device. It executes various functions of the computer device and processes data by running or executing software programs and / or modules stored in the storage unit 402, and calling data stored in the storage unit 402. Optionally, the processing unit 401 may include one or more processing cores; preferably, the processing unit 401 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface and application programs, etc., and the modem processor mainly processes wireless communications. It is understandable that the above-mentioned modem processor may not be integrated into the processing unit 401.

[0173] The storage unit 402 can be used to store software programs and modules. The processing unit 401 executes various functional applications and data processing by running the software programs and modules stored in the storage unit 402. The storage unit 402 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, and web page access, etc.); the data storage area may store data created according to the use of the computer device, etc. In addition, the storage unit 402 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices. Accordingly, the storage unit 402 may also include a memory controller to provide the processing unit 401 with access to the storage unit 402.

[0174] The computer device also includes a power module 403 for supplying power to each component. Preferably, the power module 403 can be logically connected to the processing unit 401 through a power management system, so as to achieve functions such as management of charging, discharging, and power consumption management through the power management system. The power module 403 can also include any components such as one or more DC or AC power supplies, recharging systems, power failure detection circuits, power converters or inverters, and power status indicators.

[0175] The computer device may further include an input module 404, which may be used to receive input digital or character information and generate keyboard, mouse, joystick, optical or trackball signal input related to user settings and function control.

[0176] Although not shown, the computer device may further include a display unit, etc., which will not be described in detail herein. Specifically, in this embodiment, the processing unit 401 in the computer device will load the executable files corresponding to the processes of one or more application programs into the storage unit 402 according to the following instructions, and the processing unit 401 will run the application programs stored in the storage unit 402, thereby realizing various functions, as follows:

[0177] Acquire a query task; split the query task to obtain a first number of first sub-query tasks and a second number of second sub-query tasks, wherein the first sub-query task is a query task based on a single database, and the second sub-query task is a query task based on at least two databases; use a first execution engine to execute the first sub-query task, and use a second execution engine to execute the second sub-query task, and when the second execution engine executes the second sub-query task, the data between the databases associated with the second sub-query task are isolated; determine the query result corresponding to the query task according to the execution result of the sub-query task.

[0178] It should be noted that the computer device provided in the embodiment of the present application and the method in the above embodiment belong to the same concept, and the specific implementation of the above operations can be referred to the previous embodiment, which will not be repeated here.

[0179] All or part of the steps in the various methods of the above embodiments may be completed by instructions, or by controlling related hardware through instructions. The instructions may be stored in a computer-readable storage medium and loaded and executed by a processor.

[0180] To this end, an embodiment of the present invention provides a computer-readable storage medium, in which a plurality of instructions are stored, and the instructions can be loaded by a processor to execute the steps in any method provided in the embodiment of the present invention. For example, the instructions can execute the following steps:

[0181] Acquire a query task; split the query task to obtain a first number of first sub-query tasks and a second number of second sub-query tasks, wherein the first sub-query task is a query task based on a single database, and the second sub-query task is a query task based on at least two databases; use a first execution engine to execute the first sub-query task, and use a second execution engine to execute the second sub-query task, and when the second execution engine executes the second sub-query task, the data between the databases associated with the second sub-query task are isolated; determine the query result corresponding to the query task according to the execution result of the sub-query task.

[0182] The specific implementation of the above operations can be found in the previous embodiments, which will not be described in detail here.

[0183] The computer-readable storage medium may include: a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.

[0184] Since the instructions stored in the computer-readable storage medium can execute the steps in any method provided in the embodiments of the present invention, the beneficial effects that can be achieved by any method provided in the embodiments of the present invention can be achieved. Please refer to the previous embodiments for details and will not be repeated here.

[0185] According to one aspect of the present application, a computer program product or a computer program is provided, the computer program product or the computer program includes computer instructions, and the computer instructions are stored in a storage medium. A processor of a computer device reads the computer instructions from the storage medium, and the processor executes the computer instructions, so that the computer device executes the method provided in various optional implementations of the above-mentioned information query method.

[0186] The information query method, device, computer equipment and computer-readable storage medium provided in the embodiments of the present invention are introduced in detail above. Specific examples are used in this article to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea; at the same time, according to the idea of ​​the present invention, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present invention.

Claims

1. An information query method, characterized in that: The method comprises: Get query tasks; Splitting the query task to obtain a first number of first sub-query tasks and a second number of second sub-query tasks, wherein the first sub-query tasks are query tasks based on a single database, and the second sub-query tasks are query tasks based on at least two databases; A first execution engine is used to execute the first sub-query task, and a second execution engine is used to execute the second sub-query task. When the second execution engine executes the second sub-query task, data between databases associated with the second sub-query task are isolated; Determine the query result corresponding to the query task according to the execution result of the sub-query task; The step of splitting the query task to obtain a first number of first sub-query tasks and a second number of second sub-query tasks includes: Acquire the query data included in the query task; Parsing the query data to obtain a syntax tree corresponding to the query data; Splitting the syntax tree to obtain multiple sub-query data; The plurality of sub-query data are detected, and when the sub-query data meets a preset classification condition, a second sub-query task is generated according to the sub-query data; when the sub-query data does not meet the preset classification condition, a first sub-query task is generated according to the sub-query data.

2. The method according to claim 1, characterized in that The detecting of the plurality of sub-query data, when the sub-query data meets the preset classification condition, generating a second sub-query task according to the sub-query data, and when the sub-query data does not meet the preset classification condition, generating a first sub-query task according to the sub-query data, comprises: When there is a cross-database query operator in the sub-query data, a second sub-query task is generated according to the sub-query data; When there is no cross-database query operator in the sub-query data, a first sub-query task is generated according to the sub-query data.

3. The method according to claim 2, characterized in that The parsing the query data to obtain a syntax tree corresponding to the query data includes: Identifying query operators and data objects in the query data; A syntax tree is constructed with the query operator as a non-leaf node and the data object as a leaf node.

4. The method according to claim 1, characterized in that The method further comprises: Acquire the logical relationship between sub-query tasks according to the query data; The determining the query result corresponding to the query task according to the execution result of the sub-query task includes: The query result corresponding to the query task is determined according to the execution result of the sub-query task and the logical relationship.

5. The method according to claim 4, characterized in that The determining the query result corresponding to the query task according to the execution result of the sub-query task and the logical relationship includes: Generate a graph network of subquery tasks according to the logical relationship; Execute each sub-query task sequentially according to the graph network to obtain the query result corresponding to the query task.

6. The method according to claim 5, characterized in that The step of generating a graph network of a subquery task according to the logical relationship includes: Obtaining the execution order between the sub-query tasks from the logical relationship; A graph network of the sub-query tasks is generated with each sub-query task as a node and the execution order as an edge.

7. An information query device, characterized in that: The device comprises: An acquisition unit, used for acquiring query tasks; a splitting unit, configured to split the query task to obtain a first number of first sub-query tasks and a second number of second sub-query tasks, wherein the first sub-query tasks are query tasks based on a single database, and the second sub-query tasks are query tasks based on at least two databases; an execution unit, configured to use a first execution engine to execute the first sub-query task, and use a second execution engine to execute the second sub-query task, wherein when the second execution engine executes the second sub-query task, data between databases associated with the second sub-query task are isolated; A determination unit, configured to determine a query result corresponding to the query task according to an execution result of the sub-query task; The splitting unit includes a first acquisition subunit, which is used to acquire the query data included in the query task; The analysis subunit is used to parse the query data to obtain a syntax tree corresponding to the query data; split the syntax tree to obtain multiple sub-query data; and detect the multiple sub-query data. When the sub-query data meets the preset classification conditions, a second sub-query task is generated according to the sub-query data; when the sub-query data does not meet the preset classification conditions, a first sub-query task is generated according to the sub-query data.

8. The device according to claim 7, characterized in that The analysis subunit is used to generate a second subquery task according to the subquery data when there is a cross-database query operator in the subquery data; or to generate a first subquery task according to the subquery data when there is no cross-database query operator in the subquery data.

9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a plurality of instructions, and the instructions are suitable for being loaded by a processor to execute the steps in the information query method according to any one of claims 1 to 6.

10. A computer device, characterized in that: The method comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the information query method according to any one of claims 1 to 6 when executing the computer program.

11. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instructions are executed by a processor, the steps of the information query method according to any one of claims 1 to 6 are implemented.