SQL statement processing method and device, medium, equipment and product
By combining the syntax tree node relationships of multiple single-indicator tasks in the CDP system, the merged SQL statements are generated, and the problem of concurrent task scheduling affects the timeliness of data output is solved, and the access efficiency and resource utilization of databases or warehouses is improved. Rate.
Patent Information
- Application Number
- CN202411311996.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-19
- Publication Date
- 2025-01-03
AI Technical Summary
In the CDP system, due to the increase in single indicators, the number of tasks also increases. A large number of concurrent scheduling of multiple tasks will affect the timeliness of data output, and the time and resource consumption caused by concurrent access and data transmission of databases or warehouses is high. , affects the efficiency of task execution.
By obtaining multiple indicators under the indicator grouping, a syntax tree of each indicator is generated, and the nodes in the syntax tree are merged to form a node relationship of the indicator grouping. Based on this relationship, the merged SQL statement is generated, thereby multiple singles are The metric tasks are merged into metric grouping tasks, reducing the number of accesses to the database or warehouse, and simplifying the data query and writing process.
It effectively reduces the number of accesses to databases or warehouses during multiple single-metric task processing, improves the efficiency of data output, simplifies large-scale task processing, reduces resource consumption, and improves the execution efficiency of indicator grouping tasks.
Smart Images

Figure CN119248814A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, and in particular, to a method, device, medium, equipment and product for processing SQL statements. Background Art
[0002] The CDP (Customer-Data-Platform) system is used to collect and unify customer data from multiple sources, and collect, integrate, analyze and apply real-time data and offline data from different scenarios and channels. In a CDP system, multiple calculation indicators can usually be set, such as configuring an independent calculation task for each indicator. Therefore, large-scale task management problems usually arise in a CDP system. In related technologies, as the number of single indicators increases, the number of tasks also increases. The large-scale concurrent scheduling of multiple tasks will affect the timeliness of data output. Summary of the invention
[0003] This summary is provided to introduce concepts in a brief form that will be described in detail in the detailed description below. This summary is not intended to identify key features or essential features of the claimed technical solution, nor is it intended to limit the scope of the claimed technical solution.
[0004] In a first aspect, the present disclosure provides a method for processing an SQL statement, the method comprising: Get multiple indicators under the indicator group; Generate a syntax tree corresponding to each indicator under the indicator group, wherein the syntax tree is used to split the indicator to obtain multiple nodes corresponding to the indicator, and the leaf nodes in the syntax tree are nodes that cannot be split; Merging the nodes in the syntax tree corresponding to the indicator to obtain the node relationship corresponding to the indicator grouping; According to the node relationship corresponding to the indicator grouping, an SQL statement corresponding to the indicator grouping is generated.
[0005] In a second aspect, the present disclosure provides a device for processing SQL statements, the device comprising: The acquisition module is used to obtain multiple indicators under the indicator group; A first generating module is used to generate a syntax tree corresponding to each indicator under the indicator group, wherein the syntax tree is used to split the indicator to obtain multiple nodes corresponding to the indicator, and the leaf nodes in the syntax tree are nodes that cannot be split; A merging module, used to merge the nodes in the syntax tree corresponding to the indicator to obtain the node relationship corresponding to the indicator group; The second generating module is used to generate SQL statements corresponding to the indicator grouping according to the node relationship corresponding to the indicator grouping.
[0006] In a third aspect, the present disclosure provides a computer-readable medium having a computer program stored thereon, which implements the steps of the method described in the first aspect when the computer program is executed by a processing device.
[0007] In a fourth aspect, the present disclosure provides an electronic device, including: a storage device having a computer program stored thereon; A processing device is used to execute the computer program in the storage device to implement the steps of the method described in the first aspect.
[0008] In a fifth aspect, the present disclosure provides a computer program product, including a computer program, which implements the steps of the method described in the first aspect when executed by a processor.
[0009] In the above technical solution, syntax trees corresponding to the multiple indicators can be generated respectively for the multiple indicators, so that the nodes therein can be merged based on the multiple syntax trees to obtain the node relationship corresponding to the indicator group formed by the multiple indicators, and the corresponding SQL statement can be generated based on the node relationship corresponding to the indicator group. Therefore, through the above technical solution, based on the SQL statement corresponding to the generated indicator group, the tasks corresponding to multiple single indicators can be merged to obtain the calculation tasks of the indicator group, which can effectively reduce the number of accesses to the database or data warehouse HDFS (Hadoop Distributed File System) during the processing of multiple single indicator tasks, so as to simplify the data query and writing process in the large-scale task processing process and improve the efficiency of data output. It can also reduce the concurrent access to the database or data warehouse and the time and resource consumption caused by data transmission, thereby improving the efficiency of the execution of the indicator grouping tasks.
[0010] Other features and advantages of the present disclosure will be described in detail in the following detailed description. BRIEF DESCRIPTION OF THE DRAWINGS
[0011] The above and other features, advantages and aspects of the embodiments of the present disclosure will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. Throughout the drawings, the same or similar reference numerals represent the same or similar elements. It should be understood that the drawings are schematic and the originals and elements are not necessarily drawn to scale. In the drawings: Figure 1 It is a flowchart of a method for processing SQL statements provided according to an embodiment of the present disclosure.
[0012] Figure 2 It is a schematic diagram of a syntax tree of indicators under an indicator grouping provided according to an embodiment of the present disclosure.
[0013] Figure 3 A schematic diagram of a syntax tree of indicators under an indicator grouping provided according to another embodiment of the present disclosure.
[0014] Figure 4 A block diagram of a device for processing SQL statements provided according to an embodiment of the present disclosure.
[0015] Figure 5 A schematic diagram of the structure of an electronic device suitable for implementing the embodiments of the present disclosure is shown. DETAILED DESCRIPTION
[0016] Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although certain embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as being limited to the embodiments described herein, which are instead provided for a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are only for exemplary purposes and are not intended to limit the scope of protection of the present disclosure.
[0017] It should be understood that the various steps described in the method embodiments of the present disclosure may be performed in different orders and / or in parallel. In addition, the method embodiments may include additional steps and / or omit the steps shown. The scope of the present disclosure is not limited in this respect.
[0018] The term "including" and its variations used herein are open inclusions, i.e., "including but not limited to". The term "based on" means "based at least in part on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". The relevant definitions of other terms will be given in the following description.
[0019] It should be noted that the concepts such as "first" and "second" mentioned in the present disclosure are only used to distinguish different devices, modules or units, and are not used to limit the order or interdependence of the functions performed by these devices, modules or units.
[0020] It should be noted that the modifications of "one" and "plurality" mentioned in the present disclosure are illustrative rather than restrictive, and those skilled in the art should understand that unless otherwise clearly indicated in the context, it should be understood as "one or more".
[0021] The names of the messages or information exchanged between multiple devices in the embodiments of the present disclosure are only used for illustrative purposes and are not used to limit the scope of these messages or information.
[0022] It is understandable that before using the technical solutions disclosed in the embodiments of the present disclosure, the types, scope of use, usage scenarios, etc. of the personal information involved in the present disclosure should be informed to the user and the user's authorization should be obtained in an appropriate manner in accordance with relevant laws and regulations.
[0023] For example, in response to receiving an active request from a user, a prompt message is sent to the user to clearly prompt the user that the operation requested to be performed will require obtaining and using the user's personal information. Thus, the user can autonomously choose whether to provide personal information to software or hardware such as an electronic device, application, server, or storage medium that performs the operation of the technical solution of the present disclosure according to the prompt message.
[0024] As an optional but non-limiting implementation, in response to receiving an active request from the user, the prompt information may be sent to the user in the form of a pop-up window, in which the prompt information may be presented in text form. In addition, the pop-up window may also carry a selection control for the user to choose "agree" or "disagree" to provide personal information to the electronic device.
[0025] It is understandable that the above notification and the process of obtaining user authorization are merely illustrative and do not constitute a limitation on the implementation of the present disclosure. Other methods that meet the relevant laws and regulations may also be applied to the implementation of the present disclosure.
[0026] At the same time, it is understandable that the data involved in this technical solution (including but not limited to the data itself, the acquisition or use of the data) shall comply with the requirements of relevant laws, regulations and relevant provisions.
[0027] Figure 1 As shown, it is a flowchart of a method for processing SQL statements provided according to an embodiment of the present disclosure. Figure 1 As shown, the method may include: In step 11, multiple indicators under the indicator group are obtained.
[0028] Among them, the CDP system may include daily routine tasks to process customer data. As an example, the user can first create a new indicator that needs to be calculated in the CDP system, and then pre-group the various indicators corresponding to the daily routine tasks. For example, the user can pre-group, or it can be automatically grouped based on the fields corresponding to the data in the indicator, such as the same indicators such as data set, time dimension, aggregation dimension, etc. can be divided into the same indicator group. Each indicator group can contain multiple indicators, and the relationship between the indicator group and the indicator is recorded. In this embodiment, each indicator group can be obtained separately, and each indicator group can obtain the SQL (Structured Query Language) statement corresponding to the indicator group through the following steps.
[0029] In step 12, a syntax tree corresponding to each indicator under the indicator group is generated, wherein the syntax tree is used to split the indicator to obtain multiple nodes corresponding to the indicator and the relationship between the nodes, and the leaf nodes in the syntax tree are nodes that cannot be split.
[0030] Among them, the syntax tree of each indicator can be generated based on the syntax analysis method and syntax tree generation method in the field, such as the syntax tree can be generated by recursive descent analysis. In this step, for each indicator, the indicator can be used as the root node, and the syntax analysis can be performed from top to bottom. The indicator can be recursively decomposed into smaller syntax units (such as sub-indicators) until an indivisible node is obtained as the leaf node of the syntax tree, and finally the syntax tree is constructed through hierarchical decomposition. For example, for indicator A1: sum(indicator field 1) / max(indicator field 2)+indicator field 1+indicator field 3, the schematic diagram of the corresponding syntax tree is as follows Figure 2 As shown, for ease of presentation only Figure 2 In the syntax tree, the nodes are represented. Wherein, sum() and max() are aggregation functions and cannot be split. Wherein, the dependency relationship of the nodes in the syntax tree is represented as the node depending on the node after the node is split, such as node N1 depends on nodes N4 and N5.
[0031] In step 13, the nodes in the syntax tree corresponding to the indicator are merged to obtain the node relationship corresponding to the indicator grouping.
[0032] Among them, the syntax trees corresponding to the various indicators under the indicator group may contain the same nodes, so the nodes in the various syntax trees can be merged to reduce the number of nodes in the node relationship corresponding to the indicator group, thereby simplifying the subsequent SQL statements. If the indicator group also includes indicator A2: max (indicator field 2) / sum (indicator field 1) + indicator field 4, then the syntax tree of indicator A2 contains the same nodes as the syntax tree of indicator A1, so they can be merged to obtain the node relationship corresponding to the indicator group.
[0033] In step 14, SQL statements corresponding to the indicator groups are generated according to the node relationships corresponding to the indicator groups.
[0034] In the above technical solution, syntax trees corresponding to the multiple indicators can be generated respectively for the multiple indicators, so that the nodes therein can be merged based on the multiple syntax trees to obtain the node relationship corresponding to the indicator group formed by the multiple indicators, and the corresponding SQL statement can be generated based on the node relationship corresponding to the indicator group. Therefore, through the above technical solution, based on the SQL statement corresponding to the generated indicator group, the tasks corresponding to multiple single indicators can be merged to obtain the calculation tasks of the indicator group, which can effectively reduce the number of accesses to the database or data warehouse during the processing of multiple single indicator tasks, so as to simplify the data query and writing process in the large-scale task processing process and improve the efficiency of data output. It can also reduce the concurrent access to the database or data warehouse and the time and resource consumption caused by data transmission, thereby improving the efficiency of the execution of the indicator grouping tasks.
[0035] In a possible embodiment, merging the nodes in the syntax tree corresponding to the indicator to obtain the node relationship corresponding to the indicator group may include: Determine the node information and dependency relationship of each node in the syntax tree. The dependency relationship can be used to represent the association relationship between different nodes.
[0036] As an example, the dimensions in the node information of the node can be pre-set, so that the node information can be obtained by extracting information from the configuration information of the indicator and the syntax tree, such as the node information can include the indicator type (type), which is used to indicate whether the node is an aggregation type node, and can also include the indicator field (select_fields), which is used to indicate the field for querying the node, as well as time and dimension fields, etc., wherein the field for querying can be a basic field in the database, such as a field represented by a column, or a materialized indicator in a hive table as a field. The node information can also include the filtering condition (where) corresponding to the node, which is used for data filtering query. The node information can also include the data set (from_tables) corresponding to the node, which is used to indicate the data source of the data, which can be an actual data set or a view. The node information can also include an aggregation field (group_fields) to indicate the field that needs to be aggregated, that is, the column aggregated in the aggregation function. The node information can also include an aggregation dimension (group_key) to indicate the grouping dimension when performing aggregation calculation, that is, the column for grouping. The node information can also include a view name (view_name) corresponding to the node, which is used to indicate the data view obtained by querying data based on the node. The above node information can be analyzed and structured through the configuration information of the indicator. Figure 2Node N4 in contains an aggregation function, then its corresponding indicator type is an aggregation indicator, its corresponding field aggregation dimension is indicator field 1, and its corresponding aggregation key is dim1. The dependency relationship can include the node's dependency nodes (dependencie_nodes), where the node's dependency nodes are initially used to represent the nodes in the syntax tree obtained by splitting the node. The dependency relationship can also include the observer node (observes) corresponding to the node, and the observer node is the node in the syntax tree that is split to obtain the node. Figure 2 As shown in , the dependent nodes of node N1 are N4 and N5, and the observer node of node N4 is node N1, so as to characterize the dependency relationship. The dependency relationship can be determined by the relationship between the nodes in the syntax tree.
[0037] For identical nodes, the identical nodes are merged into the same node, and the dependency relationship of the merged node obtained by the merger is updated.
[0038] Continuing with the above example, the syntax tree corresponding to index A1 and index A2 is represented as follows Figure 3 As shown. If the nodes N4 of index A1 and N9 of index A2 are the same, the same nodes are merged into the same node, such as retaining one of the nodes, and the dependency relationship of the merged node is updated, such as replacing the node before the merge with the merged node in the dependent nodes of the observer node corresponding to the node before the merge, so as to obtain the dependency relationship of the merged node. Figure 3 As shown, node N4 and its node information can be retained, and the dependent node of the observer node N1 corresponding to N4 can be updated to N4, and the dependent node N9 of the observer node N7 corresponding to N9 can be updated to N4. Similarly, N5 and N10 are the same nodes, N5 can be retained, and the dependent node N10 of the observer node N7 corresponding to N10 can be further updated to N5.
[0039] For different nodes, the node group to be merged corresponding to the node is determined based on the node information, wherein each node group includes multiple nodes.
[0040] Among them, the data of some nodes in different nodes can be obtained through a database or data warehouse table lookup operation. Therefore, in this step, the nodes that can be merged can be further determined to reduce the number of table lookups in the indicator calculation process.
[0041] As an example, determining the node group to be merged corresponding to the node based on the node information may include: Based on the node information, the indicator type of the node is determined, wherein the determination can be performed by obtaining a value of the indicator type in the node information.
[0042] For the node whose indicator type is an aggregation type, the aggregation dimension and dependent nodes of the node are determined based on the node information, and the nodes having the same aggregation dimension and dependent nodes are determined as a node group.
[0043] When performing aggregation calculations, grouping is usually required. The calculations of the same grouping dimension can be obtained through a table lookup calculation, and the dependent nodes must be the same. For example, if nodes N4 and N5 have the same corresponding aggregation dimension, dim1, then N4 and N5 can be taken as a node group for merging.
[0044] For the node whose indicator type is not an aggregation type, a filtering condition and a data set of the node are determined based on the node information, and nodes with the same filtering condition and the same data set are regarded as a node group.
[0045] Based on the node information, it can be determined that the data set of N2 is t1, the data set of N3 is t2, and the filtering condition is data within 7 days, and the data set of N8 is t2, and the filtering condition is data within 7 days. Therefore, it can be further determined that the filtering conditions and data sets of N3 and N8 are the same, that is, they are a node group.
[0046] Afterwards, multiple nodes in the node group are merged to obtain a merged node, and the dependency relationship and node information of the merged node are updated to obtain the node relationship corresponding to the indicator grouping.
[0047] As an example, updating the dependency relationship and node information of the merged node may include: The node information of each node in the node group is merged according to the query field in the node information to obtain the node information of the merged node.
[0048] For example, the query fields of multiple nodes in the node group can be merged into a target query field. Take N3 and N8 as examples, where the query field of N3 is index field 3, and the query field of N8 is index field 4, and their data sets and filtering conditions are the same, then the index field 3 and the index field 4 can be merged as the target query field. Then, based on the target query field and the multiple nodes in the node group, the node information of the merged node corresponding to the node group is generated. If the target query field is used as the query field of the merged node, the merged node is generated based on the filtering condition and the data set, and the multiple nodes in the node group are deleted.
[0049] Afterwards, for each node in the node group corresponding to the merged node, the observer node corresponding to the node is determined, and the node in the dependent node of the observer node is updated to the merged node to obtain the dependency relationship of the merged node, wherein the observer node is a node that is split in the syntax tree to obtain at least one node in the node group.
[0050] Among them, the dependency relationship of each node in the node group can be traversed to determine the observer node corresponding to the node. Continuing with the above example, the node after N3 and N8 are merged is N3-8. For node N3, and the corresponding observer node is N0, N3 in the dependent node of observer N0 can be updated to N3-8. For node N8, and the corresponding observer node is N6, N8 in the dependent node of observer N6 can be updated to N3-8.
[0051] Therefore, through the above technical solution, the syntax trees of indicators can be merged based on the relationship between nodes in the syntax tree and the node information of each node to obtain the node relationship that can characterize multiple indicators under the indicator group, so as to provide reliable data support for the access operation of the merged database.
[0052] In a possible embodiment, generating the SQL statement corresponding to the indicator grouping according to the node relationship corresponding to the indicator grouping may include: According to the dependency relationship between the nodes in the node relationship corresponding to the indicator grouping, an SQL statement corresponding to each node in the syntax tree is generated.
[0053] Among them, a materialized view view can be generated based on the query results of data query when the corresponding observer nodes in the node relationship are two or more nodes. The materialized view view is an abstraction of common logic. When executing calculations, the data will be cached in the memory for direct use by other nodes that depend on the view. In this embodiment, when generating an SQL statement, the view of the dependent node of the current node can be used as the data set for data query by the current node to generate the SQL statement.
[0054] For example, the view corresponding to the query result of node N3-8 in the above example is represented as V3-8, and its corresponding SQL statement is represented as: select indicator field 3, indicator field 4 from t2 where filter condition For the N6 node, it needs to perform a nested query from N3-8. When N6 queries the data of index field 4, the SQL statement of the nested query can be implemented through the view: with V3-8 as (select indicator field 3, indicator field 4 from t2 where filter condition) select indicator field 4 from V3-8 The data required for data calculation by a node may come from multiple dependent nodes. In this step, data source splicing can be performed for nodes at the same level through view splicing to obtain the SQL statement corresponding to the node.
[0055] For example, for node N6, the data set of indicator field 4 is V3-8, and the data set of other required data is V4-5 after N4 and N5 are merged. Then the data sets can be spliced through left join to obtain the SQL statement of the node, that is, the SQL statement of indicator A2. Similarly, the SQL statement of node N1, that is, the SQL statement of indicator A1, can be generated.
[0056] The SQL statements of each indicator are concatenated to obtain the SQL statements corresponding to the indicator grouping.
[0057] As an example, in this indicator grouping, it is usually necessary to merge the data result sets of multiple indicators. In this step, the SQL statements of each indicator can be spliced through the UNION ALL operator to obtain the SQL statement corresponding to the indicator grouping, thereby converting multiple columns of data into a row to merge the result sets of two or more SELECT statements.
[0058] Therefore, through the above technical solution, SQL statements can be merged based on the node relationship corresponding to the indicator grouping to realize the merging of result sets of multiple indicators under the indicator grouping, so as to save resource consumption of indicator calculation to a great extent and facilitate subsequent data statistics and report generation process.
[0059] In a possible embodiment, the method may further include: During the execution of the SQL statement corresponding to the indicator grouping, if there are multiple observer nodes corresponding to the current node, the view corresponding to the result set obtained by the current node is cached.
[0060] Among them, the task calculation of the indicators under the indicator group is realized by executing the SQL statement corresponding to the indicator group. During the execution process, if the current node is node N3-8 and there are multiple corresponding observer nodes, the view V3-8 corresponding to the query result of node N3-8 can be cached. For example, SparkDataFrame can be used to cache temporary tables, such as MEMORY_AND_DISK, which can cache all data sets to memory first, and then drop the remaining data to disk when the memory is insufficient. Then the data corresponding to the node only needs to access the data table t2 once to cache the corresponding result set to the memory. After that, multiple observer nodes can obtain the data required for calculation from the view V3-8 in the memory without re-accessing the database or querying HDFS.
[0061] Therefore, through the above technical solution, the same view that is used multiple times can be cached, and the cache can be directly used in the subsequent data calculation process, which effectively reduces the multiple table lookup operations on the database. At the same time, it can also reduce the time and resource consumption caused by network transmission, improve the efficiency of task processing, and at the same time, it can also ensure the stability of database or HDFS operation to a certain extent, and ensure the accuracy and effectiveness of indicator task calculation.
[0062] Among them, the indicators in the above indicator grouping are usually calculated for daily routine tasks in the CDP system. In actual application scenarios, the calculation method of indicators may change due to different time or scenario requirements. For example, indicator A3 is sum (indicator field 1) / max (indicator field 2), and then it is updated to sum (indicator field 1) / min (indicator field 2) due to scenario requirements. If the user needs to perform statistical calculations on previous data, data backtracking is required, that is, calculations are performed based on previous historical data and based on the calculation method of the updated indicators.
[0063] In a possible embodiment, the method may further include: During the execution of the SQL statement corresponding to the indicator group, if a backtracking instruction of the indicator in the indicator group is received, the backtracking instruction is executed after the execution of the task corresponding to the SQL statement is completed.
[0064] Among them, in the present disclosure, the execution of the SQL statement corresponding to the indicator group corresponds to the task calculation of each indicator under the indicator group, and the backtracking instruction is usually used for the backtracking calculation of a single indicator, so the priority of the SQL statement corresponding to the indicator group is higher than the priority of the backtracking instruction. Therefore, in this embodiment, if the SQL statement corresponding to the indicator group to which the indicator belongs is being executed, it is necessary to wait for the task corresponding to the SQL statement corresponding to the indicator group to be executed before the backtracking instruction of the indicator under the indicator group can be executed, so as to avoid affecting the tasks of the indicators under the indicator group that have not been backtracked.
[0065] As an example, a redis lock can be added at the beginning of a routine scheduling task to prevent users from modifying the indicator, so as to ensure that the definition of the indicator is not changed when the SQL statement is generated, thereby achieving consistency and avoiding backtracking conflicts during the execution of the SQL statement. If a backtracking instruction for the indicator is received during the routine scheduling execution of the task, the backtracking instruction will be rejected at this time. The backtracking instruction can be added to the waiting queue. After the task calculation is completed, the redis lock can be released. At this time, the backtracking instruction can be obtained from the waiting queue and executed, realizing data backtracking of a single indicator under the instruction group.
[0066] Therefore, through the above technical solution, it is possible to avoid the influence of single indicator backtracking on the task calculation process of indicator grouping, and support the implementation of single indicator backtracking, ensure the accuracy and effectiveness of data calculation, and broaden the scope of application of the disclosed method.
[0067] Based on the same inventive concept, the present disclosure also provides a SQL statement processing device, such as Figure 4 As shown, the device 10 comprises: An acquisition module 100 is used to acquire multiple indicators under an indicator group; A first generating module 200 is used to generate a syntax tree corresponding to each indicator under the indicator group, wherein the syntax tree is used to split the indicator to obtain multiple nodes corresponding to the indicator, and the leaf nodes in the syntax tree are nodes that cannot be split; A merging module 300 is used to merge the nodes in the syntax tree corresponding to the indicator to obtain the node relationship corresponding to the indicator group; The second generating module 400 is used to generate SQL statements corresponding to the indicator grouping according to the node relationship corresponding to the indicator grouping.
[0068] Optionally, the merging module includes: A first determination submodule, used to determine node information and dependency relationships of each node in the syntax tree; A first merging submodule, used for merging identical nodes into the same node, and updating the dependency relationship of the merged node obtained by merging; A second determination submodule is used to determine, for different nodes, a node group to be merged corresponding to the node based on the node information, wherein each node group includes multiple nodes; The second merging submodule is used to merge multiple nodes in the node group to obtain a merged node, and update the dependency relationship and node information of the merged node to obtain the node relationship corresponding to the indicator grouping.
[0069] Optionally, the second determining submodule includes: A third determination submodule is used to determine the indicator type of the node based on the node information; A fourth determination submodule is used to determine, for a node whose indicator type is an aggregation type, an aggregation dimension and a dependent node of the node based on the node information, and determine nodes with the same aggregation dimension and dependent nodes as a node group; The fifth determination submodule is used to determine the filtering condition and data set of the node based on the node information for the node whose indicator type is not an aggregation type, and to group the nodes having the same filtering condition and data set as a node group.
[0070] Optionally, the second merging submodule includes: A third merging submodule, configured to merge according to the query field in the node information of each node in the node group to obtain the node information of the merged node; An update submodule is used to determine the observer node corresponding to each node in the node group corresponding to the merged node, and update the node in the dependent node of the observer node to the merged node to obtain the dependency relationship of the merged node. The observer node is a node that is split in the syntax tree to obtain at least one node in the node group.
[0071] Optionally, the device further comprises: The cache module is used to cache the view corresponding to the result set obtained by the current node if there are multiple observer nodes corresponding to the current node during the execution of the SQL statement corresponding to the indicator group.
[0072] Optionally, the second generating module includes: A first generating submodule, used to generate a corresponding SQL statement for each of the indicators according to the dependency relationship between the nodes in the node relationship corresponding to the indicator group; The second generation submodule is used to splice the SQL statements of various indicators to obtain the SQL statements corresponding to the indicator grouping.
[0073] Optionally, the device further comprises: The processing module is used to, during the execution of the SQL statement corresponding to the indicator group, if a backtracking instruction of the indicator in the indicator group is received, execute the backtracking instruction after the execution of the task corresponding to the SQL statement is completed.
[0074] Reference below Figure 5 , which shows a schematic diagram of the structure of an electronic device (such as a terminal device or a server) 600 suitable for implementing the embodiment of the present disclosure. The terminal device in the embodiment of the present disclosure may include but is not limited to mobile terminals such as mobile phones, notebook computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 5 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.
[0075] like Figure 5 As shown, the electronic device 600 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 601, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 602 or a program loaded from a storage device 608 into a random access memory (RAM) 603. In the RAM 603, various programs and data required for the operation of the electronic device 600 are also stored. The processing device 601, the ROM 602, and the RAM 603 are connected to each other via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.
[0076] Typically, the following devices may be connected to the I / O interface 605: an input device 606 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 607 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 608 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 609. The communication device 609 may allow the electronic device 600 to communicate with other devices wirelessly or by wire to exchange data. Although Figure 5 The electronic device 600 is shown with various devices, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead.
[0077] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program contains program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device 609, or installed from a storage device 608, or installed from a ROM 602. When the computer program is executed by the processing device 601, the above-mentioned functions defined in the method of the embodiment of the present disclosure are executed.
[0078] It should be noted that the computer-readable medium mentioned above in the present disclosure may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present disclosure, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. Computer readable signal media may also be any computer readable medium other than computer readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer readable medium may be transmitted using any appropriate medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.
[0079] In some embodiments, the client and the server may communicate using any currently known or future developed network protocol such as HTTP (HyperText Transfer Protocol), and may be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), an internet (e.g., the Internet), and a peer-to-peer network (e.g., an ad hoc peer-to-peer network), as well as any currently known or future developed network.
[0080] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.
[0081] The above-mentioned computer-readable medium carries one or more programs. When the above-mentioned one or more programs are executed by the electronic device, the electronic device: obtains multiple indicators under the indicator group; generates a syntax tree corresponding to each indicator under the indicator group, wherein the syntax tree is used to split the indicator to obtain multiple nodes corresponding to the indicator, and the leaf nodes in the syntax tree are nodes that cannot be split; merges the nodes in the syntax tree corresponding to the indicator to obtain the node relationship corresponding to the indicator group; and generates an SQL statement corresponding to the indicator group according to the node relationship corresponding to the indicator group.
[0082] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages or a combination thereof, including, but not limited to, object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet service provider).
[0083] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some implementations as replacements, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0084] The modules involved in the embodiments described in the present disclosure may be implemented by software or hardware. The name of a module does not limit the module itself in some cases. For example, an acquisition module may also be described as a "module for acquiring multiple indicators under an indicator group".
[0085] The functions described above herein may be performed at least in part by one or more hardware logic components. For example, exemplary types of hardware logic components that may be used include, without limitation, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), and the like.
[0086] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or device, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0087] According to one or more embodiments of the present disclosure, Example 1 provides a method for processing an SQL statement, the method comprising: Get multiple indicators under the indicator group; Generate a syntax tree corresponding to each indicator under the indicator group, wherein the syntax tree is used to split the indicator to obtain multiple nodes corresponding to the indicator, and the leaf nodes in the syntax tree are nodes that cannot be split; Merging the nodes in the syntax tree corresponding to the indicator to obtain the node relationship corresponding to the indicator grouping; According to the node relationship corresponding to the indicator grouping, an SQL statement corresponding to the indicator grouping is generated.
[0088] According to one or more embodiments of the present disclosure, Example 2 provides the method of Example 1, wherein merging the nodes in the syntax tree corresponding to the indicator to obtain the node relationship corresponding to the indicator group includes: Determine node information and dependency relationships of each node in the syntax tree; For identical nodes, merge the identical nodes into the same node, and update the dependency relationship of the merged node obtained by merging; For different nodes, determining the node group to be merged corresponding to the node based on the node information, wherein each node group includes multiple nodes; A plurality of nodes in the node group are merged to obtain a merged node, and dependency relationships and node information of the merged node are updated to obtain a node relationship corresponding to the indicator grouping.
[0089] According to one or more embodiments of the present disclosure, Example 3 provides the method of Example 2, wherein determining the node group to be merged corresponding to the node based on the node information includes: Based on the node information, determine the indicator type of the node; For the node whose indicator type is an aggregation type, determining the aggregation dimension and dependent nodes of the node based on the node information, and determining the nodes with the same aggregation dimension and dependent nodes as a node group; For the node whose indicator type is not an aggregation type, a filtering condition and a data set of the node are determined based on the node information, and nodes with the same filtering condition and the same data set are regarded as a node group.
[0090] According to one or more embodiments of the present disclosure, Example 4 provides the method of Example 2, wherein updating the dependency relationship and node information of the merged node includes: Merge according to the query field in the node information of each node in the node group to obtain the node information of the merged node; For each node in the node group corresponding to the merged node, determine the observer node corresponding to the node, and update the node in the dependent node of the observer node to the merged node to obtain the dependency relationship of the merged node, and the observer node is a node that is split in the syntax tree to obtain at least one node in the node group.
[0091] According to one or more embodiments of the present disclosure, Example 5 provides the method of Example 4, wherein the method further includes: During the execution of the SQL statement corresponding to the indicator grouping, if there are multiple observer nodes corresponding to the current node, the view corresponding to the result set obtained by the current node is cached.
[0092] According to one or more embodiments of the present disclosure, Example 6 provides the method of Example 1, wherein generating a SQL statement corresponding to the indicator grouping according to the node relationship corresponding to the indicator grouping includes: Generate a SQL statement corresponding to each of the indicators according to the dependency relationship between the nodes in the node relationship corresponding to the indicator group; The SQL statements of each indicator are concatenated to obtain the SQL statements corresponding to the indicator grouping.
[0093] According to one or more embodiments of the present disclosure, Example 7 provides the method of Example 1, wherein the method further includes: During the execution of the SQL statement corresponding to the indicator group, if a backtracking instruction of the indicator in the indicator group is received, the backtracking instruction is executed after the execution of the task corresponding to the SQL statement is completed.
[0094] According to one or more embodiments of the present disclosure, Example 8 provides a device for processing a SQL statement, the device comprising: The acquisition module is used to obtain multiple indicators under the indicator group; A first generating module is used to generate a syntax tree corresponding to each indicator under the indicator group, wherein the syntax tree is used to split the indicator to obtain multiple nodes corresponding to the indicator, and the leaf nodes in the syntax tree are nodes that cannot be split; A merging module, used to merge the nodes in the syntax tree corresponding to the indicator to obtain the node relationship corresponding to the indicator group; The second generating module is used to generate SQL statements corresponding to the indicator grouping according to the node relationship corresponding to the indicator grouping.
[0095] According to one or more embodiments of the present disclosure, Example 9 provides a computer-readable medium having a computer program stored thereon, which implements the steps of any of the methods described in Examples 1-7 when executed by a processing device.
[0096] According to one or more embodiments of the present disclosure, Example 10 provides an electronic device, including: a storage device having a computer program stored thereon; A processing device is used to execute the computer program in the storage device to implement the steps of any one of the methods described in Examples 1-7.
[0097] According to one or more embodiments of the present disclosure, Example 11 provides a computer program product, including a computer program, which implements the steps of any one of the methods of Examples 1-7 when executed by a processor.
[0098] The above description is only a preferred embodiment of the present disclosure and an explanation of the technical principles used. Those skilled in the art should understand that the scope of disclosure involved in the present disclosure is not limited to the technical solutions formed by a specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above disclosed concept. For example, the above features are replaced with the technical features with similar functions disclosed in the present disclosure (but not limited to) by each other to form a technical solution.
[0099] In addition, although each operation is described in a specific order, this should not be understood as requiring these operations to be performed in the specific order shown or in a sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Similarly, although some specific implementation details are included in the above discussion, these should not be interpreted as limiting the scope of the present disclosure. Some features described in the context of a separate embodiment can also be implemented in a single embodiment in combination. On the contrary, the various features described in the context of a single embodiment can also be implemented in multiple embodiments individually or in any suitable sub-combination mode.
[0100] Although the subject matter has been described in language specific to structural features and / or method logic actions, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. On the contrary, the specific features and actions described above are merely example forms of implementing the claims. Regarding the device in the above embodiment, the specific manner in which each module performs the operation has been described in detail in the embodiment related to the method, and will not be elaborated here.
Claims
1. A method for processing SQL statements, characterized in that: The method comprises: Get multiple indicators under the indicator group; Generate a syntax tree corresponding to each indicator under the indicator group, wherein the syntax tree is used to split the indicator to obtain multiple nodes corresponding to the indicator, and the leaf nodes in the syntax tree are nodes that cannot be split; Merging the nodes in the syntax tree corresponding to the indicator to obtain the node relationship corresponding to the indicator grouping; According to the node relationship corresponding to the indicator grouping, an SQL statement corresponding to the indicator grouping is generated.
2. The method according to claim 1, characterized in that The merging of the nodes in the syntax tree corresponding to the indicator to obtain the node relationship corresponding to the indicator grouping includes: Determine node information and dependency relationships of each node in the syntax tree; For identical nodes, merge the identical nodes into the same node, and update the dependency relationship of the merged node obtained by merging; For different nodes, determining the node group to be merged corresponding to the node based on the node information, wherein each node group includes multiple nodes; A plurality of nodes in the node group are merged to obtain a merged node, and dependency relationships and node information of the merged node are updated to obtain a node relationship corresponding to the indicator grouping.
3. The method according to claim 2, characterized in that The determining, based on the node information, a node group to be merged corresponding to the node includes: Based on the node information, determine the indicator type of the node; For the node whose indicator type is an aggregation type, determining the aggregation dimension and dependent nodes of the node based on the node information, and determining the nodes with the same aggregation dimension and dependent nodes as a node group; For the node whose indicator type is not an aggregation type, a filtering condition and a data set of the node are determined based on the node information, and nodes with the same filtering condition and the same data set are regarded as a node group.
4. The method according to claim 2, characterized in that: The updating of the dependency relationship and node information of the merged node includes: Merge according to the query field in the node information of each node in the node group to obtain the node information of the merged node; For each node in the node group corresponding to the merged node, determine the observer node corresponding to the node, and update the node in the dependent node of the observer node to the merged node to obtain the dependency relationship of the merged node, and the observer node is a node that is split in the syntax tree to obtain at least one node in the node group.
5. The method according to claim 4, characterized in that The method further comprises: During the execution of the SQL statement corresponding to the indicator grouping, if there are multiple observer nodes corresponding to the current node, the view corresponding to the result set obtained by the current node is cached.
6. The method according to claim 1, characterized in that The step of generating SQL statements corresponding to the indicator groups according to the node relationships corresponding to the indicator groups includes: Generate a SQL statement corresponding to each of the indicators according to the dependency relationship between the nodes in the node relationship corresponding to the indicator group; The SQL statements of each indicator are concatenated to obtain the SQL statements corresponding to the indicator grouping.
7. The method according to claim 1, characterized in that The method further comprises: During the execution of the SQL statement corresponding to the indicator group, if a backtracking instruction of the indicator in the indicator group is received, the backtracking instruction is executed after the execution of the task corresponding to the SQL statement is completed.
8. A SQL statement processing device, characterized in that: The device comprises: The acquisition module is used to obtain multiple indicators under the indicator group; A first generating module is used to generate a syntax tree corresponding to each indicator under the indicator group, wherein the syntax tree is used to split the indicator to obtain multiple nodes corresponding to the indicator, and the leaf nodes in the syntax tree are nodes that cannot be split; A merging module, used to merge the nodes in the syntax tree corresponding to the indicator to obtain the node relationship corresponding to the indicator group; The second generating module is used to generate SQL statements corresponding to the indicator grouping according to the node relationship corresponding to the indicator grouping.
9. A computer readable medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processing device, the steps of the method according to any one of claims 1 to 7 are implemented.
10. An electronic device, characterized in that: include: a storage device having a computer program stored thereon; A processing device, configured to execute the computer program in the storage device to implement the steps of the method according to any one of claims 1 to 7.
11. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.
