A data query method and device
By sinking the computational logic in the logical plan tree down to the data source and leveraging the high computing power of the data source for data querying, the problems of transmission time between the data source and memory and limited memory computing power are solved, thus improving the efficiency of data querying.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- BEIJING GRIDSUM TECH CO LTD
- Filing Date
- 2022-06-02
- Publication Date
- 2026-04-21
AI Technical Summary
In existing data query methods, data transfer between the data source and memory is time-consuming and memory computing power is limited, resulting in low data query efficiency.
The computational logic that can be executed by the data source in the logical plan tree is pushed down to the data source for execution, and the high computing power of the data source is used to perform data query operations.
This reduces the amount of data transfer between the data source and memory, as well as the computational burden on memory, thereby improving the processing speed and efficiency of data queries.
Smart Images

Figure CN117216125B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer technology, and in particular to a data query method and apparatus. Background Technology
[0002] To facilitate data querying for users, data query engines, such as distributed query engines, have emerged. A data query engine is responsible for executing data query tasks; its main function is to process data according to the user's data query requirements and return query results that satisfy those requirements.
[0003] Currently, when performing data queries, data query engines need to retrieve and store data from the data source that meets the query requirements in the engine's memory. Once all the data meeting the query requirements is in memory, the data is processed within that memory. This method has at least two drawbacks: First, retrieving and storing the data from the data source in memory incurs significant data transfer time due to the large data volume. Second, the computing power of memory is limited; therefore, the speed of data query processing in memory is constrained by the memory's processing capabilities. These two drawbacks demonstrate that existing data query methods have low efficiency. Summary of the Invention
[0004] In view of this, the present invention proposes a data query method and apparatus, the main purpose of which is to improve data query efficiency.
[0005] To achieve the above objectives, the present invention mainly provides the following technical solutions:
[0006] In a first aspect, the present invention provides a data query method, the method comprising:
[0007] Obtain the logical plan tree for data query, wherein the logical plan tree consists of at least one subtree, each subtree consists of at least one node, and each subtree has a corresponding data source;
[0008] Select a first node from the nodes of the logical plan tree, wherein the computation logic corresponding to the first node can be executed by the data source corresponding to its subtree;
[0009] The computational logic corresponding to the selected first node is provided to the data source corresponding to its subtree, so that the corresponding data source can perform data query operations based on the computational logic.
[0010] Secondly, the present invention provides a data query device, the device comprising:
[0011] The acquisition unit is used to acquire the logical plan tree for data query, wherein the logical plan tree consists of at least one subtree, each subtree consists of at least one node, and each subtree has a corresponding data source.
[0012] The selection unit is used to select a first node from the nodes of the logical plan tree, wherein the calculation logic corresponding to the first node can be executed by the data source corresponding to its subtree;
[0013] The providing unit is used to provide the computational logic corresponding to the selected first node to the data source corresponding to its subtree, so that the corresponding data source can perform data query operations based on the computational logic.
[0014] Thirdly, the present invention provides a computer-readable storage medium comprising a stored program, wherein, when the program is executed, it controls the device on which the storage medium is located to perform the data query method described in the first aspect.
[0015] Fourthly, the present invention provides an electronic device, the electronic device comprising:
[0016] Memory, used to store programs;
[0017] A processor, coupled to the memory, is used to run the program to perform the data query method described in the first aspect.
[0018] By employing the above technical solution, the data query method and apparatus provided by this invention, when there is a data query requirement, obtains a logical plan tree consisting of at least one subtree required for the data query. Then, a first node is selected from the nodes of the logical plan tree. The computational logic corresponding to the selected first node can be executed by the data source corresponding to its subtree. Finally, the computational logic corresponding to the selected first node is provided to the data source corresponding to its subtree, so that the corresponding data source can perform data query operations based on the computational logic. It can be seen that the solution provided by this invention sinks the computational logic in the logical plan tree that can be executed by the data source to the data source for execution. Since the computing power of the data source itself is higher than the computing power of the memory corresponding to the data query engine, sinking the computational logic to the data source can improve the processing speed of data query. In addition, the data source can use its own computing power to obtain data query results with a small amount of data. Transmitting data query results between the data source and memory, compared to transmitting the original data required for the data query, can reduce the amount of data transmitted and the transmission time. In summary, the solution provided by this invention can improve data query efficiency.
[0019] The above description is merely an overview of the technical solution of the present invention. In order to better understand the technical means of the present invention and to implement it in accordance with the contents of the specification, and to make the above and other objects, features and advantages of the present invention more apparent and understandable, specific embodiments of the present invention are described below. Attached Figure Description
[0020] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0021] Figure 1 A flowchart of a data query method provided in one embodiment of the present invention is shown;
[0022] Figure 2 A schematic diagram of a logic plan tree provided by another embodiment of the present invention is shown;
[0023] Figure 3 A flowchart of a data query method provided by another embodiment of the present invention is shown;
[0024] Figure 4 This diagram illustrates the structure of a data query device according to an embodiment of the present invention.
[0025] Figure 5 A schematic diagram of a data query structure provided by another embodiment of the present invention is shown. Detailed Implementation
[0026] Exemplary embodiments of the present disclosure will now be described in more detail with reference to the accompanying drawings. While exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be implemented in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art.
[0027] Data querying is a crucial step in the data application process. To facilitate data retrieval for users, data query engines, such as distributed query engines, have emerged. A data query engine is responsible for executing data query tasks; its main function is to process data based on the user's query requirements and return query results that satisfy those requirements.
[0028] Currently, when performing data queries, data query engines need to retrieve and store data from the data source that meets the query requirements in the engine's memory. Once all the data meeting the query requirements is in memory, the data is processed within that memory. This method has at least two drawbacks: First, retrieving and storing the data from the data source in memory incurs significant data transfer time due to the large data volume. Second, the computing power of memory is limited; therefore, the data query processing speed is slow due to the constraints of memory's processing capabilities. These two drawbacks demonstrate that existing data query methods have low efficiency.
[0029] To improve data query efficiency, this invention provides a data query method and apparatus to reduce the amount of data transferred between the data source and memory, thereby reducing the time spent on data transfer. In addition, it reduces the amount of data processed in memory, thereby reducing the amount of memory computing power required, and thus improving the speed of data query processing.
[0030] The data query method and apparatus provided in this invention can be applied to data query engines such as distributed query engines. This embodiment does not limit the specific application scenario. The data query method and apparatus provided by this invention will be described in detail below.
[0031] like Figure 1 As shown, this embodiment of the invention provides a data query method, which mainly includes:
[0032] 101. Obtain the logical plan tree for data query, wherein the logical plan tree consists of at least one subtree, each subtree consists of at least one node, and each subtree has a corresponding data source.
[0033] A logical plan tree is a data query plan set up according to data query requirements. In practical applications, a logical plan tree can be obtained by rewriting or expanding a preset logical plan tree based on data query requirements. For example, the data query method provided in this embodiment is applied to the Spark SQL distributed query engine, and the logical plan tree for data query is obtained by rewriting or expanding the code of the preset logical plan tree of the Spark SQL distributed query engine.
[0034] The logical plan tree consists of at least one subtree, and each subtree consists of at least one node. Each node contains its own corresponding computational logic. Each subtree also contains its own corresponding data source.
[0035] For example, such as Figure 2 As shown, Figure 2There are three subtrees, A, B, and C. Subtree A corresponds to an Oracle database as its data source. Subtree A includes nodes A1, A2, A3, A4, A5, and A6. Node A1 handles database connection relationships (JDBCRelation) and its calculation logic; node A2 handles filtering; node A3 handles database connection relationships (JDBCRelation); node A4 handles filtering; node A5 handles joining; and node A6 handles aggregation. Subtree B corresponds to a MySQL database as its data source. Subtree B includes nodes B1 and B2. Node B1 handles database connection relationships (JDBCRelation) and its calculation logic; node B2 handles filtering. Subtree A corresponds to Oracle and MySQL databases, meaning it requires query results from these two databases for subsequent data processing. Subtree C includes node C1, whose function is to perform a join operation, which corresponds to the join calculation logic.
[0036] 102. Select the first node from the nodes of the logical plan tree. The calculation logic corresponding to the first node can be executed by the data source corresponding to its subtree.
[0037] To improve data query efficiency, two things need to be done: first, reduce the amount of data transfer between the data source and the data query engine's memory; second, reduce the processing load on the data query engine's memory. The foundation for achieving these two goals is selecting the first node from the logical plan tree, enabling the data source corresponding to the subtree containing the first node to utilize its own computing power to execute the computational logic corresponding to that first node.
[0038] The process of selecting the first node from the nodes of the logical plan tree is described in detail below, which includes the following steps 102A to 102B:
[0039] 102A. Select the second node from the nodes of the logic plan tree.
[0040] The specific process of selecting the second node from the nodes of the logical plan tree is as follows: For each subtree, start from the node at the bottom level of the subtree and traverse the nodes in the subtree upwards, performing the following steps one to four:
[0041] Step 1: Determine whether the computational logic corresponding to the node can be executed by the data source of its subtree.
[0042] For any two adjacent nodes in a subtree, the node at the upper level needs to use the data query result from the node at the lower level. If the upper node cannot receive the data query result from the lower node, then the upper node cannot perform data query processing. Therefore, considering the above factors, when making a judgment for each subtree, it is necessary to traverse the nodes in the subtree upwards starting from the node at the lowest level.
[0043] Since the data source has a large computing power, it can execute the computing logic corresponding to the node relatively quickly. Therefore, in order to reduce the amount of data processing in memory and improve the processing speed of data query, for the currently traversed node, it is necessary to determine whether the computing logic corresponding to the node can be executed by the data source of its subtree.
[0044] Step 2: When it is determined that a node can be executed by the data source of its subtree, continue to traverse the adjacent parent node.
[0045] In order to push computational logic down to the data source as much as possible, when it is determined that the currently traversed node can be executed by the data source of its subtree, it is necessary to continue traversing the adjacent upper-level nodes.
[0046] Step 3: If it is determined that a node cannot be executed by the data source of its subtree, it is necessary to determine whether there are any lower-level nodes below the node.
[0047] If it is determined that a node cannot be executed by the data source of its subtree, it means that the calculation logic corresponding to the currently traversed node cannot be pushed down to the data source of its subtree. In order to further determine whether there is a node in the subtree of the currently traversed node that can be pushed down to its corresponding data source, it is necessary to determine whether there is a lower-level node below the node.
[0048] Step 4: When it is determined that there are lower-level nodes under a node, and all lower-level nodes under a node can be executed by the data source of its subtree, the next lower-level node adjacent to the node is determined as the second node.
[0049] Since for any two adjacent nodes in a subtree, the node at the upper level needs to use the data query results from the node at the lower level, and if the upper level node cannot receive the data query results from the lower level node, then the upper level node cannot perform data query processing. Therefore, when it is determined that there are lower level nodes below a node, and all lower level nodes below the node can be executed by the data source of its subtree, the next lower level node adjacent to the node is determined as the second node.
[0050] Step 5: If it is determined that there are no lower-level nodes under a node, issue a prompt that the subtree containing the node has no computational logic provided to the data source.
[0051] If it is determined that there are no lower-level nodes below a node, then the node is determined to be the lowest-level node in its subtree. At this time, in order to make the user intuitively understand that there is no computational logic in the subtree where the node is located that can sink down to the corresponding data source, a prompt is issued that there is no computational logic in the subtree where the node is located that is provided to the data source.
[0052] In summary, as described in steps one through five regarding the selection of the second node from the nodes of the logical plan tree, the second node can be categorized into the following two cases:
[0053] In the first scenario, the computational logic corresponding to the second node can be executed by the data source corresponding to its subtree. Furthermore, if the second node has lower-level nodes within its subtree, the computational logic corresponding to all lower-level nodes of the second node can be executed by the data source corresponding to their respective subtrees. For example, such as... Figure 2 As shown, the computational logic corresponding to node A5 can be executed by the data source "Oracle database" corresponding to its subtree A. Node A5 has lower-level nodes A1, A2, A3, and A4 in its subtree A. The computational logic corresponding to all lower-level nodes A1, A2, A3, and A4 of node A5 can be executed by the data source "Oracle database" corresponding to its subtree A. Therefore, node A5 is selected as the second node.
[0054] The second approach involves the computational logic corresponding to the second node being executed by the data source corresponding to its subtree, where the second node is the lowest-level node in its subtree. For example, such as... Figure 2 As shown, the computational logic corresponding to node A3 can be executed by the data source "Oracle database" corresponding to its subtree A. Node A3 is the lowest level node in its subtree A, and there are no other nodes below it. Therefore, node A3 is selected as the second node.
[0055] 102B. Select the selected second node and all its lower-level nodes as the first node.
[0056] Since for any two adjacent nodes in a subtree, the node at the upper level needs to use the data query results from the node at the lower level, if the upper node cannot receive the data query results from the lower node, then the upper node will not be able to perform data query processing. Therefore, when selecting the first node based on the second node, the selected second node and all its lower nodes are selected as the first node.
[0057] For example, such as Figure 2As shown, the computational logic corresponding to node A5 can be executed by the data source "Oracle Database" corresponding to its subtree A. Furthermore, node A5 has lower-level nodes A1, A2, A3, and A4 within its subtree A. The computational logic corresponding to all lower-level nodes A1, A2, A3, and A4 of node A5 can be executed by the data source "Oracle Database" corresponding to their respective subtree A. Therefore, node A5 is selected as the second node. Then, nodes A1, A2, A3, A4, and A5 are all selected as the first nodes.
[0058] For example, such as Figure 2 As shown, the computational logic corresponding to node A3 can be executed by the data source "Oracle database" corresponding to its subtree A. Node A3 is the lowest-level node in its subtree A, and there are no other nodes below it. Therefore, node A3 is selected as the second node. Thus, node A3 is selected as the first node.
[0059] 103. Provide the computation logic corresponding to the selected first node to the data source corresponding to its subtree, so that the corresponding data source can perform data query operations based on the computation logic.
[0060] The main purpose of providing the computational logic corresponding to the selected first node to the data source corresponding to its subtree is twofold: First, to enable the data source corresponding to the first node's subtree to execute the computational logic corresponding to the first node using its own computing power, thereby minimizing the amount of data transmitted from the data source to memory; Second, since the data source has greater computing power, it can execute the computational logic corresponding to the first node more quickly. By pushing the computational logic corresponding to the first node down to the data source, the amount of data processed in memory can be reduced.
[0061] The specific process of providing the computation logic corresponding to the selected first node to the data source corresponding to its subtree includes the following steps 103A to 103B:
[0062] 103A. Determine the first node belonging to the same subtree.
[0063] Since the computational logic corresponding to the first node of the same subtree needs to provide the same data source, it is necessary to determine the first node belonging to the same subtree.
[0064] 103B. For the first node belonging to the same subtree: determine the hierarchical relationship between the first nodes of the subtree; based on the hierarchical relationship, convert the calculation logic corresponding to the first node of the subtree into a data query statement supported by the data source corresponding to the subtree; and provide the data query statement to the data source corresponding to the subtree.
[0065] After determining the first node belonging to the same subtree, steps one through three need to be performed for each determined subtree:
[0066] Step 1: Determine the hierarchical relationship between the first nodes of the subtree.
[0067] Because for any two adjacent nodes in a subtree, the node at the upper level needs to use the data query results from the node at the lower level, if the upper node cannot receive the data query results from the lower node, then the upper node will not be able to perform data query processing. Therefore, it is necessary to clearly define the hierarchical relationship between the first nodes in the subtree so that the data source can perform data query processing based on the hierarchical relationship.
[0068] For example, such as Figure 2 As shown, the hierarchical relationship between nodes B1 and B2 in subtree B is that node B1 is the lower level node of node B2.
[0069] Step two: Based on the hierarchical relationship, the calculation logic corresponding to the first node of the subtree is converted into a data query statement supported by the data source corresponding to the subtree.
[0070] The specific process of this step is as follows: First, based on the hierarchical relationship of the first node and the corresponding computational logic, the first node in the subtree is transformed into a logic tree of the class library used to generate query statements. Second, the generated logic tree is transformed into data query statements supported by the corresponding data source, according to the language supported by the corresponding data source, so that the data source can read and execute the data query statements. The essence of transforming the computational logic corresponding to the first node of the subtree into the data query statements supported by the data source based on the hierarchical relationship is to equivalently rewrite functions not supported by the data source into functions supported by the data source.
[0071] Step 3: Provide the data query statement to the data source corresponding to the subtree.
[0072] The data query statement is provided to the data source corresponding to the subtree so that the computational logic of at least some nodes in the subtree is pushed down to the data value, so that the data source executes this part of the computational logic, thereby using the data source's own computing power to obtain the smallest possible result set and obtain the data query results as quickly as possible.
[0073] The data query method provided in this embodiment of the invention, when a data query requirement exists, obtains a logical plan tree consisting of at least one subtree required for the data query. Then, a first node is selected from the nodes of the logical plan tree. The computational logic corresponding to the selected first node can be executed by the data source corresponding to its subtree. Finally, the computational logic corresponding to the selected first node is provided to the data source corresponding to its subtree, so that the corresponding data source can perform data query operations based on the computational logic. It can be seen that the solution provided in this embodiment of the invention sinks the computational logic in the logical plan tree that can be executed by the data source to the data source for execution. Since the computational power of the data source itself is higher than the computational power of the memory corresponding to the data query engine, sinking the computational logic to the data source can improve the processing speed of data query. In addition, the data source can use its own computational power to obtain data query results with a small amount of data. Transmitting the data query results between the data source and memory can reduce the amount of data transmitted and the transmission time compared to transmitting the original data required for the data query. In summary, the solution provided in this embodiment of the invention can improve data query efficiency.
[0074] Furthermore, according to Figure 1 The method shown in the figure, in another embodiment of the present invention, also provides a data query method, such as... Figure 3 As shown, the method mainly includes:
[0075] 201. Obtain the logical plan tree for data query, wherein the logical plan tree consists of at least one subtree, each subtree consists of at least one node, and each subtree has a corresponding data source.
[0076] 202. Select the first node from the nodes of the logical plan tree. The calculation logic corresponding to the first node can be executed by the data source corresponding to its subtree.
[0077] 203. Provide the computation logic corresponding to the selected first node to the data source corresponding to its subtree, so that the corresponding data source can perform data query operations based on the computation logic.
[0078] 204. When the data query result of any data source is obtained, determine whether all nodes in the subtree corresponding to the data source are the first node; if yes, proceed to step 205; otherwise, proceed to step 206.
[0079] The data query result is obtained by the data source executing the computational logic corresponding to the first node it receives. The size of the data query result is smaller than the size of the original data required for the data source to directly feed the data query result back to memory. Therefore, the method of the data source directly feeding back the data query result can reduce the amount of data transfer between the data source and memory, and reduce data transfer time. In addition, since the data source directly feeds back the data query result, the memory can directly use the data query result without performing calculations related to the data query result, thus saving memory's computing power.
[0080] Since the computational logic that sinks to the data source may only involve a portion of the nodes in the subtree, and other nodes in the subtree may still require data query processing, it is necessary to determine whether all nodes in the subtree corresponding to that data source are the first node when obtaining the data query results. Subsequent data query processing will then be performed based on this determination.
[0081] 205. When all nodes in the subtree corresponding to the data source are first nodes, the data query results are provided to the target subtree that has a logical relationship with the subtree corresponding to the data source, wherein the target subtree is the subtree that needs to use the data query results to perform data query operations.
[0082] When it is determined that all nodes in the subtree corresponding to the data source are the first node, it means that the computational logic of all nodes in the subtree has been pushed down to the data source, and the data source completes the corresponding data query processing. At this time, the data query result obtained is the data query processing result of all nodes in the subtree.
[0083] Considering that the logical plan tree for data querying may contain more than one subtree, when it is determined that all nodes in the subtree corresponding to the data source are first nodes, it is necessary to identify the target subtree within the logical plan subtree that has a logical relationship with the subtree corresponding to the data source, so that the target subtree can perform data query operations. For example, such as... Figure 2 As shown, Figure 2 In subtree B, all nodes are first nodes. When the data source "MySQL database" returns the data query results, since all nodes in subtree B corresponding to the data source "MySQL database" are first nodes, the data query results are the data query results of subtree B. Because subtree B and subtree C have a logical relationship, the data query results are provided to subtree C so that node C1 in subtree C can perform subsequent data query operations based on the data query results. It should be noted that since the calculation logic corresponding to node C1 in subtree C is not pushed down to the corresponding data source, all operations in subtree C are performed in memory.
[0084] 206. When there is a third node in the subtree corresponding to the data source that is not selected as the first node, the data query result is provided to the target node in the third node, where the target node is the third node that needs to use the data query result to perform a data query operation.
[0085] If there is a third node in the subtree corresponding to the data source that was not selected as the first node, it means that there are still nodes in the subtree that have not completed the corresponding data query operation. Therefore, a target node needs to be selected from the third nodes. The selection principle for the target node is: the target node is the third node that needs to use the data query results to perform data query operations. After selecting the target node, the data query results are provided to the target node so that the target node can perform subsequent data query operations.
[0086] For example, such as Figure 2 As shown, Figure 2 In subtree A, nodes A1, A2, A3, A4, and A5 are the first nodes. When the data source "Oracle Database" returns the data query results, if there is a node A6 in the subtree corresponding to the data source that is not selected as the third node, since A6 is the parent node of A5, and the data query results are obtained by the database based on the calculation logic corresponding to nodes A1, A2, A3, A4, and A5, the data query results are provided to node A6 so that node A6 can perform subsequent data query operations based on the data query results. It should be noted that since the calculation logic corresponding to node A6 in subtree A is not pushed down to the corresponding data source, all operations in subtree A are performed in memory.
[0087] Furthermore, based on the above method embodiments, another embodiment of the present invention also provides a data query device, such as... Figure 4 As shown, the device includes:
[0088] The acquisition unit 31 is used to acquire the logical plan tree of the data query, wherein the logical plan tree consists of at least one subtree, each subtree consists of at least one node, and each subtree has a corresponding data source.
[0089] The selection unit 32 is used to select a first node from the nodes of the logical plan tree, wherein the calculation logic corresponding to the first node can be executed by the data source corresponding to its subtree.
[0090] The providing unit 33 is used to provide the calculation logic corresponding to the selected first node to the data source corresponding to its subtree, so that the corresponding data source can perform data query operations based on the calculation logic.
[0091] The data query apparatus provided in this embodiment of the invention, when a data query requirement exists, obtains a logical plan tree consisting of at least one subtree required for the data query. Then, a first node is selected from the nodes of the logical plan tree. The computational logic corresponding to the selected first node can be executed by the data source corresponding to its subtree. Finally, the computational logic corresponding to the selected first node is provided to the data source corresponding to its subtree, so that the corresponding data source can perform a data query operation based on the computational logic. It can be seen that the solution provided in this embodiment of the invention sinks the computational logic in the logical plan tree that can be executed by the data source to the data source for execution. Since the computing power of the data source itself is higher than the computing power of the memory corresponding to the data query engine, sinking the computational logic to the data source can improve the processing speed of data query. In addition, the data source can use its own computing power to obtain data query results with a small amount of data. Transmitting the data query results between the data source and memory can reduce the amount of data transmitted and the transmission time compared to transmitting the original data required for the data query. In summary, the solution provided in this embodiment of the invention can improve data query efficiency.
[0092] Optional, such as Figure 5 As shown, the selection unit 32 includes:
[0093] The first selection module 321 is used to select a second node from the nodes of the logical plan tree, wherein the calculation logic corresponding to the second node can be executed by the data source corresponding to its subtree, and when the second node has a lower node in its subtree, the calculation logic corresponding to all the lower nodes of the second node can be executed by the data source corresponding to its subtree.
[0094] The second selection module 322 is used to select the selected second node and all its lower-level nodes as the first node.
[0095] Optional, such as Figure 5 As shown, the first selection module 321 is specifically used for each subtree to traverse the nodes in the subtree upwards starting from the lowest-level node in the subtree, and to perform the following: determine whether the calculation logic corresponding to the node can be executed by the data source of its subtree; if it is determined that the node can be executed by the data source of its subtree, continue to traverse the adjacent upper-level nodes; if it is determined that the node cannot be executed by the data source of its subtree, but all lower-level nodes below the node can be executed by the data source of its subtree, determine the adjacent lower-level node as the second node.
[0096] Optional, such as Figure 5As shown, the first selection module 321 is further configured to, after determining that the node cannot be executed by the data source of its subtree, issue a prompt that the subtree of the node has no computational logic provided to the data source when determining that the node is the lowest level node in its subtree.
[0097] Optional, such as Figure 5 As shown, the providing unit 33 includes:
[0098] Module 331 is used to determine the first node belonging to the same subtree;
[0099] Module 332 is provided for, for the first node belonging to the same subtree: determining the hierarchical relationship between the first nodes of the subtree; converting the calculation logic corresponding to the first node of the subtree into a data query statement supported by the data source corresponding to the subtree based on the hierarchical relationship; and providing the data query statement to the data source corresponding to the subtree.
[0100] Optional, such as Figure 5 As shown, the device further includes:
[0101] The processing unit 34 is configured to, when obtaining a data query result from any data source, determine whether all nodes in the subtree corresponding to the data source are first nodes, wherein the data query result is obtained by the data source executing the calculation logic corresponding to the first node received; and when all nodes in the subtree corresponding to the data source are first nodes, provide the data query result to a target subtree that has a logical relationship with the subtree corresponding to the data source, wherein the target subtree is the subtree that needs to use the data query result to perform a data query operation.
[0102] Optional, such as Figure 5 As shown, the processing unit 34 is further configured to provide the data query result to the target node in the third node when there is a third node in the subtree corresponding to the data source that is not selected as the first node, wherein the target node is the third node that needs to use the data query result to perform a data query operation.
[0103] For a detailed explanation of the methods used in the operation of each functional module in the data query device provided in this embodiment of the invention, please refer to the corresponding method details in the above method embodiments, which will not be repeated here.
[0104] Furthermore, according to the above embodiments, another embodiment of the present invention also provides a computer-readable storage medium, the storage medium including a stored program, wherein, when the program is executed, it controls the device where the storage medium is located to execute the data query method described in the above method embodiments.
[0105] Furthermore, according to the above embodiments, another embodiment of the present invention also provides an electronic device, the electronic device comprising:
[0106] Memory, used to store programs;
[0107] A processor, coupled to the memory, is used to run the program to execute the data query method described in the above method embodiments.
[0108] In the above embodiments, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions in other embodiments.
[0109] It is understood that the relevant features in the above methods and apparatus can be referenced interchangeably. Furthermore, the terms "first," "second," etc., in the above embodiments are used to distinguish between embodiments and do not represent the superiority or inferiority of any particular embodiment.
[0110] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.
[0111] The algorithms and displays provided herein are not inherently related to any particular computer, virtual system, or other device. Various general-purpose systems can also be used in conjunction with the teachings herein. The required structure for constructing such systems is apparent from the above description. Furthermore, this invention is not directed to any particular programming language. It should be understood that the contents of the invention described herein can be implemented using various programming languages, and the above description of specific languages is for the purpose of disclosing the best mode of implementation of the invention.
[0112] Numerous specific details are set forth in the specification provided herein. However, it will be understood that embodiments of the invention may be practiced without these specific details. In some instances, well-known methods, structures, and techniques have not been shown in detail so as not to obscure the understanding of this specification.
[0113] Furthermore, those skilled in the art will understand that although some embodiments described herein include certain features but not others included in other embodiments, combinations of features from different embodiments are intended to be within the scope of the invention and form different embodiments. For example, in the following claims, any of the claimed embodiments can be used in any combination.
[0114] The various component embodiments of the present invention can be implemented in hardware, or as software modules running on one or more processors, or a combination thereof. Those skilled in the art will understand that microprocessors or digital signal processors (DSPs) can be used in practice to implement some or all of the functions of some or all of the components in the method, apparatus, and framework for operating the deep neural network model according to embodiments of the present invention. The present invention can also be implemented as a device or apparatus program (e.g., a computer program and computer program product) for performing part or all of the methods described herein. Such programs implementing the present invention can be stored on a computer-readable medium, or can be in the form of one or more signals. Such signals can be downloaded from an Internet website, provided on a carrier signal, or provided in any other form.
[0115] It should be noted that the above embodiments are illustrative of the invention and not restrictive, and that those skilled in the art can devise alternative embodiments without departing from the scope of the appended claims. In the claims, any reference signs placed between parentheses should not be construed as limiting the claims. The word "comprising" does not exclude the presence of elements or steps not listed in the claims. The word "a" or "an" preceding an element does not exclude the presence of a plurality of such elements. The invention can be implemented by means of hardware comprising several different elements and by means of a suitably programmed computer. In the unit claims enumerating several means, several of these means may be embodied by the same item of hardware. The use of the words first, second, and third, etc., does not indicate any order. These words can be interpreted as names.
Claims
1. A data query method, characterized in that, The method includes: Obtain the logical plan tree for data query, wherein the logical plan tree consists of at least one subtree, each subtree consists of at least one node, and each subtree has a corresponding data source; Select a first node from the nodes of the logical plan tree, wherein the computation logic corresponding to the first node can be executed by the data source corresponding to its subtree; The computational logic corresponding to the selected first node is provided to the data source corresponding to its subtree, so that the corresponding data source can perform data query operations based on the computational logic. Selecting the first node from the nodes of the logical plan tree includes: Select a second node from the nodes of the logical plan tree. The computation logic corresponding to the second node can be executed by the data source corresponding to its subtree. When the second node has a lower node in its subtree, the computation logic corresponding to all the lower nodes of the second node can be executed by the data source corresponding to its subtree. Select the selected second node and all its lower-level nodes as the first node; Selecting a second node from the nodes of the logical plan tree includes: For each subtree, starting from the lowest-level node in the subtree, traverse the nodes in the subtree upwards, performing the following: Determine whether the computational logic corresponding to the node can be executed by the data source of its subtree; When it is determined that the node can be executed by the data source of its subtree, continue to traverse the adjacent parent node; When it is determined that the node cannot be executed by the data source of its subtree, but all the lower-level nodes below the node can be executed by the data source of their subtree, the next lower-level node adjacent to the node is determined as the second node. Specifically, the computational logic corresponding to the selected first node is provided to the data source corresponding to its subtree, including: Determine the first node belonging to the same subtree; For the first node belonging to the same subtree: determine the hierarchical relationship between the first nodes of the subtree; based on the hierarchical relationship, convert the calculation logic corresponding to the first node of the subtree into a data query statement supported by the data source corresponding to the subtree; and provide the data query statement to the data source corresponding to the subtree.
2. The method according to claim 1, characterized in that, After determining that the node cannot be executed by the data source of its subtree, the method further includes: When the node is determined to be the lowest level node in its subtree, a prompt is issued indicating that the subtree containing the node has no computational logic provided to the data source.
3. The method according to claim 1, characterized in that, After providing the computational logic corresponding to the selected first node to the data source corresponding to its subtree, the following is included: When obtaining the data query result of any data source, determine whether all nodes in the subtree corresponding to the data source are the first node, wherein the data query result is obtained by the data source executing the calculation logic corresponding to the first node received; When all nodes in the subtree corresponding to the data source are first nodes, the data query result is provided to the target subtree that has a logical relationship with the subtree corresponding to the data source, wherein the target subtree is the subtree that needs to use the data query result to perform a data query operation.
4. The method according to claim 3, characterized in that, The method further includes: When there is a third node in the subtree corresponding to the data source that is not selected as the first node, the data query result is provided to the target node in the third node, wherein the target node is the third node that needs to use the data query result to perform a data query operation.
5. A data query device, characterized in that, The device includes: The acquisition unit is used to acquire the logical plan tree for data query, wherein the logical plan tree consists of at least one subtree, each subtree consists of at least one node, and each subtree has a corresponding data source. The selection unit is used to select a first node from the nodes of the logical plan tree, wherein the calculation logic corresponding to the first node can be executed by the data source corresponding to its subtree; The providing unit is used to provide the computational logic corresponding to the selected first node to the data source corresponding to its subtree, so that the corresponding data source can perform data query operations based on the computational logic. The selection unit is specifically used to: select a second node from the nodes of the logical plan tree, wherein the calculation logic corresponding to the second node can be executed by the data source corresponding to its subtree, and when the second node has a lower node in its subtree, the calculation logic corresponding to all the lower nodes of the second node can be executed by the data source corresponding to its subtree. Select the selected second node and all its lower-level nodes as the first node; Specifically, the selection unit is used to: for each subtree, traverse the nodes in the subtree upwards starting from the lowest-level node, and perform the following: Determine whether the computational logic corresponding to the node can be executed by the data source of its subtree; When it is determined that the node can be executed by the data source of its subtree, continue to traverse the adjacent parent node; When it is determined that the node cannot be executed by the data source of its subtree, but all the lower-level nodes below the node can be executed by the data source of their subtree, the next lower-level node adjacent to the node is determined as the second node. Specifically, the providing unit is used to determine the first node belonging to the same subtree; for the first node belonging to the same subtree: determine the hierarchical relationship between the first nodes of the subtree; based on the hierarchical relationship, convert the calculation logic corresponding to the first node of the subtree into a data query statement supported by the data source corresponding to the subtree; and provide the data query statement to the data source corresponding to the subtree.
6. A computer-readable storage medium, characterized in that, The storage medium includes a stored program, wherein, when the program is executed, it controls the device where the storage medium is located to execute the data query method according to any one of claims 1 to 4.
7. An electronic device, characterized in that, The electronic device includes: Memory, used to store programs; A processor, coupled to the memory, is used to run the program to perform the data query method according to any one of claims 1 to 4.
Citation Information
Patent Citations
Data query method and device, electronic equipment and storage medium
CN114328595A