Data query method and apparatus

CN116483867BActive Publication Date: 2026-09-08ANT BLOCKCHAIN TECHNOLOGY (SHANGHAI) CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202310391361.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-04-11
Publication Date
2026-09-08
Estimated Expiration
2043-04-11

AI Technical Summary

Benefits of technology

[0009]In the scheme provided in the embodiments of this specification, multiple data tables serving as data sources all provide data query services with query restrictions, such as supporting read methods that use certain fields of the corresponding data tables for filtering queries. In this scheme, the multiple data tables to be queried, the filtering conditions for the data tables, and the association conditions between the data tables can be parsed from the target query statement to be executed. A first relationship graph is generated based on the parsing results. The first relationship graph includes nodes corresponding to each of the multiple data tables and target connection edges between nodes representing the association conditions. Each node includes the read methods supported by its corresponding data table, and the nodes corresponding to the data tables with associated filtering conditions also include the filtering conditions. Then, nodes whose included filtering conditions satisfy the included read methods can be selected from the first relationship graph as first target nodes. The first query dependency relationship between the first target node and its first neighbor nodes connected by target connection edges is analyzed. Based on the first query dependency relationship, a logical execution plan for the target query statement is generated for the joint query of the multiple data tables. Therefore, it is possible to perform query analysis on multi-table join queries in scenarios where data source queries are limited, and automatically generate feasible logical execution plans based on the reading methods supported by the multi-tables, the filtering conditions for the tables in the multi-tables, and the association conditions between the multi-tables, which can avoid the error risks caused by manually designing logical execution plans.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116483867B_ABST
    Figure CN116483867B_ABST
Patent Text Reader

Abstract

Embodiments of the present specification provide a data query method and device, the method comprising: parsing, from a target query statement to be executed, a plurality of data tables to be queried, filter conditions of data tables in the plurality of data tables, and association conditions between the data tables; generating a first relationship graph based on the parsing result, wherein the first relationship graph comprises nodes corresponding to the plurality of data tables respectively, and target connection edges between the nodes for representing the association conditions, the nodes comprising reading methods supported by the data tables corresponding to the nodes, and the nodes corresponding to the data tables associated with the filter conditions further comprising the filter conditions; selecting, from the first relationship graph, nodes comprising filter conditions satisfying reading methods as first target nodes, and analyzing first query dependency relationships between the first target nodes and first neighbor nodes connected to the first target nodes through target connection edges; and generating a logical execution plan of the target query statement based on the first query dependency relationships, for joint query of the plurality of data tables.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments in this specification belong to the field of computer technology, and in particular relate to data query methods and apparatus. Background Technology

[0002] In multi-table join queries under data source constraints, there may be dependencies between the queries on each table. For example, data retrieved from table A may be used as input parameters for filtering conditions in table B. When multiple tables in a join query have dependencies, the order of the queries becomes particularly important. Summary of the Invention

[0003] The purpose of this invention is to provide a data query solution that can perform query analysis on multi-table joint queries in scenarios where data source queries are limited, and automatically generate a feasible logical execution plan based on the reading methods supported by the multi-table, the filtering conditions for the tables in the multi-table, and the association conditions between the multi-table, thereby avoiding the error risks caused by manually designing logical execution plans.

[0004] This specification provides a data query method, comprising: obtaining a target query statement to be executed, wherein the target query statement specifies multiple data tables and includes query conditions; wherein each of the multiple data tables supports a reading method, and the reading method uses a portion of the corresponding data table for filtering query; parsing the multiple data tables to be queried, the filtering conditions for the data tables in the multiple data tables, and the association conditions between the data tables from the target query statement; generating a first relationship graph based on the parsing results, wherein the first relationship graph includes nodes corresponding to the multiple data tables respectively, and target connection edges between the nodes used to represent the association conditions, wherein any node includes the reading method supported by its corresponding data table, and the node corresponding to the data table associated with the filtering condition also includes the filtering condition; selecting nodes in the first relationship graph whose included filtering conditions satisfy the included reading methods as first target nodes, and analyzing a first query dependency relationship between the first target node and its first neighbor nodes connected by target connection edges; and generating a logical execution plan for the target query statement based on the first query dependency relationship for joint querying of the multiple data tables.

[0005] A second aspect of this specification provides a data query apparatus, comprising: an acquisition unit configured to acquire a target query statement to be executed, the target query statement specifying multiple data tables and including query conditions; wherein each of the multiple data tables supports a reading method, the reading method using partial fields of the corresponding data tables for filtering and querying; a parsing unit configured to parse from the target query statement the multiple data tables to be queried, the filtering conditions for the data tables in the multiple data tables, and the association conditions between the data tables; and a first generation unit configured to generate a first relationship graph based on the parsing results, the first relationship graph including the multiple data tables respectively. The first relational graph includes corresponding nodes and target connection edges between nodes to represent association conditions. Each node includes the reading methods supported by its corresponding data table, and the nodes corresponding to the data tables with association filtering conditions also include the filtering conditions. The analysis unit is configured to select nodes from the first relational graph that satisfy the included reading methods as first target nodes, and analyze the first query dependency relationship between the first target node and its first neighbor nodes connected by target connection edges. The second generation unit is configured to generate a logical execution plan for the target query statement based on the first query dependency relationship, for use in the joint query of the multiple data tables.

[0006] A third aspect of this specification provides a computer-readable storage medium having a computer program stored thereon, which, when executed in a computer, causes the computer to perform the method described in any implementation of the first aspect.

[0007] A fourth aspect of this specification provides a computing device including a memory and a processor, wherein the memory stores executable code, and the processor, when executing the executable code, implements a method as described in any implementation of the first aspect.

[0008] The fifth aspect of this specification provides a computer program that, when executed in a computer, causes the computer to perform the method described in any implementation of the first aspect.

[0009] In the scheme provided in the embodiments of this specification, multiple data tables serving as data sources all provide data query services with query restrictions, such as supporting read methods that use certain fields of the corresponding data tables for filtering queries. In this scheme, the multiple data tables to be queried, the filtering conditions for the data tables, and the association conditions between the data tables can be parsed from the target query statement to be executed. A first relationship graph is generated based on the parsing results. The first relationship graph includes nodes corresponding to each of the multiple data tables and target connection edges between nodes representing the association conditions. Each node includes the read methods supported by its corresponding data table, and the nodes corresponding to the data tables with associated filtering conditions also include the filtering conditions. Then, nodes whose included filtering conditions satisfy the included read methods can be selected from the first relationship graph as first target nodes. The first query dependency relationship between the first target node and its first neighbor nodes connected by target connection edges is analyzed. Based on the first query dependency relationship, a logical execution plan for the target query statement is generated for the joint query of the multiple data tables. Therefore, it is possible to perform query analysis on multi-table join queries in scenarios where data source queries are limited, and automatically generate feasible logical execution plans based on the reading methods supported by the multi-tables, the filtering conditions for the tables in the multi-tables, and the association conditions between the multi-tables, which can avoid the error risks caused by manually designing logical execution plans. Attached Figure Description

[0010] To more clearly illustrate the technical solutions of the embodiments in this specification, the drawings used in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in this specification. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0011] Figure 1 This is a schematic diagram illustrating one application scenario in which the embodiments of this specification can be applied;

[0012] Figure 2 This is a schematic diagram of the logic execution plan generation process;

[0013] Figure 3 This is a flowchart of the data query method in the embodiments of this specification;

[0014] Figure 4 This is a schematic diagram of the generation process of relation graph G1;

[0015] Figure 5 This is a schematic diagram of the logic execution plan generation process;

[0016] Figure 6 This is a schematic diagram of the logic execution plan generation process;

[0017] Figure 7 This is a schematic diagram of the update process of relation graph G1;

[0018] Figure 8 This is a schematic diagram of subtree SubTree1;

[0019] Figure 9 This is a schematic diagram of the updated relational graph G1;

[0020] Figure 10 This is a schematic diagram of the updated relational graph G1;

[0021] Figure 11 This is a schematic diagram of the data query device in the embodiments of this specification. Detailed Implementation

[0022] To enable those skilled in the art to better understand the technical solutions in this specification, the technical solutions in the embodiments of this specification will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this specification, and not all embodiments. Based on the embodiments in this specification, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of this specification.

[0023] As mentioned earlier, in multi-table join queries under scenarios where data source queries are limited, there may be dependencies between the queries on each table. For example, data retrieved from table A may be used as input parameters for filtering conditions in table B. When multiple tables in a join query have dependencies, the order of the queries becomes particularly important.

[0024] Currently, in scenarios where data source queries are limited, developers typically pre-design logical execution plans for multi-table joins. An execution plan can be understood as a sequence of database operation instructions required to perform a data query. A logical execution plan, composed of logical operations, primarily describes the actions to be taken to achieve the data query. For complex query scenarios, this approach can lead to more tedious development work and carries a certain risk of errors.

[0025] To avoid the risk of errors caused by manually designing logic execution plans, this specification provides a data query scheme that can perform query analysis on multi-table joint queries in scenarios where data source queries are limited, and automatically generate feasible logic execution plans based on the reading methods supported by the multi-tables, the filtering conditions for the tables in the multi-tables, and the association conditions between the multi-tables.

[0026] Figure 1This is a schematic diagram illustrating one application scenario to which the embodiments of this specification can be applied. Figure 1 The application scenario shown may include user device 101 used by user A, database server 102, and data tables table1, table2, and table3 included in database server 102. Each of table1, table2, and table3 includes multiple fields. For example... Figure 1 As shown, table1 can include fields col1_1, col1_2, and col1_3; table2 can include fields col2_1, col2_2, and col2_3; and table3 can include fields col3_1, col3_2, col3_3, and col3_4. It should be noted that... Figure 1 The "##" shown can represent field values.

[0027] In addition, tables1, 2, and 3 all support a read method that uses a subset of fields from their respective tables for filtering and querying. For example... Figure 1 As shown, table1 supports the read method `read_method1(col1_1)`, which uses the `col1_1` field for filtering queries. The query result is equivalent to the SQL statement `select * from table1 where col1_1 = ?`. Table2 supports the read method `read_method2(col2_2)`, which uses the `col2_2` field for filtering queries. The query result is equivalent to the SQL statement `select * from table2 where col2_2 = ?`. Table3 supports the read method `read_method3(col3_3, col3_4)`, which uses both `col3_3` and `col3_4` fields for multi-column filtering queries. The query result is equivalent to the SQL statement `select * from table3 where col3_3 = ? and col3_4 = ?`. It should be noted that the "?" in the SQL statement can be considered a parameter placeholder; the position of this placeholder is used to place the actual field value.

[0028] When user A wants to perform a join query on tables1, 2, and 3, they can submit a target query statement for this join query to database server 102 through user device 101. The target query statement can be an SQL statement, such as the following:

[0029] select table1.*

[0030] from table1, table2, table3

[0031] where table1.col1_1=table2.col2_1

[0032] and table2.col2_2=table3.col3_2

[0033] and table1.col1_1 = 'ee'

[0034] and table3.col3_3 = 123

[0035] and table3.col3_4 = 'ABC'.

[0036] Database server 102 can parse the target query statement to obtain the data tables table1, table2, and table3 to be queried, the filter condition for table1 table1.col1_1 = 'ee', the filter condition for table3 table3.col3_3 = 123 and table3.col3_4 = 'ABC', the join condition between table1 and table2 table1.col1_1 = table2.col2_1, and the join condition between table2 and table3 table2.col2_2 = table3.col3_2. Then, based on the parsing results, database server 102 can generate... Figure 2 The relationship diagram G1 is shown below. Wherein, Figure 2This is a schematic diagram of the logical execution plan generation process. The relational graph G1 includes nodes corresponding to table1, table2, and table3. The nodes corresponding to table1 and table2 represent the target connection edges representing the association condition table1.col1_1 = table2.col2_1, and the nodes corresponding to table2 and table3 represent the target connection edges representing the association condition table2.col2_2 = table3.col3_2. Each node in relational graph G1 includes the read methods supported by the corresponding data table, such as the method name and the field names used. Furthermore, each node may also include the field names of the fields included in the corresponding data table. Additionally, the nodes corresponding to the data table with the association filter condition also include the filter condition. It should be noted that "fields" in relational graph G1 represents fields, and "filters" in the nodes corresponding to table1 and table3 represent filter conditions. Next, the database server 102 can perform query dependency analysis on the nodes in relational graph G1 and generate a logical execution plan for the target query statement based on the analyzed query dependencies for use in the joint query of table1, table2, and table3.

[0037] The data query scheme provided in the embodiments of this specification will be described below with reference to specific examples.

[0038] See Figure 3 This is a flowchart of the data query method in the embodiments of this specification. This method can be executed by any device, platform, or device cluster with data storage, computing, and processing capabilities; for example, it can be executed by a database server (such as...). Figure 1 The database server 102 shown, data flow hub platform, privacy collaboration application platform or data matrix service platform, etc. are executed.

[0039] like Figure 3 As shown, firstly, in step S301, the target query statement to be executed is obtained. The target query statement specifies multiple data tables and includes query conditions. Each of the multiple data tables supports a read method, which uses some fields of the corresponding data table for filtering and querying.

[0040] Specifically, it can receive target query statements submitted by users through user devices. The target query statement can include an SQL statement. This SQL statement can include a `from` clause and a `where` clause. The `from` clause specifies the aforementioned multiple data tables, and the `where` clause includes query conditions, including filtering conditions for the data tables and join conditions between the data tables.

[0041] In step S303, the multiple data tables to be queried, the filtering conditions for the data tables, and the association conditions between the data tables are parsed from the target query statement.

[0042] Specifically, when the target query statement is an SQL statement, the FROM clause and WHERE clause of the SQL statement can be parsed to extract the multiple data tables to be queried, the filtering conditions for the data tables, and the association conditions between the data tables.

[0043] In step S305, a relation graph G1 is generated based on the parsing results. The relation graph G1 includes nodes corresponding to the above multiple data tables, and target connection edges between nodes used to represent association conditions. Any node includes the reading method supported by its corresponding data table, and the node corresponding to the data table with association filtering conditions also includes the filtering conditions.

[0044] In one implementation, the nodes corresponding to the multiple data tables in the relational graph G1 can be table scan nodes or query call nodes. Query call nodes include filtering conditions that satisfy the included read methods. Table scan nodes in relational graph G1 do not include filtering conditions, or their included filtering conditions do not satisfy the included read methods. Taking the target query statement for performing a joint query on table1, table2, and table3 as described above as an example, in this implementation, the relational graph G1 generated based on the parsing result of the target query statement can be as follows: Figure 4 As shown in the figure. Among them, Figure 4 This is a schematic diagram illustrating the generation process of relation graph G1. Figure 4 In the relationship diagram G1 shown, the nodes corresponding to tables1 and 3 are both query call nodes, and the node corresponding to table2 is a table scan node. Specifically, the field col1_1 in the filter condition of the query call node QueryCall1 for table1 is a field used by the read_method1 method supported by table1, and this filter condition satisfies this read method. The fields col3_3 and col3_4 in the filter condition of the query call node QueryCall3 for table3 are fields used by the read_method3 method supported by table3, and this filter condition satisfies this read method. The table scan node TableScan2 for table2 does not have any filter conditions.

[0045] It should be noted that identifying whether a node corresponding to a data table is a table scan node or a query call node can help determine whether the query for that node is restricted, such as whether the query for that node depends on other nodes. In practice, query call nodes in graph G1 are generally query-unrestricted nodes, while table scan nodes are generally query-restricted nodes.

[0046] Furthermore, in one example, the relational graph G1 can be generated directly based on the parsing results of the target query statement.

[0047] In another example, a relationship graph G2 can be generated first. G2 includes table scan nodes corresponding to the aforementioned data tables, and target connection edges between nodes representing association conditions. Each table scan node includes the read methods supported by its corresponding data table, and the table scan node corresponding to the data table with the association filter condition also includes the filter condition. Then, for the data table with the association filter condition, in response to the filter condition satisfying the read methods supported by the data table, the table scan node corresponding to that data table can be transformed into a query call node in relationship graph G2. The updated relationship graph G2 can then be used as relationship graph G1. Continuing with the example of the target query statement used to perform a joint query on table1, table2, and table3, as described earlier, we can first generate a query graph G2 based on the parsing results of the target query statement. Figure 4 The relationship graph G2 shown can then be updated to support different read methods based on the filter conditions associated with each of tables 1 and 3. Specifically, the table scan node TableScan1 corresponding to table1 is transformed into a query call node QueryCall1, and the table scan node TableScan3 corresponding to table3 is transformed into a query call node QueryCall3. The updated relationship graph G2 can then be used as relationship graph G1.

[0048] In step S307, select the node that satisfies the filtering conditions and the reading method from the relation graph G1 as the target node T1, and analyze the query dependency relationship R1 between the target node T1 and its neighbor node S1 which is connected by a target connection edge.

[0049] As an example, the query path can be searched in a depth-first manner. Specifically, the target node T1 can be selected from the relational graph G1 if the included filtering conditions satisfy the included reading methods. It should be noted that when the node corresponding to the data table in the relational graph G1 is a table scan node or a query call node, the query call node can be selected from the relational graph G1 as the target node T1.

[0050] After determining the target node T1, we can find the neighboring nodes S1 connected to the target node T1 by a target connection edge in the relation graph G1, and analyze the query dependency relationship R1 between the target node T1 and the neighboring node S1. For example, if the association condition C1 represented by the target connection edge between the target node T1 and the neighboring node S1 satisfies the reading method included in the neighboring node S1, then we can know that the data in the query result of the target node T1 needs to be used as the input parameter of the reading method, and thus we can determine that the query of the neighboring node S1 depends on the target node T1. If the association condition C1 does not satisfy the reading method included in the neighboring node S1, then we can determine that the query of the neighboring node S1 does not depend on the target node T1.

[0051] In step S309, based on the query dependency R1, a logical execution plan for the target query statement is generated for use in the joint query of the above multiple data tables.

[0052] In one implementation, the process of generating the logic execution plan can be as follows: Figure 5 As shown. Among them, Figure 5 This is a schematic diagram of the logic execution plan generation process.

[0053] like Figure 5 As shown, firstly, in step S501, if the query dependency R1 is that the query of the neighbor node S1 depends on the target node T1, then the associated query node of the target node T1 and the neighbor node S1 is generated.

[0054] In step S503, a subtree SubTree1 is generated. Subtree SubTree1 includes an associated query node, a target node T1, a neighbor node S1, a connection edge from the target node T1 to the associated query node, and a connection edge from the neighbor node S1 to the associated query node.

[0055] In step S505, the association condition C1 represented by the target connection edge between the target node T1 and the neighbor node S1 is converted into a filter condition F1 and added to the neighbor node S1 in the subtree SubTree1.

[0056] As an example, the associated query node has a node identifier, and the associated condition C1 includes the field name referenced by the table name N1 of the data table corresponding to the target node T1. The table name N1 in the associated condition C1 can be modified to the node identifier, and the modified associated condition C1 can be used as the filter condition F1.

[0057] In step S507, subtree SubTree2 in relation graph G1 is replaced by subtree SubTree1. Subtree SubTree2 is formed by target node T1 and neighbor node S1 connected to target node T1 by a target connection edge. The association query node is used to replace the neighbor node S1 in subtree SubTree2.

[0058] It should be noted that when a neighbor node S1 has a target connection edge that connects to other nodes, the target connection edge can be connected to the associated query node by having the associated query node replace the neighbor node S1 in the subtree SubTree2.

[0059] In one implementation, if the node corresponding to the data table in the relation graph G1 is a table scan node or a query call node, before executing step S507, the neighbor node S1 in the subtree SubTree1 can also be converted from a table scan node to a query call node.

[0060] In one implementation, before performing step S507, descriptive information for the left and right child nodes can be added to the associated query node. This descriptive information may include the node names or node identifiers of the left and right child nodes.

[0061] In step S509, a logical execution plan for the target query statement is generated based on the updated relational graph G1.

[0062] When the above multiple data tables are actually two data tables, the logical execution plan of the target query statement can be directly generated based on the updated relational graph G1, for example, the updated relational graph G1 can be used as the logical execution plan.

[0063] It should be noted that the neighbor node S1 can be located on a specific side of the subtree SubTree1, such as the right side. In this case, the neighbor node S1 can be the right child of the associated query node, and the target node T1 can be the left child of the associated query node. Based on this, the logical execution plan can describe the query dependencies, where the associated query node can represent a query dependency between the left and right child nodes, and the query of the right child node depends on the query of the left child node.

[0064] In one implementation, when searching the query path in a depth-first manner, before step S509, a connection node may be generated in response to the query dependency R1 being that the query for neighbor node S1 does not depend on the target node T1. This connection node includes the association condition C1 represented by the target connection edge between the target node T1 and the neighbor node S1. Then, this connection node can be added to the relationship graph G1, and the target connection edge between the target node T1 and the neighbor node S1 can be removed from the relationship graph G1. Furthermore, connection edges from the target node T1 to this connection node and from the neighbor node S1 to this connection node can be added. Further, descriptive information for its left and right child nodes can be added to the connection node. This descriptive information may include the node names or node identifiers of the left and right child nodes, etc.

[0065] In one implementation, when the number of the aforementioned multiple data tables is greater than 2, after step S507 and before step S509, query dependency analysis can be performed on the nodes in the relationship graph G1, and the relationship graph G1 can be updated based on the analyzed query dependencies. Thus, in step S509, a logical execution plan can be generated based on the finally updated relationship graph G1, for example, using the finally updated relationship graph G1 as the logical execution plan.

[0066] Specifically, when the number of the aforementioned multiple data tables is greater than 2, in the case of searching the query path in a depth-first manner, in step S309, the following can be executed: Figure 6 The logical execution plan generation process is shown below. Figure 6 This is a schematic diagram of the logic execution plan generation process.

[0067] like Figure 6 As shown, firstly, in step S601, if the query dependency R1 is that the query of the neighbor node S1 depends on the target node T1, then the associated query node of the target node T1 and the neighbor node S1 is generated.

[0068] In step S603, a subtree SubTree1 is generated. Subtree SubTree1 includes an associated query node, a target node T1, a neighbor node S1, a connection edge from the target node T1 to the associated query node, and a connection edge from the neighbor node S1 to the associated query node.

[0069] In step S605, the association condition C1 represented by the target connection edge between the target node T1 and the neighbor node S1 is converted into a filter condition F1 and added to the neighbor node S1 in the subtree SubTree1.

[0070] In step S607, subtree SubTree2 in relation graph G1 is replaced by subtree SubTree1. Subtree SubTree2 is formed by target node T1 and neighbor node S1 connected to target node T1 by a target connection edge. The association query node is used to replace the neighbor node S1 in subtree SubTree2.

[0071] Among them, steps S601-S607 and Figure 5 The corresponding steps S501-S507 in the embodiment are described in detail below.

[0072] In step S609, the associated query node in the relation graph G1 is taken as the target node T2, and the query dependency relationship R2 between the target node T2 and its neighbor node S2 which is connected by a target connection edge is analyzed.

[0073] In step S611, the relation graph G1 is updated based on the query dependency R2.

[0074] Specifically, when the query dependency R2 is such that the query of neighbor node S2 depends on the target node T2, a process similar to steps S601-S607 can be executed. When the query of neighbor node S2 does not depend on the target node T2, the following can be executed: Figure 7 The update process of relation graph G1 is shown. Figure 7 This is a schematic diagram of the update process of relation graph G1.

[0075] like Figure 7 As shown, firstly, in step S701, if the query dependency R2 is that the query of neighbor node S2 does not depend on the target node T2, then a connection node between the target node T2 and the neighbor node S2 is generated. The connection node includes the association condition C2, which is determined based on the association condition represented by the target connection edge between the target node T2 and the neighbor node S2.

[0076] As an example, the association condition represented by the target connection edge between target node T2 and neighbor node S2 includes the field name referenced by the table name N2 of the data table corresponding to neighbor node S1. The table name N2 in this association condition can be modified to the node identifier of the associated query node, and the modified association condition can be used as association condition C2.

[0077] In step S703, the connecting node is added to the relationship graph G1, and the target connecting edge between the target node T2 and the neighbor node S2 is removed from the relationship graph G1. Connecting edges are then added from the target node T1 to the connecting node and from the neighbor node S2 to the connecting node. Furthermore, descriptive information for the left and right child nodes can be added to the connecting node. This descriptive information may include the node names or node identifiers of the left and right child nodes.

[0078] After performing step S611, if the relation graph G1 no longer contains the target connection edge, it indicates that the relation graph G1 has been updated and step S613 can be performed next.

[0079] In step S613, a logical execution plan for the target query statement is generated based on the updated relational graph G1.

[0080] Below, with Figure 4 Using the relationship graph G1 shown as an example, this section describes the process of generating a logical execution plan when searching the query path in a depth-first manner.

[0081] First, we can select the QueryCall3 node from the relationship graph G1 and analyze the query dependency between the QueryCall3 node and the TableScan2 node connected to it by a target connection edge. Since the field col2_2 in the association condition represented by the target connection edge between the QueryCall3 node and the TableScan2 node is a field used by the read_method2 included in the TableScan2 node, we can determine that the association condition satisfies the read method, and thus determine that the query of the TableScan2 node depends on the QueryCall3 node.

[0082] Next, a related query node, Correlate, can be generated between the QueryCall3 node and the TableScan2 node, thus generating a subtree, SubTree1. The node identifier for the Correlate node can be Cor1. SubTree1 includes the Correlate node, the QueryCall3 node, the TableScan2 node, connecting edges from the QueryCall3 node to the Correlate node, and connecting edges from the TableScan2 node to the Correlate node. The QueryCall3 node can be the left child of the Correlate node, and the TableScan2 node can be the right child of the Correlate node.

[0083] Next, the association condition `table2.col2_2 = table3.col3_2` can be transformed into the filter condition `table2.col2_2 = cor1.col3_2`, and this filter condition can be added to the `TableScan2` node in the subtree `SubTree1`. The `TableScan2` node can then be transformed into a `QueryCall2` node. Additionally, descriptions of the left and right child nodes of the `Correlate` node, such as "left: QueryCall3" and "right: QueryCall2", can be added to the `Correlate` node. Here, "left" represents the left child node, and "right" represents the right child node. At this point, the subtree `SubTree1` can be viewed as follows: Figure 8 As shown. Among them, Figure 8 This is a schematic diagram of the subtree SubTree1.

[0084] Next, you can use Figure 8 The subtree SubTree1 shown is replaced Figure 4The subtree SubTree2 in the relationship graph G1 shown is formed by the QueryCall3 node and the TableScan2 node connected to the QueryCall3 node by a target edge. The Correlate node in subtree SubTree1 is used to replace the TableScan2 node in subtree SubTree2. The relationship graph G1 can now be viewed as follows: Figure 9 As shown. Among them, Figure 9 This is a schematic diagram of the updated relational graph G1.

[0085] Next, the Correlate node can be selected from the relation graph G1, and the query dependency between the Correlate node and the QueryCall1 node connected to it by a target connection edge can be analyzed. In one example, since the field col2_1 in the association condition represented by the target connection edge between the Correlate node and QueryCall1 is not a field used by the read_method2 included in the child node QueryCall2 of the Correlate node, it can be determined that the association condition does not satisfy the read method, and thus it can be determined that the query of the QueryCall1 node does not depend on the Correlate node. In another example, the QueryCall1 node can be identified as the query invocation node. Since the filter condition in the query invocation node satisfies the included read method, it can be determined that the query of the QueryCall1 node does not depend on the Correlate node.

[0086] Next, a Join node can be generated connecting the Correlate node and the QueryCall1 node. The Join node can include the association condition table1.col1_1 = cor1.col2_1, which is determined based on the association condition table1.col1_1 = table2.col2_1 represented by the target connection edge between the Correlate node and the QueryCall1 node.

[0087] Next, you can add a Join node to, for example... Figure 9 In the relationship graph G1 shown, the target connection edge between the Correlate node and the QueryCall1 node is removed, and connection edges from the Correlate node to the Join node and from the QueryCall1 node to the Join node are added. Additionally, descriptive information for the left and right child nodes can be added to the Join node, such as "left:QueryCall1" and "right:cor1". The relationship graph G1 can then be viewed as follows: Figure 10 As shown. Among them, Figure 10 This is a schematic diagram of the updated relationship graph G1. Figure 10 In the relationship diagram G1 shown, the “condition” in the Join node represents the association condition.

[0088] Since the nodes corresponding to tables1, table2, and table3 in relation graph G1 have all been analyzed, relation graph G1 no longer contains the target connection edges, and therefore it can be concluded that... Figure 10 The relationship graph G1 shown is the final updated relationship graph, which can then be used as a basis for... Figure 10 The relationship graph G1 shown generates the logical execution plan for the target query statement. For example, the relationship graph G1 can be directly used as the logical execution plan for the target query statement.

[0089] It needs to be explained that, Figure 10 The diagram G1 shown is a tree containing join nodes, related query nodes, and query call nodes. Leaf nodes are query call nodes, and non-leaf nodes are join nodes or related query nodes. The tree describes query dependencies. For non-leaf nodes, if it's a related query node, it means its left and right child nodes have query dependencies, with the right child's query depending on the left child. If it's a join node, it means its left and right child nodes do not have query dependencies, and their queries can be completed independently. The tree also describes the data source query order, reading methods, and query result association methods, representing the logical execution plan of the current target query statement. Nodes in the logical execution plan can represent an operation, such as a data source query operation or a related operation.

[0090] Figure 3 The corresponding implementation provides a data query solution that can perform query analysis on multi-table join queries in scenarios where data source queries are limited. Based on the read methods supported by the multiple tables, the filtering conditions for the tables, and the relationship conditions between the tables, it automatically generates a feasible logical execution plan, avoiding the error risks associated with manually designing the logical execution plan. Furthermore, this solution supports the integrated development of multi-source limited data resources based on standard SQL, improving data development efficiency and avoiding the additional cost of manually designing logical execution plans.

[0091] In one embodiment, after generating the logical execution plan for the target query statement, a joint query can also be performed on the aforementioned multiple data tables based on the logical execution plan.

[0092] In practice, in addition to searching query paths in a depth-first manner, a breadth-first manner can also be used to search query paths.

[0093] After generating the relationship graph G1 by executing step S305, when searching for query paths in a breadth-first manner, nodes in relationship graph G1 that satisfy the included reading methods and whose filtering conditions are met can be placed into the target queue. Next, by executing step S307, the node at the head of the target queue is retrieved as the target node T1, and the query dependency R1 between the target node T1 and its neighboring node S1 connected by a target edge is analyzed. Then, by executing step S309, a logical execution plan for the target query statement is generated based on the query dependency R1 for use in the joint query of the multiple data tables.

[0094] It should be noted that when the query of neighbor node S1 does not depend on the target node T1, the query of neighbor node S1 may depend on other nodes. For example, if neighbor node S1 does not include filtering conditions, or if neighbor node S1 is a table scan node, then it can be known that the query of neighbor node S1 depends on other nodes.

[0095] Based on this, in one implementation, when the query dependency R1 is that the query of neighbor node S1 does not depend on the target node T1, the analysis of the target node T1 can be ended. Then, the node at the head of the target queue is taken out as the target node T4. The query dependency R4 between the target node T4 and its neighbor node S4 which is connected by a target connection edge is analyzed. Based on the query dependency R4, the logical execution plan of the target query statement is generated.

[0096] by Figure 4 Taking the relationship graph G1 shown as an example, the QueryCall1 and QueryCall3 nodes can be placed into the target queue. Assuming the QueryCall1 node is at the head of the queue, the QueryCall1 node at the head of the queue can be retrieved from the target queue, and the query dependency relationship between the QueryCall1 node and the TableScan2 node connected to it by a target connection edge can be analyzed. Since the association condition represented by the target connection edge between the QueryCall1 node and the TableScan2 node does not satisfy the reading method included in the TableScan2 node, it can be determined that the TableScan2 node does not depend on the QueryCall1 node. Therefore, the analysis of the QueryCall1 node can be ended, and then the QueryCall3 node at the head of the target queue can be retrieved from the queue. The query dependency relationship between the QueryCall3 node and the TableScan2 node connected to it by a target connection edge can be analyzed, and based on this query dependency relationship, the logical execution plan of the target query statement can be generated.

[0097] In another implementation, when the query dependency R1 is that the query of neighbor node S1 depends on the target node T1, the following can be executed: Figure 5 The logical execution plan generation process is shown. It should be noted that when the number of the aforementioned multiple data tables is greater than 2, after step S507 and before step S509, the associated query nodes in the relation graph G1 can be placed at the tail of the target queue. Then, the node at the head of the target queue is taken as the target node T3. The query dependency relationship R3 between the target node T3 and its neighbor node S3 connected by a target edge is analyzed, and the relation graph G1 is updated based on the query dependency relationship R3.

[0098] Continue with Figure 4 Taking the relationship graph G1 shown as an example, the QueryCall3 node and the QueryCall1 node can be placed into the target queue. Assuming that the QueryCall3 node is at the head of the queue, the QueryCall3 node at the head of the queue can be retrieved from the target queue. By performing query dependency analysis on the QueryCall3 node and the TableScan2 node connected to it by a target connection edge, it can be analyzed that the TableScan2 node depends on the QueryCall3 node. Then, a processing procedure similar to steps S501-S507 above can be used to generate a result like... Figure 8 The subtree SubTree1 is shown, and subtree SubTree2 in relation graph G1 is replaced with subtree SubTree1 to obtain the following: Figure 9 The updated relational graph G1 is shown below. Next, the Correlate node in relational graph G1 can be placed at the tail of the target queue, and the QueryCall1 node at the head of the target queue can be retrieved. By performing query dependency analysis on the QueryCall1 node and the Correlate node connected to it by a target edge, it can be determined that the query of the Correlate node does not depend on the QueryCall1 node. Then, the analysis of the QueryCall1 node can be ended, and the Correlate node at the head of the target queue can be retrieved. By performing query dependency analysis on the Correlate node and the QueryCall1 node connected to it by a target edge, it can be determined that the query of the QueryCall1 node does not depend on the Correlate node. Since the target queue is empty at this time, a process similar to steps S701-S703 above can be performed to update relational graph G1, resulting in the following... Figure 10 The updated relational graph G1 is shown below. Subsequently, a logical execution plan for the target query statement can be generated based on this relational graph G1, for example, by directly using this relational graph G1 as the logical execution plan for the target query statement.

[0099] In summary, when searching the query path using a breadth-first approach, a queue can be used to store all currently queried nodes. The first node of the queue is analyzed sequentially, and the resulting nodes are then added to the rear of the queue, continuing until the queue is empty, at which point the analysis is complete. This approach can reduce the height of the final generated tree to some extent, optimizing the query process and improving query efficiency.

[0100] Figure 11 This is a schematic diagram of the data query device in the embodiments of this specification. This device can be applied to any device, platform, or device cluster with data storage, computing, and processing capabilities; for example, it can be applied to a database server (such as...). Figure 1 The database server 102 shown is a data flow hub platform, a privacy collaboration application platform, or a data matrix service platform, etc.

[0101] like Figure 11 As shown, the data query device 1100 in this embodiment may include: an acquisition unit 1101, a parsing unit 1102, a first generation unit 1103, an analysis unit 1104, and a second generation unit 1105. The acquisition unit 1101 is configured to acquire a target query statement to be executed, which specifies multiple data tables and includes query conditions; wherein each of the multiple data tables supports a reading method that uses partial fields of the corresponding data tables for filtering and querying; the parsing unit 1102 is configured to parse the multiple data tables to be queried, the filtering conditions for the data tables, and the association conditions between the data tables from the target query statement; the first generation unit 1103 is configured to generate a first relationship graph based on the parsing results, the first relationship graph including nodes corresponding to the multiple data tables, and nodes... The target connection edges used to characterize the association conditions are defined. Each node includes the reading methods supported by its corresponding data table, and the nodes corresponding to the data tables with association filtering conditions also include the filtering conditions. The analysis unit 1104 is configured to select nodes whose included filtering conditions satisfy the included reading methods from the first relation graph as first target nodes, and analyze the first query dependency relationship between the first target node and its first neighbor nodes connected by target connection edges. The second generation unit 1105 is configured to generate a logical execution plan for the target query statement based on the first query dependency relationship for joint querying of the multiple data tables.

[0102] In one embodiment, the above-mentioned device 1100 may further include: a query unit (not shown in the figure), configured to perform a joint query on the above-mentioned multiple data tables based on a logical execution plan.

[0103] In one implementation, the analysis unit 1104 may be further configured to: if the first association condition represented by the target connection edge between the first target node and the first neighbor node satisfies the reading method included in the first neighbor node, then determine that the query of the first neighbor node depends on the first target node; if the first association condition does not satisfy the reading method included in the first neighbor node, then determine that the query of the first neighbor node does not depend on the first target node.

[0104] In one implementation, the second generation unit 1105 may be further configured to: generate an associated query node between the first target node and the first neighbor node if the first query dependency is that the query of the first neighbor node depends on the first target node; generate a first subtree, the first subtree including the associated query node, the first target node, the first neighbor node, a connection edge from the first target node to the associated query node, and a connection edge from the first neighbor node to the associated query node; convert the first association condition represented by the target connection edge between the first target node and the first neighbor node into a first filtering condition and add it to the first neighbor node in the first subtree; replace the second subtree in the first relationship graph with the first subtree, the second subtree being formed by the first target node and the first neighbor node connected to the first target node by a target connection edge, the associated query node being used to replace the first neighbor node in the second subtree; and generate a logical execution plan based on the updated first relationship graph.

[0105] In one implementation, the associated query node has a node identifier, the first association condition includes a field name referenced by the first table name of the data table corresponding to the first target node; and the second generation unit 1105 can be further configured to: modify the first table name in the first association condition to the node identifier, and use the modified first association condition as the first filtering condition.

[0106] In one implementation, the nodes corresponding to the plurality of data tables in the first relational graph are table scan nodes or query call nodes; the query call node includes filtering conditions and the filtering conditions satisfy the included reading methods; the table scan node in the first relational graph does not include filtering conditions, or the filtering conditions it includes do not satisfy the included reading methods.

[0107] In one embodiment, the first generation unit 1103 may be further configured to: generate a second relational graph, the second relational graph including table scan nodes corresponding to the plurality of data tables respectively, and target connection edges between nodes used to characterize association conditions, any table scan node including the reading method supported by its corresponding data table, and the table scan node corresponding to the data table with association filtering conditions also including the filtering conditions; for the data table with association filtering conditions in the plurality of data tables, in response to the filtering conditions satisfying the reading method supported by the data table, the table scan node corresponding to the data table is converted into a query call node in the second relational graph; and the updated second relational graph is used as the first relational graph.

[0108] In one implementation, the analysis unit 1104 may be further configured to: select a query call node from the first relational graph as the first target node; the second generation unit 1105 may be further configured to: convert the first neighbor node in the first subtree from a table scan node into a query call node.

[0109] In one implementation, the analysis unit 1104 may be further configured to: select, in a depth-first manner, nodes from the first relational graph whose included filtering conditions satisfy the included reading methods as first target nodes.

[0110] Furthermore, after replacing the second subtree in the first relation graph with the first subtree, and before generating the logic execution plan based on the updated first relation graph, the analysis unit 1104 can also be configured to: take the associated query node in the first relation graph as the second target node, and analyze the second query dependency relationship between the second target node and the second neighbor node connected to it by the target connection edge; the second generation unit 1105 can also be configured to: update the first relation graph based on the second query dependency relationship.

[0111] Furthermore, the second generation unit 1105 can be further configured to: if the second query dependency is that the query of the second neighbor node does not depend on the second target node, generate a connection node between the second target node and the second neighbor node, the connection node including a second association condition, the second association condition being determined based on the association condition represented by the target connection edge between the second target node and the second neighbor node; add the connection node to the first relationship graph, remove the target connection edge between the second target node and the second neighbor node from the first relationship graph, and add connection edges from the second target node to the connection node and from the second neighbor node to the connection node.

[0112] In one implementation, the analysis unit 1104 may be further configured to: place each node in the first relational graph that satisfies the filtering conditions of the included reading method into a target queue; and take the node at the head of the target queue as the first target node.

[0113] Furthermore, after replacing the second subtree in the first relation graph with the first subtree, and before generating the logic execution plan based on the updated first relation graph, the analysis unit 1104 can also be configured to: place the associated query node at the tail of the target queue; take the node at the head of the target queue as the third target node, and analyze the third query dependency relationship between the third target node and the third neighbor node connected to it by the target connection edge; the second generation unit 1105 can also be configured to: update the first relation graph based on the third query dependency relationship.

[0114] In one implementation, the analysis unit 1104 may also be configured to: if the first query dependency is that the query of the first neighbor node does not depend on the first target node, then take the node at the head of the target queue as the fourth target node, and analyze the fourth query dependency between the fourth target node and the fourth neighbor node connected to it by a target connection edge; the second generation unit 1105 may also be configured to: generate a logical execution plan for the target query statement based on the fourth query dependency.

[0115] exist Figure 11 For further explanation of each unit in the corresponding device embodiment, please refer to the relevant descriptions in the previous method embodiments, which will not be repeated here.

[0116] This specification also provides a computer-readable storage medium storing a computer program thereon, wherein when the computer program is executed in a computer, it causes the computer to perform the data query method described in the above method embodiments.

[0117] This specification also provides a computing device, including a memory and a processor, wherein the memory stores executable code, and when the processor executes the executable code, it implements the data query method described in the above method embodiments.

[0118] This specification also provides a computer program in its embodiments, wherein when the computer program is executed in a computer, it causes the computer to perform the data query method described in the above method embodiments.

[0119] In the 1990s, improvements to a technology could be clearly distinguished as either hardware improvements (e.g., improvements to the circuit structure of diodes, transistors, switches, etc.) or software improvements (improvements to the methodology). However, with technological advancements, many methodological improvements today can be considered direct improvements to the hardware circuit structure. Designers almost always obtain the corresponding hardware circuit structure by programming the improved methodology into the hardware circuit. Therefore, it cannot be said that a methodological improvement cannot be implemented using hardware physical modules. For example, a Programmable Logic Device (PLD) (such as a Field Programmable Gate Array (FPGA)) is such an integrated circuit whose logic function is determined by the user programming the device. Designers can program and "integrate" a digital system onto a PLD themselves, without needing chip manufacturers to design and manufacture dedicated integrated circuit chips. Furthermore, nowadays, instead of manually manufacturing integrated circuit chips, this programming is mostly implemented using "logic compiler" software. Similar to the software compiler used in program development, the original code before compilation must be written in a specific programming language, called a Hardware Description Language (HDL). There are many HDLs, such as ABEL (Advanced Boolean Expression Language), AHDL (Altera Hardware Description Language), Confluence, CUPL (Cornell University Programming Language), HDCal, JHDL (Java Hardware Description Language), Lava, Lola, MyHDL, PALASM, and RHDL (Ruby Hardware Description Language). Currently, the most commonly used are VHDL (Very-High-Speed ​​Integrated Circuit Hardware Description Language) and Verilog. Those skilled in the art should understand that by simply performing some logic programming on the method flow using one of these hardware description languages ​​and programming it into an integrated circuit, the hardware circuit implementing the logical method flow can be easily obtained.

[0120] The controller can be implemented in any suitable manner. For example, it can take the form of a microprocessor or processor and a computer-readable medium storing computer-readable program code (e.g., software or firmware) executable by the (micro)processor, logic gates, switches, application-specific integrated circuits (ASICs), programmable logic controllers, and embedded microcontrollers. Examples of controllers include, but are not limited to, the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20, and Silicon Labs C8051F320. A memory controller can also be implemented as part of the control logic of the memory. Those skilled in the art will also recognize that, in addition to implementing the controller in purely computer-readable program code form, the same functionality can be achieved by logically programming the method steps to make the controller take the form of logic gates, switches, application-specific integrated circuits, programmable logic controllers, and embedded microcontrollers. Therefore, such a controller can be considered a hardware component, and the means included therein for implementing various functions can also be considered as structures within the hardware component. Alternatively, the means for implementing various functions can be considered as both software modules implementing the method and structures within the hardware component.

[0121] The systems, devices, modules, or units described in the above embodiments can be implemented by computer chips or physical entities, or by products with certain functions. A typical implementation device is a server system. Of course, this application does not exclude the possibility that, with the future development of computer technology, the computer implementing the functions of the above embodiments can be, for example, a personal computer, a laptop computer, an in-vehicle human-machine interaction device, a cellular phone, a camera phone, a smartphone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or any combination of these devices.

[0122] While one or more embodiments of this specification provide the operational steps of the methods described in the embodiments or flowcharts, more or fewer operational steps may be included based on conventional or non-inventive means. The order of steps listed in the embodiments is merely one possible order of execution among many steps and does not represent the only possible order. In actual device or end product execution, the methods shown in the embodiments or drawings may be executed sequentially or in parallel (e.g., in a parallel processor or multi-threaded processing environment, or even a distributed data processing environment). The terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, product, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, product, or apparatus. Without further limitations, the presence of other identical or equivalent elements in the process, method, product, or apparatus that includes the elements is not excluded. For example, the use of terms such as "first," "second," etc., is to denote names and does not indicate any particular order.

[0123] For ease of description, the above devices are described in terms of function, divided into various modules. Of course, when implementing one or more of these specifications, the functions of each module can be implemented in one or more software and / or hardware components, or a module that performs the same function can be implemented by a combination of multiple sub-modules or sub-units. The device embodiments described above are merely illustrative. For example, the division of units is only a logical functional division; in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces, indirect coupling or communication connection between devices or units, and may be electrical, mechanical, or other forms.

[0124] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0125] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0126] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0127] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.

[0128] Memory may include non-persistent storage in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.

[0129] Computer-readable media includes both permanent and non-permanent, removable and non-removable media that can store information by any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic disk storage, graphene storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.

[0130] Those skilled in the art will understand that one or more embodiments of this specification can be provided as a method, system, or computer program product. Therefore, one or more embodiments of this specification may take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, one or more embodiments of this specification may take the form of a computer program product implemented on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0131] One or more embodiments of this specification can be described in the general context of computer-executable instructions, such as program modules, that are executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, etc., that perform a particular task or implement a particular abstract data type. One or more embodiments of this specification can also be practiced in distributed computing environments where tasks are performed by remote processing devices connected via a communication network. In distributed computing environments, program modules can reside in local and remote computer storage media, including storage devices.

[0132] The various embodiments in this specification are described in a progressive manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, system embodiments are basically similar to method embodiments, so the description is relatively simple; relevant parts can be referred to the descriptions in the method embodiments. In the description of this specification, the terms "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., refer to specific features, structures, materials, or characteristics described in connection with that embodiment or example, which are included in at least one embodiment or example of this specification. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described can be combined in any suitable manner in one or more embodiments or examples. Moreover, without contradiction, those skilled in the art can combine and integrate the different embodiments or examples described in this specification and the features of different embodiments or examples.

[0133] The above description is merely an embodiment of one or more embodiments of this specification and is not intended to limit the scope of these embodiments. Various modifications and variations can be made to these embodiments by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this specification should be included within the scope of the claims.

Claims

1. A data query method, comprising: Obtain the target query statement to be executed, wherein the target query statement specifies multiple data tables and includes query conditions; wherein, each of the multiple data tables supports a read method, and the read method uses a portion of the corresponding data table for filtering and querying; Parse the target query statement to extract the multiple data tables to be queried, the filtering conditions for the data tables, and the association conditions between the data tables; A first relational graph is generated based on the parsing results. The first relational graph includes nodes corresponding to the multiple data tables and target connection edges between nodes used to represent association conditions. Any node includes the reading method supported by its corresponding data table, and the node corresponding to the data table with the association filtering condition also includes the filtering condition. Nodes whose filtering conditions satisfy the included reading methods are selected as first target nodes from the first relationship graph. The first query dependency relationship between the first target node and its first neighboring nodes connected by a target connection edge is analyzed, including: if the first association condition represented by the target connection edge between the first target node and the first neighboring node satisfies the reading methods included in the first neighboring node, then it is determined that the query of the first neighboring node depends on the first target node; if the first association condition does not satisfy the reading methods included in the first neighboring node, then it is determined that the query of the first neighboring node does not depend on the first target node. Based on the first query dependency, a logical execution plan for generating the target query statement is generated, including: if the first query dependency is that the query of the first neighbor node depends on the first target node, then generating an associated query node between the first target node and the first neighbor node; generating a first subtree, the first subtree including the associated query node, the first target node, the first neighbor node, a connection edge from the first target node to the associated query node, and a connection edge from the first neighbor node to the associated query node; converting the first association condition represented by the target connection edge between the first target node and the first neighbor node into a first filtering condition and adding it to the first neighbor node in the first subtree; replacing the second subtree in the first relationship graph with the first subtree, the second subtree being formed by the first target node and the first neighbor node connected to the first target node by a target connection edge, the associated query node being used to replace the first neighbor node in the second subtree; The logical execution plan is generated based on the updated first relationship graph for joint queries of the multiple data tables.

2. The data query method according to claim 1 further includes: Based on the logical execution plan, a joint query is performed on the multiple data tables.

3. The data query method according to claim 1, wherein, The associated query node has a node identifier, and the first association condition includes the field name referenced by the first table name of the data table corresponding to the first target node; as well as The step of converting the first association condition represented by the target connection edge between the first target node and the first neighbor node into a first filtering condition includes: The first table name in the first association condition is modified to the node identifier, and the modified first association condition is used as the first filtering condition.

4. The data query method according to claim 1, wherein, The nodes corresponding to the multiple data tables in the first relationship diagram are either table scan nodes or query call nodes; the query call node includes filtering conditions and the filtering conditions satisfy the included reading methods; the table scan node in the first relationship diagram does not include filtering conditions, or the filtering conditions it includes do not satisfy the included reading methods.

5. The data query method according to claim 4, wherein, The generation of the first relationship graph based on the parsing results includes: Generate a second relation graph, which includes table scan nodes corresponding to the plurality of data tables, and target connection edges between nodes used to characterize association conditions. Any table scan node includes the reading method supported by its corresponding data table, and the table scan node corresponding to the data table with association filtering conditions also includes the filtering conditions. For a data table with associated filtering conditions among the multiple data tables, in response to the filtering conditions satisfying the read methods supported by the data table, the table scan node corresponding to the data table is transformed into a query call node in the second relationship graph; The updated second relationship graph is used as the first relationship graph.

6. The data query method according to claim 4, wherein, The step of selecting nodes from the first relationship graph that satisfy the included filtering conditions and the included reading methods as the first target nodes includes: Select the query call node as the first target node from the first relationship graph; and Before replacing the second subtree in the first relationship graph with the first subtree, the method further includes: Transform the first neighbor node in the first subtree from a table scan node into a query call node.

7. The data query method according to claim 1, wherein, The step of selecting nodes from the first relationship graph that satisfy the included filtering conditions and the included reading methods as the first target nodes includes: Using a depth-first approach, nodes that satisfy the included reading methods and are included in the filtering conditions are selected from the first relationship graph as the first target nodes.

8. The data query method according to claim 7, wherein, After replacing the second subtree in the first relationship graph with the first subtree, and before generating the logical execution plan based on the updated first relationship graph, the method further includes: Taking the associated query node in the first relationship graph as the second target node, analyze the second query dependency relationship between the second target node and the second neighbor node connected to it by a target connection edge; Based on the second query dependency, the first relationship graph is updated.

9. The data query method according to claim 8, wherein, The step of updating the first relationship graph based on the second query dependency includes: If the second query dependency is that the query of the second neighbor node does not depend on the second target node, then a connection node between the second target node and the second neighbor node is generated. The connection node includes a second association condition, which is determined based on the association condition represented by the target connection edge between the second target node and the second neighbor node. Add the connecting node to the first relationship graph, remove the target connecting edge between the second target node and the second neighbor node from the first relationship graph, and add connecting edges from the second target node to the connecting node and from the second neighbor node to the connecting node.

10. The data query method according to claim 1, further comprising: Each node in the first relationship graph that satisfies the filtering conditions of the included reading methods is placed into the target queue. as well as The step of selecting nodes from the first relationship graph that satisfy the included filtering conditions and the included reading methods as the first target nodes includes: The node at the head of the target queue is taken as the first target node.

11. The data query method according to claim 10, wherein, After replacing the second subtree in the first relationship graph with the first subtree, and before generating the logical execution plan based on the updated first relationship graph, the method further includes: Place the associated query node at the tail of the target queue; Take the node at the head of the target queue as the third target node, and analyze the third query dependency relationship between the third target node and the third neighbor node connected to it by the target connection edge; The first relationship graph is updated based on the third query dependency.

12. The data query method according to claim 10, wherein, The step of generating the logical execution plan for the target query statement based on the first query dependency relationship further includes: If the first query dependency is that the query of the first neighbor node does not depend on the first target node, then the node at the head of the target queue is taken out as the fourth target node, and the fourth query dependency between the fourth target node and the fourth neighbor node connected to it by a target connection edge is analyzed. Based on the fourth query dependency, a logical execution plan for the target query statement is generated.

13. A data query device, comprising: The acquisition unit is configured to acquire a target query statement to be executed, wherein the target query statement specifies multiple data tables and includes query conditions; wherein, each of the multiple data tables supports a read method, and the read method uses a portion of the corresponding data table for filtering and querying; The parsing unit is configured to parse the multiple data tables to be queried, the filtering conditions for the data tables in the multiple data tables, and the association conditions between the data tables from the target query statement; The first generation unit is configured to generate a first relation graph based on the parsing results. The first relation graph includes nodes corresponding to the plurality of data tables, and target connection edges between nodes used to characterize association conditions. Any node includes the reading method supported by its corresponding data table, and the node corresponding to the data table with the association filtering condition also includes the filtering condition. The analysis unit is configured to select nodes from the first relation graph that satisfy the included reading methods according to the included filtering conditions as first target nodes, and analyze the first query dependency relationship between the first target node and its first neighbor nodes connected by a target connection edge, including: if the first association condition represented by the target connection edge between the first target node and the first neighbor node satisfies the reading methods included in the first neighbor node, then it is determined that the query of the first neighbor node depends on the first target node; if the first association condition does not satisfy the reading methods included in the first neighbor node, then it is determined that the query of the first neighbor node does not depend on the first target node. The second generation unit is configured to generate a logical execution plan for the target query statement based on the first query dependency relationship, including: if the first query dependency relationship is that the query of the first neighbor node depends on the first target node, then generating an associated query node between the first target node and the first neighbor node; generating a first subtree, the first subtree including the associated query node, the first target node, the first neighbor node, a connection edge from the first target node to the associated query node, and a connection edge from the first neighbor node to the associated query node; converting the first association condition represented by the target connection edge between the first target node and the first neighbor node into a first filter condition and adding it to the first neighbor node in the first subtree; replacing the second subtree in the first relationship graph with the first subtree, the second subtree being formed by the first target node and the first neighbor node connected to the first target node by a target connection edge, the associated query node being used to replace the first neighbor node in the second subtree; generating the logical execution plan based on the updated first relationship graph, generating the logical execution plan for the target query statement for joint queries of the multiple data tables.

14. A computer-readable storage medium having a computer program stored thereon, which, when executed in a computer, causes the computer to perform the method of any one of claims 1-12.

15. A computing device comprising a memory and a processor, wherein the memory stores executable code, and the processor, when executing the executable code, implements the method of any one of claims 1-12.

Citation Information

Patent Citations

  • Multi-table connection query method and device, equipment and storage medium

    CN114780589A