Data query method and device, electronic equipment and storage medium
By splitting the target query task into subquery tasks of a single data table and merging the results, the problem of high resource consumption in multi-data source or multi-data table queries is solved, achieving efficient data querying and saving storage resources.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-08-15
- Publication Date
- 2026-03-31
AI Technical Summary
When querying target data from multiple data sources or multiple data tables, existing technologies require the creation of temporary tables for synchronous storage, resulting in high resource consumption, low query efficiency, and wasted storage resources.
The target query task is broken down into multiple sub-query tasks. Each sub-query task is a query task with a single data table, a single query condition, and a single aggregation method. The sub-query tasks are split using the single-table query concept, and the query results are merged to generate the target query result.
It improves the efficiency of data querying, reduces resource consumption, avoids the storage of temporary tables, reduces query complexity, and enhances query performance.
Smart Images

Figure CN115374157B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of data processing technology, and in particular to a data query method, apparatus, electronic device, and storage medium. Background Technology
[0002] In scenarios where target data is stored across multiple data sources or tables, it's impossible to retrieve the target data using a single structured query language (SCL) record. Related technologies suggest creating a temporary table to synchronously store data from multiple data sources or tables, and then querying the target data from this temporary table. However, synchronously storing data from multiple data sources or tables in a temporary table is resource-intensive, inefficient, and wasteful of storage resources. Summary of the Invention
[0003] This disclosure provides a data query method, apparatus, electronic device, and storage medium to at least solve the problems in related technologies where storing data from multiple data sources or multiple data tables simultaneously in temporary tables results in high resource consumption, low query efficiency, and wasted storage resources. The technical solution of this disclosure is as follows:
[0004] According to a first aspect of the present disclosure, a data query method is provided, comprising: obtaining a target query task including at least one query field, the target query task being used to instruct the search for target data from at least one data table; splitting the target query task according to the at least one query field and a preset splitting condition to obtain at least two sub-query tasks, each sub-query task being a query task for a single data table, a single query condition, and a single aggregation method; obtaining at least two query results corresponding to at least two sub-query tasks in the data table corresponding to each sub-query task, based on the aggregation method corresponding to each sub-query task and using the query condition corresponding to each sub-query task as a filtering rule; and merging the at least two query results to generate a target query result for the target query task.
[0005] Optionally, in the above data query method, the above-preset splitting conditions include the query fields in each of the at least two subquery tasks, which need to satisfy the following conditions: the data tables corresponding to the query fields are the same, the query conditions corresponding to the query fields are the same, and the aggregation methods corresponding to the query fields are the same.
[0006] Optionally, the above "based on at least one query field, split the target query task according to preset splitting conditions to obtain at least two sub-query tasks" includes: splitting the target query task according to a first splitting condition to obtain at least two first splitting query tasks, where the data tables corresponding to the query fields in each first splitting query task are the same; splitting each first splitting query task according to a second splitting condition to obtain at least two second splitting query tasks, where the query conditions corresponding to the query fields in each second splitting query task are the same; splitting each second splitting query task according to a third splitting condition to obtain at least two third splitting query tasks, where the aggregation methods corresponding to the query fields in each third splitting query task are the same; and determining the at least two third splitting query tasks as at least two sub-query tasks.
[0007] Optionally, the above data query method further includes: splitting the target query task according to at least one query field and preset splitting conditions to obtain at least two sub-query tasks, and then obtaining the target dimension field in the target query task; determining the task dimension field corresponding to each of the at least two sub-query tasks, wherein the task dimension field belongs to the target dimension field and also belongs to the source dimension field contained in the single data table of the sub-query task; and adding the task dimension field corresponding to each sub-query task in each sub-query task.
[0008] Optionally, the above "in the data table corresponding to each subquery task, according to the aggregation method corresponding to each subquery task and using the query conditions corresponding to each subquery task as the filtering rules, obtain at least two query results corresponding to at least two subquery tasks" includes: determining the sub-main query task among at least two subquery tasks, and determining the subquery tasks other than the sub-main query task among at least two subquery tasks as at least one sub-further query task; in the data table corresponding to the sub-main query task, according to the aggregation method corresponding to the sub-main query task and using the query conditions corresponding to the sub-main query task as the filtering rules, obtain the main query result corresponding to the sub-main query task; in the data table corresponding to each sub-further query task, according to the aggregation method corresponding to each sub-further query task and using the query conditions corresponding to each sub-further query task as the filtering rules, obtain at least one secondary query result corresponding to at least one sub-further query task.
[0009] The above-mentioned "merging at least two query results to generate the target query result of the target query task" includes: merging the main query result and at least one secondary query result to generate the target query result of the target query task.
[0010] Optionally, the above "determining the sub-main query task among at least two subquery tasks" includes: obtaining a first target task among at least two subquery tasks, the first target task including a sorting field; if the number of tasks in the first target task is 1, determining the first target task as the sub-main query task; if the number of tasks in the first target task is greater than 1, determining the first target task carrying the filtering conditions as the second target task; if the number of tasks in the second target task is 1, determining the second target task as the sub-main query task; if the number of tasks in the second target task is greater than 1, determining the first target task corresponding to the maximum number of fields as the sub-main query task.
[0011] Optionally, the above data query method further includes: determining the subquery tasks other than the sub-main query tasks in at least two subquery tasks as at least one sub-sub-query task, obtaining the sub-main query conditions corresponding to the sub-main query task; and adding the sub-main query conditions to each sub-sub-query task in the at least one sub-sub-query task using a logical AND operation.
[0012] Optionally, the above "in each sub-query task's corresponding data table, based on the aggregation method of each sub-query task and using the query conditions of each sub-query task as the filtering rules, obtain at least one sub-query result corresponding to at least one sub-query task" includes: obtaining the main query dimension field corresponding to the main sub-query task; in each sub-query task's corresponding data table, based on the aggregation method of each sub-query task and using the query conditions and main query dimension field of each sub-query task as the filtering rules, finding at least one sub-query result corresponding to at least one sub-query task.
[0013] Optionally, the above "merging the main query result and at least one subordinate query result to generate the target query result of the target query task" includes: merging the primary key values corresponding to the dimension fields in the sub-main query task, and the subordinate key values corresponding to the dimension fields in at least one sub-sub subordinate query task, to obtain the target key value of the target query result; and merging the main query result and at least one subordinate query result according to the target key value to generate the target query result of the target query task.
[0014] Optionally, the above "in each sub-query task's corresponding data table, based on the aggregation method of each sub-query task and using the query conditions of each sub-query task as filtering rules, at least one sub-query result corresponding to at least one sub-query task is obtained" includes: in a concurrent manner, in each sub-query task's corresponding data table, based on the aggregation method of each sub-query task and using the query conditions of each sub-query task as filtering rules, at least one sub-query result corresponding to at least one sub-query task is obtained.
[0015] According to a second aspect of the present disclosure, a data query apparatus is provided, including an acquisition unit, a splitting unit, a first processing unit, and a second processing unit. The acquisition unit is configured to acquire a target query task including at least one query field, the target query task indicating the search for target data from at least one data table. The splitting unit is configured to split the target query task acquired by the acquisition unit according to the at least one query field and preset splitting conditions, obtaining at least two sub-query tasks, each sub-query task being a query task with a single data table, a single query condition, and a single aggregation method. The first processing unit is configured to, in the data table corresponding to the sub-query task split by each splitting unit, according to the aggregation method corresponding to the sub-query task split by each splitting unit and using the query condition corresponding to the sub-query task split by each splitting unit as a filtering rule, obtain at least two query results corresponding to the at least two sub-query tasks. The second processing unit is configured to merge the at least two query results obtained by the first processing unit to generate a target query result for the target query task.
[0016] Optionally, in the above data query device, the preset splitting conditions in the splitting unit include the query fields in each of the at least two sub-query tasks, which need to satisfy the following conditions: the data tables corresponding to the query fields are the same, the query conditions corresponding to the query fields are the same, and the aggregation methods corresponding to the query fields are the same.
[0017] Optionally, the above splitting unit is specifically used for: splitting the target query task according to the first splitting condition to obtain at least two first splitting query tasks, wherein the data tables corresponding to the query fields in each first splitting query task are the same; splitting each first splitting query task according to the second splitting condition to obtain at least two second splitting query tasks, wherein the query conditions corresponding to the query fields in each second splitting query task are the same; splitting each second splitting query task according to the third splitting condition to obtain at least two third splitting query tasks, wherein the aggregation methods corresponding to the query fields in each third splitting query task are the same; and determining at least two third splitting query tasks as at least two subquery tasks.
[0018] Optionally, the data query device further includes a determining unit and an adding unit; the obtaining unit is further configured to, after the splitting unit splits the target query task according to at least one query field and a preset splitting condition to obtain at least two sub-query tasks, obtain the target dimension field in the target query task; the determining unit is configured to determine the task dimension field corresponding to each of the at least two sub-query tasks, wherein the task dimension field belongs to the target dimension field obtained by the obtaining unit, and the task dimension field also belongs to the source dimension field contained in the single data table of the sub-query task; the adding unit is configured to, in each sub-query task, add the task dimension field corresponding to the sub-query task determined by each determining unit.
[0019] Optionally, the first processing unit described above is configured to: determine the sub-main query task among at least two sub-query tasks, and determine the sub-query tasks other than the sub-main query task among the at least two sub-query tasks as at least one sub-secondary query task; in the data table corresponding to the sub-main query task, obtain the main query result corresponding to the sub-main query task according to the aggregation method corresponding to the sub-main query task and the query conditions corresponding to the sub-main query task as the filtering rule; in the data table corresponding to each sub-secondary query task, obtain at least one secondary query result corresponding to at least one sub-secondary query task according to the aggregation method corresponding to each sub-secondary query task and the query conditions corresponding to each sub-secondary query task as the filtering rule;
[0020] The second processing unit described above is used to: merge the main query result and at least one secondary query result to generate the target query result for the target query task.
[0021] Optionally, the first processing unit is specifically used to: obtain a first target task from at least two subquery tasks, the first target task including a sorting field; if the number of tasks in the first target task is 1, determine the first target task as a sub-main query task; if the number of tasks in the first target task is greater than 1, determine the first target task carrying the filtering conditions as a second target task; if the number of tasks in the second target task is 1, determine the second target task as a sub-main query task; if the number of tasks in the second target task is greater than 1, determine the first target task corresponding to the maximum number of fields as a sub-main query task.
[0022] Optionally, the above data query device further includes: an acquisition unit, which is further configured to, after the determining unit determines the sub-query tasks other than the sub-main query tasks in at least two sub-query tasks as at least one sub-sub-query task, acquire the sub-main query conditions corresponding to the sub-main query task; and an addition unit, which is further configured to add the sub-main query conditions to each sub-sub-query task in the at least one sub-sub-query task in a logical AND manner.
[0023] Optionally, the first processing unit described above is further configured to: obtain the main query dimension field corresponding to the sub-main query task; and in the data table corresponding to each sub-sub query task, find at least one sub-query result corresponding to at least one sub-sub query task based on the aggregation method corresponding to each sub-sub query task and using the query conditions and main query dimension field corresponding to each sub-sub query task as filtering rules.
[0024] Optionally, the second processing unit described above is specifically used to: merge the primary key values corresponding to the dimension fields in the sub-main query task and the secondary key values corresponding to the dimension fields in at least one sub-secondary query task to obtain the target key value of the target query result; and based on the target key value, merge the main query result and at least one secondary query result to generate the target query result of the target query task.
[0025] Optionally, the first processing unit described above is further configured to: in a concurrent manner, in the data table corresponding to each sub-sub-query task, according to the aggregation method corresponding to each sub-sub-query task and using the query conditions corresponding to each sub-sub-query task as the filtering rules, obtain at least one sub-query result corresponding to at least one sub-query task.
[0026] According to a third aspect of the present disclosure, an electronic device is provided, comprising: a processor; and a memory for storing processor-executable instructions; wherein the processor is configured to execute the instructions to implement a data query method as provided in the first aspect and any of its possible design embodiments.
[0027] According to a fourth aspect of the present disclosure, a readable storage medium is provided that, when instructions in the readable storage medium are executed by a processor, enables the data query method provided by the first aspect and any possible design thereof.
[0028] According to a fifth aspect of the present disclosure, a computer program product is provided, including a computer program / instructions that, when executed by a processor, implement the data query method provided by the first aspect and any possible design thereof.
[0029] The technical solution provided in this disclosure offers at least the following advantages: First, a target query task including at least one query field is obtained. Then, based on at least one query field and according to preset splitting conditions, the target query task is split to obtain at least two sub-query tasks. Based on the single-table query concept, the target query task is split, and the data tables corresponding to any two sub-query tasks are not related. The query complexity of the sub-query tasks is low, and the query efficiency based on a single sub-query task is high. Second, in the data table corresponding to each sub-query task, based on the aggregation method corresponding to each sub-query task and using the query conditions corresponding to each sub-query task as the filtering rule, at least two query results corresponding to at least two sub-query tasks are obtained. Since each sub-query task is a query task with a single data table, a single query condition, and a single aggregation method, it is only necessary to quickly find the query results corresponding to each sub-query task within a small amount of data, such as a single data table, at the granularity of a single query task, which can improve the efficiency of data querying. Finally, the at least two query results are merged to obtain the target query result of the target query task. During the data query process, there is no need to create temporary tables, which saves the storage resources of temporary tables. The query complexity of subquery tasks is low, the query efficiency of data query based on a single subquery task is high, and the range of data queried is small, resulting in low resource consumption and improved query efficiency.
[0030] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit this disclosure. Attached Figure Description
[0031] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this disclosure and, together with the description, serve to explain the principles of this disclosure, and are not intended to unduly limit this disclosure.
[0032] Figure 1 This is a schematic diagram illustrating an advertising delivery data table according to an exemplary embodiment;
[0033] Figure 2 This is a schematic diagram illustrating a delivery performance indicator according to an exemplary embodiment;
[0034] Figure 3 This is a schematic diagram illustrating the construction of material indicators according to an exemplary embodiment;
[0035] Figure 4 This is one of the flowcharts illustrating a data query method according to an exemplary embodiment;
[0036] Figure 5 This is a second flowchart illustrating a data query method according to an exemplary embodiment;
[0037] Figure 6 This is a third flowchart illustrating a data query method according to an exemplary embodiment;
[0038] Figure 7 This is a fourth flowchart illustrating a data query method according to an exemplary embodiment;
[0039] Figure 8 This is the fifth flowchart illustrating a data query method according to an exemplary embodiment;
[0040] Figure 9 This is a schematic flowchart of a data query method according to an exemplary embodiment, number six.
[0041] Figure 10 This is a block diagram illustrating a data query device according to an exemplary embodiment;
[0042] Figure 11 This is a schematic diagram of the structure of an electronic device according to an exemplary embodiment. Detailed Implementation
[0043] To enable those skilled in the art to better understand the technical solutions of this disclosure, the technical solutions in the embodiments of this disclosure will be clearly and completely described below with reference to the accompanying drawings.
[0044] It should be noted that the terms "first," "second," etc., used in the specification, claims, and accompanying drawings of this disclosure are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this disclosure described herein can be implemented in orders other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this disclosure. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this disclosure as detailed in the appended claims.
[0045] It should also be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for display, data used for analysis, etc.) involved in this disclosure are all information and data authorized by the user or fully authorized by all parties.
[0046] Furthermore, in the description of the embodiments of this disclosure, unless otherwise stated, " / " means "or," for example, A / B can mean A or B. The term "and / or" in this document is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, and B existing alone. Additionally, in the description of the embodiments of this disclosure, "multiple" refers to two or more.
[0047] For report queries, when the data to be queried resides in multiple tables, comes from multiple data sources, or the statistical conditions for the query fields differ in the report requirements, a table join query is necessary. The data source, or the origin of the data, provides the location of the required data. All information establishing database connections is stored in the data source. Just as a file can be found in a file system by its name, the correct data source name allows the retrieval of the corresponding database connection. When the data to be queried comes from multiple data sources, it means the data is stored in multiple databases, which may even be stored on multiple servers.
[0048] In table join queries, the first step is to select the query fields, such as... Figure 1 As shown, the field details table can include data such as Detail 1, Detail 2, and Detail 3. The above field details table can also display other custom fields based on user input. These other custom fields can be, for example,... Figure 2 The fields shown in the performance metrics can be other custom fields such as... Figure 3 The data points shown are the fields in the material metrics. When a table has many fields, the page displays a subset of the fields by default, while the remaining fields are displayed only after the user has made their own selections. These user-selectable fields are called custom fields. After determining the query fields in the field details table, query conditions can be organized based on the user-selected fields. If all query fields originate from the same data table, a single-table query is sufficient; otherwise, a table join query is required.
[0049] In table join queries, assuming multiple tables belong to the same data source but are different tables, a table join approach can be used. This involves defining multiple subqueries in the SQL, joining them, and then executing them sequentially to obtain the target query result. However, when the target query result contains a large amount of data, it actually involves complex data processing tasks on the underlying database, resulting in very low performance for table join queries. Because the amount of data involved in the above process is particularly large, query requests often time out.
[0050] Therefore, this disclosure provides a data query method that can solve the problem of querying related data tables from multiple data tables or multiple data sources. Specifically, the target query task is divided into multiple query tasks, and each query task is executed multiple times based on the single-table query concept. Finally, the results of the multiple queries are combined to obtain the final query result. The above-mentioned single-table query method is based on a single data table, which avoids the association between data tables, allowing each query task to retrieve only a small amount of data, thereby improving data query efficiency. In other words, for data query tasks involving table association, a general solution is formed by summarizing and abstracting the query tasks. This solution not only avoids the association between data tables, improving query efficiency, but also reduces development costs by allowing query tasks to be executed through configuration.
[0051] The data query method provided in this disclosure can be applied to electronic devices. In this disclosure, the electronic device can be a personal smart device such as a mobile phone or tablet computer, or it can be an electronic device such as a laptop computer, handheld computer, desktop computer, ultra-mobile personal computer (UMPC), server, or other electronic devices capable of storing and processing data. There are no restrictions on the form of the electronic device.
[0052] The data query method provided by the embodiments of this disclosure will now be described with reference to the accompanying drawings, using a data query device as an example for illustrative explanation. This data query device can be the aforementioned electronic device. Figure 4 As shown, the data query method provided in this embodiment includes the following steps 401 to 404.
[0053] Step 401: The data query device obtains a target query task that includes at least one query field.
[0054] In this embodiment of the disclosure, the target query task is used to instruct the search for target data from at least one data table. The at least one data table may belong to the same data source or to different data sources.
[0055] In this embodiment of the disclosure, the query field is used to record indicator data. Indicator data are numerical values with a certain range of variation, such as long jump distance, temperature, and altitude. Correspondingly, the target data corresponding to the query field can be found through the dimension field. The dimension field is usually used for filtering and is enumerated data, such as city, rainbow color, time (e.g., year, month, day, week of the week), etc.
[0056] For example, the target query task can look up the temperature of city C in province B within time A from a temperature table. The query field is temperature, and the dimension fields include time, province name, and city name.
[0057] Step 402: The data query device splits the target query task according to at least one query field and preset splitting conditions to obtain at least two sub-query tasks.
[0058] In this embodiment of the disclosure, each subquery task is a query task with a single data table, a single query condition, and a single aggregation method. It is understood that the subquery result obtained by executing a single subquery task will have a larger data volume than the query result obtained by executing the target query task through a join table.
[0059] Optionally, in this embodiment of the disclosure, the above-mentioned preset splitting conditions include the query fields in each of the at least two sub-query tasks, which need to satisfy the following conditions: the data tables corresponding to the query fields are the same, the query conditions corresponding to the query fields are the same, and the aggregation methods corresponding to the query fields are the same.
[0060] The technical solution provided in this disclosure offers at least the following advantages: By setting preset splitting conditions, ensuring that the data tables corresponding to the query fields are the same, the query conditions are the same, and the aggregation methods are the same, the subquery tasks obtained by splitting the target query task are query tasks with a single data table, a single query condition, and a single aggregation method. This ensures that there is no relationship between the data tables corresponding to any two subquery tasks, resulting in lower query complexity for the subquery tasks and higher query efficiency for data queries based on a single subquery task.
[0061] Optionally, in embodiments of this disclosure, such as Figure 5 As shown, step 402 can be implemented by the following steps 501 to 504.
[0062] Step 501: The data query device splits the target query task according to the first splitting condition to obtain at least two first splitting query tasks.
[0063] Step 502: The data query device splits each first split query task according to the second split condition to obtain at least two second split query tasks.
[0064] Step 503: The data query device splits each second split query task according to the third split condition, and obtains at least two third split query tasks.
[0065] Step 504: The data query device determines at least two third split query tasks as at least two sub-query tasks.
[0066] In this embodiment of the disclosure, the data tables corresponding to the query fields in each first split query task are the same. The query conditions corresponding to the query fields in each second split query task are the same. The aggregation methods corresponding to the query fields in each third split query task are the same.
[0067] It should be noted that the aforementioned pre-defined splitting conditions are specifically divided into a first splitting condition, a second splitting condition, and a third splitting condition. The splitting results obtained by splitting the target query condition using the pre-defined splitting conditions, or using the first, second, and third splitting conditions, are the same. That is, at least two third-split query tasks are ultimately determined as at least two subquery tasks.
[0068] In this embodiment of the disclosure, the data query device splits the data in the order described above, that is, it splits the target query conditions in sequence according to the data source, the restriction conditions and the aggregation method, so that the complexity of the first split query task, the second split query task and the third split query task obtained by the split decreases in sequence.
[0069] Understandably, to avoid interdependencies between subquery tasks, the data query device splits the target query task based on the data table, ensuring that the data tables corresponding to the query fields in the first split query task are the same. Of course, if all the query fields in the target query task belong to the same data table, then a single-table query can be performed.
[0070] It is also understandable that the data query device splits each first split query task according to the query conditions to reduce the complexity of the second split query task. The query conditions are the way the data is restricted. For example, for brand sales, the query conditions can be global average sales, average sales in region D, and average sales in region D during time period E.
[0071] It is also understandable that the data query device splits each second split query task according to the aggregation method, so that the target data corresponding to the third split query task is data with a single aggregation dimension. For example, for the average sales of region D, the aggregation method is brand-region.
[0072] Further optionally, in this embodiment of the disclosure, after step 402 above, as follows: Figure 6 As shown, the above data query method also includes steps 601 to 603.
[0073] Step 601: The data query device obtains the target dimension field in the target query task.
[0074] Step 602: The data query device determines the task dimension field corresponding to each of the at least two subquery tasks.
[0075] Step 603: The data query device adds the task dimension field corresponding to each subquery task to each subquery task.
[0076] In this embodiment of the disclosure, the task dimension field belongs to the target dimension field, and the task dimension field also belongs to the source dimension field contained in the single data table of the subquery task. That is, the task query field in each subquery task is the intersection of the target dimension field and the source dimension field contained in its corresponding single data packet.
[0077] The technical solution provided in this disclosure brings at least the following benefits: In each subquery task, a task dimension field corresponding to each subquery task is added, so that the query results obtained from each subquery task can be merged through the task dimension field, thereby improving the accuracy of the generated target query results.
[0078] The technical solution provided in this disclosure offers at least the following beneficial effects: by sequentially splitting the target query task according to the first, second, and third splitting conditions, it can quickly obtain subquery tasks that meet the requirements, i.e., subquery tasks are query tasks with a single data table, a single query condition, and a single aggregation method. By improving the speed of determining subquery tasks, the speed of executing the target query task is increased.
[0079] Step 403: The data query device obtains at least two query results corresponding to at least two subquery tasks in the data table corresponding to each subquery task, based on the aggregation method corresponding to each subquery task and the query conditions corresponding to each subquery task as the filtering rules.
[0080] The data table can be used to store video-related data such as video duration, video views, number of likes, number of shares, and video type.
[0081] Optionally, in embodiments of this disclosure, such as Figure 7 As shown, step 403 above can also be implemented through steps 701 to 703 below.
[0082] Step 701: The data query device determines the sub-main query task among at least two sub-query tasks, and determines the sub-query tasks other than the sub-main query tasks among at least two sub-query tasks as at least one sub-secondary query task.
[0083] Further optional, in embodiments of this disclosure, such as Figure 8 As shown, determining the sub-main query task among at least two sub-query tasks in step 701 above can be achieved through steps 801 to 805 below.
[0084] Step 801: The data query device obtains the first target task from at least two sub-query tasks.
[0085] Step 802: When the number of tasks for the first target task is 1, the data query device determines the first target task as the sub-main query task.
[0086] Step 803: If the number of tasks in the first target task is greater than 1, the data query device will identify the first target task carrying the filtering conditions as the second target task.
[0087] Step 804: When the number of tasks for the second target task is 1, the data query device determines the second target task as the sub-main query task.
[0088] Step 805: If the number of tasks in the second target task is greater than 1, the data query device determines the first target task corresponding to the maximum number of fields as the sub-main query task.
[0089] In this embodiment of the disclosure, the first target task includes a sorting field. It is understood that for data storage, especially big data storage, sorting is typically required. Therefore, the first target task, which includes a sorting field, contains the most data in its dimension fields. Using this first target task as a sub-main query task can avoid the problem of data not being able to be merged during the subsequent merging of query results.
[0090] It should be noted that the number of fields in the first objective task refers to the total number of all fields in the first objective task, including query fields and dimension fields.
[0091] The technical solution provided in this disclosure has at least the following beneficial effects: by determining the sub-main query task through one or two of the following conditions: sorting field, whether to carry filtering conditions, and number of fields, the problem of data not being able to be merged can be avoided during the subsequent merging of query results.
[0092] Step 702: The data query device obtains the main query result corresponding to the sub-main query task in the data table corresponding to the sub-main query task, based on the aggregation method corresponding to the sub-main query task and the query conditions corresponding to the sub-main query task as the filtering rules.
[0093] In this embodiment, in the data table corresponding to the sub-main query task, the query fields in the query conditions of the sub-main query task are first searched to filter out the initial data included in the main query results. Then, according to the aggregation method corresponding to the sub-main query task and the correspondence between the dimension fields and the initial data, the main query results corresponding to the sub-main query task are recorded.
[0094] For example, in the process of obtaining the main query results, the selectable query fields and the data table recording the target data are listed first. Then, the query conditions for the main query task are set, including company name and query time. Finally, the query fields for grouping are set.
[0095] Step 703: The data query device, in the data table corresponding to each sub-sub-query task, according to the aggregation method corresponding to each sub-sub-query task and the query conditions corresponding to each sub-sub-query task as the filtering rules, obtains at least one sub-query result corresponding to at least one sub-query task.
[0096] In this embodiment of the disclosure, step 703 is similar to step 702 described above, and will not be repeated here.
[0097] For example, in the process of obtaining the main query results, the selectable query fields and the data table recording the target data are listed first. Then, the query conditions for the main query task are set, including company name, query time, delivery system, and delivery behavior. Finally, the query fields for grouping are set.
[0098] Further optionally, in this embodiment of the disclosure, assuming that the number of at least one sub-query task is greater than 2, the data query device can concurrently obtain at least one sub-query result corresponding to at least one sub-query task in the data table corresponding to each sub-query task, based on the aggregation method corresponding to each sub-query task and the query conditions corresponding to each sub-query task as the filtering rules.
[0099] The technical solution provided in this disclosure brings at least the following beneficial effects: by starting and executing sub-query tasks concurrently, the speed of obtaining sub-query results can be improved, thereby improving the data query speed.
[0100] The technical solution provided in this disclosure brings at least the following beneficial effects: it identifies a sub-main query task and at least one sub-secondary query task in at least two sub-query tasks, so as to merge the query results based on the sorting field included in the sub-main query results, thereby improving the accuracy of the generated target query results.
[0101] Optionally, in this embodiment of the disclosure, since the dimension fields need to be arranged in the same order during the merging of the main query result and at least one secondary query result, the data values corresponding to these dimension fields are collected from each row of records in the query result (including the main query result and at least one secondary query result), and the main query result corresponding to the sub-main query task and the secondary query result corresponding to the sub-secondary query task are merged according to these dimension fields. Therefore, step 703 specifically includes: obtaining the main query dimension fields corresponding to the sub-main query task; and in the data table corresponding to each sub-secondary query task, finding at least one secondary query result corresponding to at least one sub-secondary query task based on the aggregation method corresponding to each sub-secondary query task, using the query conditions and main query dimension fields corresponding to each sub-secondary query task as filtering rules.
[0102] It should be noted that due to sorting and pagination issues in the sub-main query task, and because the dimension fields corresponding to the sub-main query task are not recorded in the sub-sub-detail query task, the sub-query results corresponding to the sub-sub-detail query task cannot be merged with the main query results corresponding to the sub-main query task.
[0103] For example, the primary sub-query task includes dimension field E and dimension field F, specifically involving dimension values e1, e2, e3, f1, and f2. Based on the query conditions corresponding to each secondary sub-query task, all dimension values from the aforementioned dimension fields E and F are also used as query conditions for the corresponding query dimension fields of the secondary sub-query task.
[0104] The technical solution provided in this disclosure brings at least the following beneficial effects: by using the query conditions and main query dimension fields corresponding to each sub-query task as filtering rules, the sub-query results corresponding to the sub-query tasks are found, so as to ensure that the main query results corresponding to the sub-main query tasks and the sub-query results corresponding to the sub-sub-query tasks can be merged, thereby improving the accuracy of the target query results.
[0105] Further optional, in embodiments of this disclosure, such as Figure 9 As shown, after step 701 above, the data query method also includes the following steps 901 and 902.
[0106] Step 901: The data query device obtains the sub-master query conditions corresponding to the sub-master query task.
[0107] Step 902: The data query device adds the sub-master query conditions to each sub-sub-query task in at least one sub-sub-query task using a logical AND method.
[0108] For example, the sub-main query task includes a sub-dimension field E and a dimension field F, specifically involving dimension values e1, e2, e3, f1, and f2, and also includes a metric field V, specifically involving metric values v1, v2, and v3. The main query result corresponding to the sub-main query task may include {e1, f1, v1}, {e2, f1, v2}, and {e3, f2, v3}.
[0109] In this embodiment, the main query result is equivalent to the main query condition. The data query device can add each main query result to at least one sub-query task using a logical AND operation. This ensures that the sub-query tasks also contain dimension combination results.
[0110] It should be noted that, typically, the sub-query results of at least one sub-query task contain more data than the main query results of the main query task. Due to sorting and pagination issues in the sub-main query task, and because the dimension fields corresponding to the sub-main query task are not recorded in the sub-sub-query task, the limitation on the number of data rows in the sub-query results of the sub-sub-query task can be removed.
[0111] In this embodiment of the disclosure, the data query device can also exhaustively add the main query results to at least one sub-query task, that is, apply query restrictions to the dimension fields of the sub-query task that are completely consistent with the main query results corresponding to the sub-main query task. For example, dimension field E has a dimension value of e1 and dimension field F has a dimension value of f1, or dimension field E has a dimension value of e2 and dimension field F has a dimension value of f1, or dimension field E has a dimension value of e3 and dimension field F has a dimension value of f2. When there are many main query results corresponding to the sub-main query task, the query statement may become too complex and exceed the length limit.
[0112] The technical solution provided in this disclosure brings at least the following beneficial effects: by obtaining the sub-master query conditions corresponding to the sub-master query task and adding the sub-master query conditions to each sub-sub-sub-query task in at least one sub-sub-query task in a logical AND manner, the sub-query results corresponding to the sub-sub-query tasks include the dimension fields in the master query results, which can ensure that the master query results and sub-query results can be merged.
[0113] Step 404: The data query device merges at least two query results to generate the target query result for the target query task.
[0114] It is understandable that the target query results include the target data.
[0115] Optionally, in this embodiment of the disclosure, after the data query device determines the sub-main query task and at least one sub-secondary query task in at least two sub-query tasks, step 404 above is: the data query device merges the main query result and at least one secondary query result to generate the target query result of the target query task. The technical solution provided by this disclosure brings at least the following beneficial effects: determining the sub-main query task and at least one sub-secondary query task in at least two sub-query tasks facilitates merging the query results based on the sorting field included in the sub-main query result, thereby improving the accuracy of the generated target query result.
[0116] Further optionally, in this embodiment of the disclosure, step 404 specifically includes: merging the primary key values corresponding to the dimension fields in the sub-main query task and the secondary key values corresponding to the dimension fields in at least one sub-secondary query task to obtain the target key value of the target query result; and merging the main query result and at least one secondary query result according to the target key value to generate the target query result of the target query task.
[0117] It should be noted that during the merging of the main query results and at least one subordinate query results, the dimension fields need to be arranged in the same order. This involves retrieving the data values corresponding to the dimension fields in each row of the query results (including the primary key values of the dimension fields in the main query results and the subordinate key values of the dimension fields in the subordinate query results), and then concatenating these data values into a string to serve as the target key. Based on the example above, the target key can be e1-f1, e1-f2, or e2-f2.
[0118] It should also be noted that if one or more dimension fields are missing in the query results, the number of data rows in the target query results will be less than that of at least two query results with more dimensions, which means that the target query results will lose some target data.
[0119] The technical solution provided in this disclosure has at least the following beneficial effects: by merging primary key values and secondary key values to obtain the target key value, the target query results are prevented from losing some target data.
[0120] The technical solution provided in this disclosure offers at least the following advantages: First, a target query task including at least one query field is obtained. Then, based on at least one query field and according to preset splitting conditions, the target query task is split to obtain at least two sub-query tasks. Based on the single-table query concept, the target query task is split, and the data tables corresponding to any two sub-query tasks are not related. The query complexity of the sub-query tasks is low, and the query efficiency based on a single sub-query task is high. Second, in the data table corresponding to each sub-query task, based on the aggregation method corresponding to each sub-query task and using the query conditions corresponding to each sub-query task as the filtering rule, at least two query results corresponding to at least two sub-query tasks are obtained. Since each sub-query task is a query task with a single data table, a single query condition, and a single aggregation method, it is only necessary to quickly find the query results corresponding to each sub-query task within a small amount of data, such as a single data table, at the granularity of a single query task, which can improve the efficiency of data querying. Finally, the at least two query results are merged to obtain the target query result of the target query task. During the data query process, there is no need to create temporary tables, which saves the storage resources of temporary tables. The query complexity of subquery tasks is low, the query efficiency of data query based on a single subquery task is high, and the range of data queried is small, resulting in low resource consumption and improved query efficiency.
[0121] The foregoing primarily describes the solutions of the embodiments of this disclosure from a methodological perspective. It is understood that, in order to achieve the above functions, the data query device includes at least one of the hardware structures and software modules corresponding to the execution of each function. Those skilled in the art should readily recognize that, based on the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein, this disclosure can be implemented in hardware or a combination of hardware and computer software. Whether a function is executed in hardware or by computer software driving hardware depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this disclosure.
[0122] This disclosure embodiment can divide the data query device into functional units according to the above method example. For example, each function can be divided into separate functional units, or two or more functions can be integrated into one processing unit. The integrated unit can be implemented in hardware or as a software functional unit. It should be noted that the unit division in this disclosure embodiment is illustrative and only represents one logical functional division; other division methods may be used in actual implementation.
[0123] Figure 10This is a schematic diagram illustrating the structure of a data query device according to an exemplary embodiment. (Refer to...) Figure 10 As shown, the data query device provided in this embodiment includes an acquisition unit 1001, a splitting unit 1002, a first processing unit 1003, and a second processing unit 1004.
[0124] The acquisition unit 1001 is used to acquire a target query task that includes at least one query field, the target query task being used to instruct the search for target data from at least one data table; for example, such as Figure 4 As shown, the acquisition unit 1001 can be used to execute step 401.
[0125] Splitting unit 1002 is used to split the target query task obtained by acquisition unit 1001 according to at least one query field and preset splitting conditions, resulting in at least two sub-query tasks. Each sub-query task is a query task with a single data table, a single query condition, and a single aggregation method; for example, Figure 4 As shown, the splitting unit 1002 can be used to perform step 402.
[0126] The first processing unit 1003 is used to, in the data tables corresponding to the sub-query tasks split by each splitting unit 1002, obtain at least two query results corresponding to at least two sub-query tasks based on the aggregation method corresponding to the sub-query tasks split by each splitting unit 1002 and using the query conditions corresponding to the sub-query tasks split by each splitting unit 1002 as the filtering rules; for example, Figure 4 As shown, the first processing unit 1003 can be used to execute step 403.
[0127] The second processing unit 1004 is used to merge at least two query results obtained by the first processing unit 1003 to generate the target query result of the target query task. For example, Figure 4 As shown, the second processing unit 1004 can be used to execute step 404.
[0128] Optional, such as Figure 10 As shown, in the above data query device, the preset splitting conditions in the splitting unit 1002 include the query fields in each of the at least two sub-query tasks, which need to satisfy the following conditions: the data table corresponding to the query field is the same, the query conditions corresponding to the query field are the same, and the aggregation method corresponding to the query field is the same.
[0129] Optional, such as Figure 10As shown, the aforementioned splitting unit 1002 is specifically used for: splitting the target query task according to a first splitting condition to obtain at least two first splitting query tasks, where the query fields in each first splitting query task correspond to the same data table; splitting each first splitting query task according to a second splitting condition to obtain at least two second splitting query tasks, where the query fields in each second splitting query task correspond to the same query conditions; splitting each second splitting query task according to a third splitting condition to obtain at least two third splitting query tasks, where the query fields in each third splitting query task correspond to the same aggregation method; and determining that the at least two third splitting query tasks are at least two sub-query tasks. For example, as... Figure 5 As shown, the splitting unit 1002 can be used to perform steps 501 to 504.
[0130] Optional, such as Figure 10 As shown, the above-mentioned data query device also includes a determining unit 1005 and an adding unit 1006;
[0131] The acquisition unit 1001 is also used to split the target query task according to at least one query field and preset splitting conditions, resulting in at least two sub-query tasks, and then acquire the target dimension field from the target query task; for example, such as Figure 6 As shown, the acquisition unit 1001 can be used to execute step 601.
[0132] Determining unit 1005 is used to determine the task dimension field corresponding to each of the at least two subquery tasks. The task dimension field belongs to the target dimension field obtained by obtaining unit 1001, and also belongs to the source dimension field contained in a single data table of the subquery task; for example, such as... Figure 6 As shown, the determining unit 1005 can be used to perform step 602.
[0133] Add unit 1006 to add the task dimension field corresponding to the subquery task determined by each determination unit 1005 in each subquery task. For example, such as Figure 6 As shown, the added unit 1006 can be used to perform step 603.
[0134] Optional, such as Figure 10As shown, the first processing unit 1003 is configured to: determine the sub-main query task among at least two sub-query tasks, and determine the sub-query tasks other than the sub-main query task among the at least two sub-query tasks as at least one sub-secondary query task; in the data table corresponding to the sub-main query task, obtain the main query result corresponding to the sub-main query task according to the aggregation method corresponding to the sub-main query task and using the query conditions corresponding to the sub-main query task as the filtering rule; in the data table corresponding to each sub-secondary query task, obtain at least one secondary query result corresponding to at least one sub-secondary query task according to the aggregation method corresponding to each sub-secondary query task and using the query conditions corresponding to each sub-secondary query task as the filtering rule; for example, as Figure 7 As shown, the first processing unit 1003 can be used to execute steps 701 to 703.
[0135] The second processing unit 1004 described above is used to: merge the main query result and at least one secondary query result to generate the target query result of the target query task.
[0136] Optional, such as Figure 10 As shown, the first processing unit 1003 is specifically used for: obtaining a first target task from at least two subquery tasks, the first target task including a sorting field; when the number of tasks in the first target task is 1, determining the first target task as a sub-main query task; when the number of tasks in the first target task is greater than 1, determining the first target task carrying the filtering conditions as a second target task; when the number of tasks in the second target task is 1, determining the second target task as a sub-main query task; when the number of tasks in the second target task is greater than 1, determining the first target task corresponding to the maximum number of fields as a sub-main query task. For example, as... Figure 8 As shown, the first processing unit 1003 can be used to execute steps 801 to 805.
[0137] Optional, such as Figure 10 As shown, the data query device further includes: an acquisition unit 1001, which is further configured to, after the determining unit 1005 determines the sub-query tasks other than the sub-main query task in at least two sub-query tasks as at least one sub-sub-query task, acquire the sub-main query conditions corresponding to the sub-main query task; for example, such as Figure 9 As shown, the acquisition unit 1001 can be used to execute step 901.
[0138] Adding unit 1006 is also used to add the sub-master query conditions to each sub-sub-query task in at least one sub-sub-query task using a logical AND method. For example, as Figure 9 As shown, the added unit 1006 can be used to perform step 902.
[0139] Optional, such as Figure 10 As shown, the first processing unit 1003 is further configured to: obtain the main query dimension field corresponding to the sub-main query task; and in the data table corresponding to each sub-sub query task, find at least one sub-query result corresponding to at least one sub-sub query task based on the aggregation method corresponding to each sub-sub query task and the query conditions and main query dimension field corresponding to each sub-sub query task as filtering rules.
[0140] Optional, such as Figure 10 As shown, the second processing unit 1004 is specifically used to: merge the primary key values corresponding to the dimension fields in the sub-main query task and the secondary key values corresponding to the dimension fields in at least one sub-secondary query task to obtain the target key value of the target query result; and merge the main query result and at least one secondary query result according to the target key value to generate the target query result of the target query task.
[0141] Optional, such as Figure 10 As shown, the first processing unit 1003 is further configured to: in a concurrent manner, in the data table corresponding to each sub-sub-query task, according to the aggregation method corresponding to each sub-sub-query task and the query conditions corresponding to each sub-sub-query task as the filtering rules, obtain at least one sub-query result corresponding to at least one sub-query task.
[0142] Regarding the apparatus in the above embodiments, the specific manner in which each unit performs its operation has been described in detail in the embodiments related to the method, and will not be elaborated upon here.
[0143] Figure 11 This is a schematic diagram of the structure of an electronic device provided in this disclosure. For example... Figure 11 As shown, the electronic device may include a processor 1101 and a memory 1102 for storing executable instructions of the processor 1101; wherein the processor 1101 is configured to execute the instructions to implement the data query method in the above embodiment.
[0144] In addition, the electronic device may also include a communication bus 1103 and at least one communication interface 1104.
[0145] The processor 1101 may be a central processing unit (CPU), a microprocessor unit, an application-specific integrated circuit (ASIC), or one or more integrated circuits for controlling the execution of programs according to the present disclosure.
[0146] The communication bus 1103 is a signal path used to transmit information between the aforementioned components.
[0147] Communication interface 1104 uses any transceiver-like device for communicating with other devices or communication networks, such as Ethernet, radio access network (RAN), wireless local area networks (WLAN), etc.
[0148] Memory 1102 may be a read-only memory (ROM) or other type of static storage device capable of storing static information and instructions, random access memory (RAM) or other type of dynamic storage device capable of storing information and instructions, or electrically erasable programmable read-only memory (EEPROM), compact disc read-only memory (CD-ROM) or other optical disc storage, optical disc storage (including compressed optical discs, laser discs, optical discs, digital universal optical discs, Blu-ray discs, etc.), magnetic disk storage media or other magnetic storage devices, or any other medium capable of carrying or storing desired program code in the form of instructions or data structures and accessible by a computer, but not limited thereto. Memory 1102 may exist independently and be connected to processor 1101 via communication bus 1103. Memory 1102 may also be integrated with processor 1101.
[0149] The memory 1102 stores instructions for executing the present invention, and its execution is controlled by the processor 1101. The processor 1101 executes the program or instructions stored in the memory 1102 to implement the functions of the method of the present invention.
[0150] As an example, combined Figure 10 The functions implemented by the acquisition unit 1001, the splitting unit 1002, the first processing unit 1003, and the second processing unit 1004 in the data query device are the same as those of... Figure 11 The processor 1101 in it has the same function.
[0151] In a specific implementation, as one example, the processor 1101 may include one or more CPUs, for example... Figure 11 CPU0 and CPU1 in the CPU.
[0152] In a specific implementation, as one embodiment, the electronic device may include a plurality of processors 1101, each of which may be a single-core (single-CPU) processor or a multi-core (multi-CPU) processor. Here, processor 1101 may refer to one or more devices, circuits, and / or processing cores for processing data (e.g., computer program instructions).
[0153] In a specific implementation, as one embodiment, the electronic device may further include an output device 1105 and an input device 1106. The output device 1105 communicates with the processor 1101 and can display information in various ways. For example, the output device 1105 may be a liquid crystal display (LCD), a light-emitting diode (LED) display device, a cathode ray tube (CRT) display device, or a projector, etc. The input device 1106 communicates with the processor 1101 and can accept user input in various ways. For example, the input device 1106 may be a mouse, keyboard, touchscreen device, or sensing device, etc.
[0154] Those skilled in the art will understand that Figure 11 The structure shown does not constitute a limitation on the electronic device and may include more or fewer components than shown, or combine certain components, or use different component arrangements. Figure 11 The electronic devices in the system can be servers, clients, or other devices.
[0155] In addition, this disclosure also provides a readable storage medium on which a program or instructions are stored. When the instructions in the readable storage medium are executed by a processor, the electronic device is able to perform the data query method provided in the above embodiments. Optionally, the readable storage medium may be a ROM, random access memory (RAM), CD-ROM, magnetic tape, floppy disk, or optical data storage device, etc.
[0156] In addition, this disclosure also provides a computer program product, including a computer program / instructions, which is stored in a non-volatile readable storage medium. When the computer program product is executed by at least one processor, it causes an electronic device to perform the data query method provided in the above embodiments.
[0157] Other embodiments of this disclosure will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This disclosure is intended to cover any variations, uses, or adaptations of this disclosure that follow the general principles of this disclosure and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this disclosure are indicated by the claims.
[0158] It should be understood that this disclosure is not limited to the precise structures described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this disclosure is limited only by the appended claims.
Claims
1. A data query method, characterized by, The method comprises the following steps: obtaining a target query task comprising at least one query field, the target query task being used to indicate finding target data from at least one data table; the at least one data table belongs to the same data source; splitting the target query task according to preset splitting conditions to obtain at least two sub-query tasks according to the at least one query field, each of the at least two sub-query tasks being a query task of a single data table, a single query condition and a single aggregation mode; obtaining at least two query results corresponding to the at least two sub-query tasks in the data table corresponding to each of the at least two sub-query tasks according to the aggregation mode corresponding to each of the at least two sub-query tasks and taking the query condition corresponding to each of the at least two sub-query tasks as a screening rule; merging the at least two query results to generate a target query result of the target query task; wherein the step of obtaining the at least two query results corresponding to the at least two sub-query tasks in the data table corresponding to each of the at least two sub-query tasks according to the aggregation mode corresponding to each of the at least two sub-query tasks and taking the query condition corresponding to each of the at least two sub-query tasks as a screening rule comprises the following steps: determining a sub-main query task in the at least two sub-query tasks and determining sub-query tasks other than the sub-main query task in the at least two sub-query tasks as at least one sub-slave query task, the sub-main query task being determined based on one or two of a sorting field, whether a filtering condition is carried and a field number; obtaining a main query result corresponding to the sub-main query task in the data table corresponding to the sub-main query task according to the aggregation mode corresponding to the sub-main query task and taking the query condition corresponding to the sub-main query task as a screening rule; obtaining at least one slave query result corresponding to the at least one sub-slave query task in the data table corresponding to each of the at least one sub-slave query task according to the aggregation mode corresponding to each of the at least one sub-slave query task and taking the query condition corresponding to each of the at least one sub-slave query task as a screening rule; the step of merging the at least two query results to generate the target query result of the target query task comprises the following step: merging the main query result and the at least one slave query result to generate the target query result of the target query task; after the step of determining the sub-query tasks other than the sub-main query task in the at least two sub-query tasks as at least one sub-slave query task, the method further comprises the following steps: obtaining a sub-main query condition corresponding to the sub-main query task; adding the sub-main query condition to each of the at least one sub-slave query task in a logical and manner.
2. The data query method of claim 1, wherein, the preset splitting conditions comprise that the query field in each of the at least two sub-query tasks needs to satisfy that the data table corresponding to the query field is the same, the query condition corresponding to the query field is the same and the aggregation mode corresponding to the query field is the same.
3. The data query method of claim 2, wherein, the step of splitting the target query task according to the preset splitting conditions to obtain the at least two sub-query tasks comprises the following steps: According to a first splitting condition, the target query task is split to obtain at least two first split query tasks, and each query field in each first split query task corresponds to the same data table; According to a second splitting condition, each first split query task is split to obtain at least two second split query tasks, and each query field in each second split query task corresponds to the same query condition; According to a third splitting condition, each second split query task is split to obtain at least two third split query tasks, and each query field in each third split query task corresponds to the same aggregation mode; The at least two third split query tasks are determined as the at least two subquery tasks.
4. The data query method of any of claims 1-3, wherein, After the at least one query field is split into the at least two subquery tasks according to the preset splitting condition, the method further comprises: A target dimension field in the target query task is obtained; A task dimension field corresponding to each subquery task in the at least two subquery tasks is determined, the task dimension field belongs to the target dimension field, and the task dimension field also belongs to a source dimension field contained in a single data table of the subquery task; In each subquery task, a task dimension field corresponding to each subquery task is added.
5. The data query method of claim 1, wherein, The determination of a sub-main query task in the at least two subquery tasks comprises: A first target task in the at least two subquery tasks is obtained, and the first target task includes a sorting field; In a case where a task quantity of the first target task is 1, the first target task is determined as the sub-main query task; In a case where the task quantity of the first target task is greater than 1, a first target task carrying a filtering condition is determined as a second target task; In a case where a task quantity of the second target task is 1, the second target task is determined as the sub-main query task; In a case where the task quantity of the second target task is greater than 1, a first target task corresponding to a maximum value in a field quantity is determined as the sub-main query task.
6. The data query method of claim 1, wherein, In each data table corresponding to each sub-slave query task, at least one slave query result corresponding to at least one sub-slave query task is obtained according to an aggregation mode corresponding to each sub-slave query task and a query condition corresponding to each sub-slave query task as a screening rule, the method comprising: A main query dimension field corresponding to the sub-main query task is obtained; In each data table corresponding to each sub-slave query task, at least one slave query result corresponding to at least one sub-slave query task is obtained according to an aggregation mode corresponding to each sub-slave query task and a query condition corresponding to each sub-slave query task and the main query dimension field as a screening rule.
7. The data query method of claim 1 or 5, wherein, The main query result and the at least one slave query result are merged to generate a target query result of the target query task. merge the primary key values corresponding to the dimension fields in the sub-main query task and the slave key values corresponding to the dimension fields in the at least one sub-slave query task to obtain target key values of the target query result; merge the main query result and the at least one slave query result according to the target key values to generate a target query result of the target query task.
8. The data query method of claim 1, wherein, The at least one slave query result corresponding to each of the at least one sub-slave query task is obtained in the data table corresponding to each of the at least one sub-slave query task according to the aggregation mode corresponding to each of the at least one sub-slave query task and the query condition corresponding to each of the at least one sub-slave query task as a filtering rule. The at least one slave query result corresponding to each of the at least one sub-slave query task is obtained in the data table corresponding to each of the at least one sub-slave query task according to the aggregation mode corresponding to each of the at least one sub-slave query task and the query condition corresponding to each of the at least one sub-slave query task as a filtering rule.
9. A data query apparatus, characterized by comprising: The method comprises an acquisition unit, a splitting unit, a first processing unit, and a second processing unit. The acquisition unit is configured to acquire a target query task comprising at least one query field, the target query task being used to indicate that target data is searched from at least one data table. The at least one data table belongs to the same data source. The splitting unit is configured to split the target query task acquired by the acquisition unit according to a preset splitting condition to obtain at least two sub-query tasks according to the at least one query field, each of the at least two sub-query tasks being a query task of a single data table, a single query condition, and a single aggregation mode. The first processing unit is configured to obtain at least two query results corresponding to the at least two sub-query tasks in the data table corresponding to each of the at least two sub-query tasks split by the splitting unit according to the aggregation mode corresponding to each of the at least two sub-query tasks and the query condition corresponding to each of the at least two sub-query tasks as a filtering rule. The second processing unit is configured to merge the at least two query results obtained by the first processing unit to generate a target query result of the target query task. The first processing unit is specifically configured to: determine a sub-main query task in the at least two sub-query tasks and determine a sub-query task other than the sub-main query task in the at least two sub-query tasks as at least one sub-slave query task, the sub-main query task being determined based on one or two of a sorting field, whether a filtering condition is carried, and a field number; obtain a main query result corresponding to the sub-main query task in the data table corresponding to the sub-main query task according to the aggregation mode corresponding to the sub-main query task and the query condition corresponding to the sub-main query task as a filtering rule; obtain at least one slave query result corresponding to the at least one sub-slave query task in the data table corresponding to each of the at least one sub-slave query task according to the aggregation mode corresponding to each of the at least one sub-slave query task and the query condition corresponding to each of the at least one sub-slave query task as a filtering rule. The merging the at least two query results to generate a target query result of the target query task comprises: merging the main query result and the at least one slave query result to generate a target query result of the target query task; After determining the sub query task other than the sub main query task in the at least two sub query tasks as at least one sub slave query task, the method further comprises: acquiring a sub main query condition corresponding to the sub main query task; adding the sub main query condition to each of the at least one sub slave query task in a logical and manner.
10. An electronic device, comprising: comprise: a processor; a memory for storing the processor-executable instructions; wherein the processor is configured to execute the instructions to implement the data query method of any one of claims 1-8.
11. A computer readable storage medium, characterized in that, When the instructions in the computer-readable storage medium are executed by the processor, the data query method of any one of claims 1-8 is implemented.
12. A computer program product comprising computer programs / instructions, characterized in that, The computer program / instructions are executed by the processor to implement the data query method of any one of claims 1-8.
Citation Information
Patent Citations
Data query method and device in distributed environment and storage medium
CN109656968A