Data processing method and device, medium, electronic equipment and program product
By analyzing and adjusting the operator sequence in the structured query statement and dynamically adjusting the data processing logic, the problem of difficulty in adjusting the data processing logic in the existing technology is solved, and the flexibility and scalability of the system are improved.
Patent Information
- Application Number
- CN202411877825.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-16
- Publication Date
- 2025-04-18
AI Technical Summary
The prior art is difficult to flexibly and efficiently adjust the data processing logic in structured query statements to meet actual business needs, resulting in insufficient system flexibility and scalability.
By analyzing structured query statements, adjusting the operator execution order in the operator sequence, and generating new structured query statements, thereby dynamically adjusting the data processing logic.
It realizes flexible and efficient configuration and adjustment of the data processing logic in structured query statements, improves the flexibility and scalability of the system, and meets changes in business needs.
Smart Images

Figure CN119848150A_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the field of computer technology, and specifically relates to a data processing method, device, medium, electronic equipment and program product. Background Art
[0002] In actual business scenarios, if you need to process data in a database table, you can define a series of structured query statements to describe the data processing flow, which makes the data processing logic clearer, easier to understand and maintain. However, when faced with defined structured query statements, how to flexibly and efficiently adjust the data processing logic to meet the needs of actual business is a technical problem that needs to be solved urgently. Summary of the invention
[0003] The present application provides a data processing method, device, medium, electronic device and program product, the purpose of which is to flexibly and efficiently adjust the data processing logic in a structured query statement to improve the flexibility and scalability of the system while meeting business needs.
[0004] Other features and advantages of the present application will become apparent from the following detailed description, or may be learned in part by the practice of the present application.
[0005] According to one aspect of an embodiment of the present application, a data processing method is provided, the method comprising: parsing a first structured query statement to obtain a first operator sequence, the first operator sequence comprising a plurality of operators executed sequentially, the first structured query statement being used to perform a first data operation on at least two data dimensions in a multidimensional database according to the plurality of operators executed sequentially; adjusting the execution order of at least one operator in the first operator sequence to obtain a second operator sequence; generating a second structured query statement according to the second operator sequence, and replacing the first structured query statement with the second structured query statement; and performing a second data operation on at least two data dimensions in the multidimensional database according to the second structured query statement.
[0006] According to one aspect of an embodiment of the present application, a data processing device is provided, the device comprising:
[0007] a parsing module configured to parse a first structured query statement to obtain a first operator sequence, wherein the first operator sequence includes a plurality of operators executed in sequence, and the first structured query statement is used to perform a first data operation on at least two data dimensions in a multidimensional database according to the plurality of operators executed in sequence;
[0008] an adjustment module, configured to adjust the execution order of at least one operator in the first operator sequence to obtain a second operator sequence;
[0009] A generating module, configured to generate a second structured query statement according to the second operator sequence, and replace the first structured query statement with the second structured query statement;
[0010] The execution module is configured to perform a second data operation on at least two data dimensions in the multidimensional database according to the second structured query statement.
[0011] According to one aspect of an embodiment of the present application, a computer-readable medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the data processing method in the above technical solution is implemented.
[0012] According to one aspect of an embodiment of the present application, an electronic device is provided, comprising: a processor; and a memory for storing executable instructions of the processor; wherein the processor is configured to execute the executable instructions to implement a data processing method as in the above technical solution.
[0013] According to one aspect of an embodiment of the present application, a computer program product is provided, including a computer program, and when the computer program is executed by a processor, the data processing method in the above technical solution is implemented.
[0014] In the technical solution provided in the embodiment of the present application, after the first structured query statement is parsed to obtain the first operator sequence, the second operator sequence can be obtained by adjusting the execution order of at least one operator in the first operator sequence, and then a second structured query statement for replacing the first structured query statement can be generated according to the second operator sequence, and then data processing can be performed on the multidimensional database based on the second structured query statement. It can be seen that the technical solution of the embodiment of the present application reduces the workload of manual code writing and speeds up the development of data processing applications by automatically parsing and processing the first structured query statement; and when the data processing logic in the first structured query statement needs to be adjusted to meet actual business needs, the parameter object of the first structured query statement can be re-encapsulated through the new second structured query statement, without in-depth modification of the underlying code, to achieve flexible and efficient configuration and adjustment of the data processing logic in the structured query statement, while meeting business needs, improving the flexibility and scalability of the system.
[0015] It should be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] The drawings herein are incorporated into the specification and constitute a part of the specification, illustrate embodiments consistent with the present application, and together with the specification are used to explain the principles of the present application. Obviously, the drawings described below are only some embodiments of the present application, and for ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0017] Figure 1 The exemplary system architecture block diagram applying the technical solution of the present application is schematically shown.
[0018] Figure 2 A flow chart of a data processing method in one embodiment of the present application is shown.
[0019] Figure 3 A schematic diagram of the storage architecture of a three-dimensional database in one embodiment of the present application is shown.
[0020] Figure 4 The figure shows a syntax tree of a first structured query statement in one embodiment of the present application.
[0021] Figure 5 A flowchart for adjusting the execution order of operators in one embodiment of the present application is shown.
[0022] Figure 6 A schematic diagram showing a comparison of the operation logic of the first operator sequence and the second operator sequence in one embodiment of the present application is shown.
[0023] Figure 7 The syntax tree of the second structured query statement in one embodiment of the present application is shown.
[0024] Figure 8 A schematic diagram showing a comparison of the grammatical structures of a first structured query statement and a second structured query statement in an embodiment of the present application is shown.
[0025] Fig. 9 The structural block diagram of the data processing device provided in the embodiment of the present application is schematically shown.
[0026] Fig.10 The structure block diagram of a computer system suitable for implementing an electronic device of an embodiment of the present application is schematically shown. DETAILED DESCRIPTION
[0027] Example embodiments will now be described more fully with reference to the accompanying drawings. However, example embodiments can be implemented in a variety of forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided so that this application will be more comprehensive and complete and fully convey the concept of the example embodiments to those skilled in the art.
[0028] In addition, described feature, structure or characteristic can be combined in one or more embodiments in any suitable manner. In the following description, many specific details are provided to provide a full understanding of the embodiments of the present application. However, those skilled in the art will appreciate that the technical scheme of the present application can be put into practice without one or more of the specific details, or other methods, components, devices, steps, etc. can be adopted. In other cases, known methods, devices, realizations or operations are not shown or described in detail to avoid blurring the various aspects of the application.
[0029] In the embodiments of the present application, the term "module" or "unit" refers to a computer program or a part of a computer program with a predetermined function, and works together with other related parts to achieve the predetermined function, and can be implemented in whole or in part by using software, hardware (such as processing circuits or memories) or a combination thereof. Similarly, a processor (or multiple processors or memories) can be used to implement one or more modules or units. In addition, each module or unit can be part of an overall module or unit that includes the function of the module or unit.
[0030] The block diagrams shown in the accompanying drawings are merely functional entities and do not necessarily correspond to physically independent entities. That is, these functional entities may be implemented in software form, or in one or more hardware modules or integrated circuits, or in different networks and / or processor devices and / or microcontroller devices.
[0031] The flowcharts shown in the accompanying drawings are only exemplary and do not necessarily include all the contents and operations / steps, nor must they be executed in the order described. For example, some operations / steps can be decomposed, and some operations / steps can be combined or partially combined, so the actual execution order may change according to actual conditions.
[0032] It should be noted that the "multiple" mentioned in this article refers to two or more. "And / or" describes the association relationship of the associated objects, indicating that there can be three relationships. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the associated objects before and after are in an "or" relationship.
[0033] It is understandable that the present application can display a prompt interface or pop-up window before collecting relevant data (such as obtaining data in a multidimensional database through a structured query statement) and during the process of collecting relevant data. The prompt interface or pop-up window is used to prompt the user that its relevant data is currently being collected, so that the present application only starts to execute the step of obtaining relevant data after obtaining the user's confirmation operation on the prompt interface or pop-up window, otherwise (that is, when the user's confirmation operation on the prompt interface or pop-up window is not obtained), the step of obtaining relevant data is terminated, that is, the relevant data is not obtained. In other words, all data collected by the present application are collected with the user's consent and authorization, and the collection, use and processing of relevant data need to comply with the relevant laws, regulations and standards of relevant countries and regions.
[0034] The technical solutions of the embodiments of the present application are mainly used in the field of data processing. Specifically, with the explosive growth of data volume and the increasing complexity of data structure, data processing has become an indispensable key link in all walks of life. However, with the diversification of data sources, the complexity of data structure and the increasing demand for data processing, traditional data processing methods have gradually shown their limitations. These traditional methods often rely on cumbersome scripting or customized software development, resulting in rigid processing flow and difficulty in adapting to the rapidly changing data environment.
[0035] The introduction of structured operation statements provides a more flexible and configurable way for data processing. By defining a series of standardized operation statements, users can describe data processing logic in a declarative way, thereby simplifying the development process and improving the readability and maintainability of the code.
[0036] However, despite the many advantages of structured operation statements, they still face some challenges in practical applications. In particular, when processing statements containing complex function calls, the structured operation statement processing mechanism in related technologies still has significant limitations. For example, when the processing logic of a function node in a structured operation statement cannot meet business needs, you can either passively accept the unreasonable results returned by the structured operation statement, or manually write additional code to modify the data processing logic, which not only increases the development workload, but may also introduce additional errors.
[0037] For example, in the application of Business Intelligence (BI) reports, there is a business demand to generate Structured Query Language (SQL) statements based on the fields and aggregate functions of the database table. When the fields of the database table are in the form of a combination of other fields (such as Field A / Field B), the results may be inaccurate due to differences in statistical dimensions.
[0038] More specifically, as shown in Table 1 below, assuming that the business requirement is to calculate the defect resolution rate of the code, and the monthly defect resolution rate = monthly defect resolution number / monthly total number of defects, in this case, after calculating the monthly defect resolution rate of each month (for example, the monthly defect resolution rate of May in Table 1 is 0.5, and the monthly defect resolution rate of June is 0.75), the SQL statement in the related art is to average the monthly defect resolution rates of multiple months (for example, the average of the monthly defect resolution rates of May and June in Table 1) to represent the overall defect resolution rate, that is, AVG (monthly defect resolution number / monthly total number of defects). However, the defect resolution rate required by the actual business is calculated by the average value of the number of defects resolved and the average value of the total number of defects, that is, AVG (monthly defect resolution number) / AVG (monthly total number of defects). Obviously, the average value of the division result (monthly defect resolution number / monthly total number of defects) obtained by the SQL statement in the related art does not match the actual required business result. That is to say, in the example shown in Table 1, the defect resolution rate obtained by taking the average of the monthly defect resolution rates according to the SQL statement in the relevant technology is (0.5+0.75) / 2=0.625, while the actual business result required is (1+6) / (2+8)=0.7, and the two results are not the same.
[0039]
[0040]
[0041] Table 1
[0042] The problems in the above application scenarios are mainly caused by the mismatch between the processing logic of the function nodes in the SQL statement and the processing logic required by the actual business. When faced with this problem, if the technicians manually write additional code to modify the data processing logic, it will not only increase the development workload, but also may introduce additional errors. Therefore, how to flexibly and efficiently adjust the data processing logic to meet the needs of the actual business is a technical problem that needs to be solved urgently.
[0043] In order to overcome the limitations existing in the relevant technologies and further improve the efficiency and flexibility of structured operation statements in data processing, the embodiment of the present application proposes a new data processing solution, which can automatically parse structured operation statements, intelligently identify and encapsulate specific function parameters, so as to dynamically adjust the data processing logic, thereby significantly improving the efficiency of data processing and better adapting to rapidly changing data processing needs.
[0044] Figure 1 The following schematically shows an exemplary system architecture block diagram that applies the technical solution of the present application. Specifically, Figure 1As shown, in a system architecture 100 applying the technical solution of the embodiment of the present application, a terminal device 110, a network 120 and a server 130 may be included. The terminal device 110 may include a smart phone, a tablet computer, a laptop computer, an intelligent voice interaction device, a smart home appliance, a vehicle-mounted terminal, etc. The server 130 may be a server that provides various services, which may be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, and big data and artificial intelligence platforms. Among them, the network 120 may be a medium that provides a communication connection between the terminal device 110 and the server 130, such as a wired communication link or a wireless communication link.
[0045] According to implementation requirements, the system architecture in the embodiment of the present application may have any number of terminal devices 110, networks 120, and servers 130. For example, the server 130 may be a server group composed of multiple server devices.
[0046] In one embodiment of the present application, a user may use a terminal device 110 to send a first structured query statement for performing data operations on a multidimensional database to a server 130 through a network 120. The multidimensional database may be located in the server 130, or may be located in other devices that can communicate with the server 130. After receiving the first structured query statement, the server 130 may parse the structured operation statement to obtain a first operator sequence corresponding to the first structured query statement.
[0047] After obtaining the first operator sequence corresponding to the first structured query statement, the server 130 may adjust the execution order of at least one operator in the first operator sequence to obtain a second operator sequence.
[0048] For example, the first operator sequence includes a first operator and a second operator that are executed in sequence. For example, in the above example, the first operator can be a function symbol for representing a ratio, i.e., a DIVIDE function, or can be represented as a division operator symbol " / "; the second operator can be a function symbol for representing an average value, i.e., an AVG function. The server 130 can obtain a second operator sequence by exchanging the execution order of the first operator and the second operator. That is, the second operator sequence includes the second operator and the first operator that are executed in sequence.
[0049] After obtaining the second operator sequence, the server 130 may generate a second structured query statement for replacing the first structured query statement according to the second operator sequence, and may further perform data operations on the multidimensional database according to the second structured query statement. Optionally, after the server 130 performs data operations on the multidimensional database according to the second structured query statement, the result of the data processing may be returned to the terminal device 110 through the network 120.
[0050] It can be seen that when the data processing logic in the structured query statement needs to be adjusted to meet actual business needs, the technical solution of the embodiment of the present application can generate a second structured query statement to replace the first structured query statement by adjusting the execution order of the operators in the operator sequence, without in-depth modification of the underlying code, thereby realizing flexible and efficient configuration and adjustment of the data processing logic in the structured query statement, and improving the flexibility and scalability of the system while meeting business needs.
[0051] The following describes in detail the technical solutions such as the data processing method, data processing device, computer-readable medium, electronic device, and computer program product provided by the present application in conjunction with specific implementation methods.
[0052] Figure 2 A flowchart of a data processing method in one embodiment of the present application is shown. The data processing method can be executed by a computer device, which can be Figure 1 The server or terminal device shown in the figure may also be other devices with computing and processing functions. Figure 2 As shown, the data processing method at least includes the following steps S210 to S240.
[0053] S210: Parse the first structured query statement to obtain a first operator sequence, where the first operator sequence includes a plurality of operators that are executed sequentially, and the first structured query statement is used to perform a first data operation on at least two data dimensions in the multidimensional database according to the plurality of operators that are executed sequentially;
[0054] S220: Adjust the execution order of at least one operator in the first operator sequence to obtain a second operator sequence;
[0055] S230: Generate a second structured query statement according to the second operator sequence, and replace the first structured query statement with the second structured query statement;
[0056] S240: According to the second structured query statement, a second data operation is performed on at least two data dimensions in the multidimensional database.
[0057] In the data processing method provided in the embodiment of the present application, by automatically parsing and processing the first structured query statement, the workload of manual code writing is reduced, and the development speed of data processing applications is accelerated; and when the data processing logic in the first structured query statement needs to be adjusted to meet actual business needs, the parameter object of the first structured query statement can be repackaged through a new second structured query statement without in-depth modification of the underlying code, thereby achieving flexible and efficient configuration and adjustment of the data processing logic in the structured query statement, and improving the flexibility and scalability of the system while meeting business needs.
[0058] The implementation details of each step in the data processing method are described in detail below.
[0059] In step S210, the first structured query statement is parsed to obtain a first operator sequence, where the first operator sequence includes multiple operators that are executed sequentially. The first structured query statement is used to perform a first data operation on at least two data dimensions in a multidimensional database according to the multiple operators that are executed sequentially.
[0060] A multidimensional database refers to a database that includes two or more data dimensions, for example, a two-dimensional database or a three-dimensional database.
[0061] The two-dimensional database may be a common relational database, which is a database based on a relational model that organizes data into tables, each of which consists of rows (records) and columns (fields). In other words, the two-dimensional database includes two data dimensions consisting of data rows and data columns.
[0062] A three-dimensional database refers to a database that contains three data dimensions, and its storage architecture can be represented by a data cube. Figure 3 FIG. 1 shows a schematic diagram of a storage architecture of a three-dimensional database in one embodiment of the present application. Figure 3 As shown, in a three-dimensional database, each data object can be located by a first data dimension X, a second data dimension Y and a third data dimension Z.
[0063] To facilitate understanding of the specific implementation of the solution, this application mainly uses a relational database containing two data dimensions as an example for explanation in the following embodiments.
[0064] In one embodiment of the present application, the first structured query statement may be a structured operation statement for executing data operations. Structured operation statements may be sets of instructions or commands organized according to specific grammatical rules in a programming language or a database query language, and these statements are intended to clearly describe the logical structure and execution flow of a program or query to ensure that a computer can accurately understand and execute these instructions.
[0065] Optionally, in a database query language, the structured operation statements may be SQL statements for defining and manipulating data in a database, including data definition language (DDL) statements for defining and modifying database structures, data manipulation language (DML) statements for querying and modifying data in a database, and data control language (DCL) statements for controlling user access rights to a database.
[0066] It should be noted that DDL statements are used to create, modify, and delete objects in the database, such as tables, indexes, views, etc. Optionally, a DDL statement can be a CREATE TABLE statement used to create a new table; an ALTER TABLE statement used to modify the table structure, such as adding, deleting, or modifying columns; a DROP TABLE statement used to delete a table and all its data, etc.
[0067] DML statements are used to query and modify data in a database. They can be used to insert, update, delete, and retrieve data in a database. Optionally, a DML statement can be a SELECT statement used to retrieve data from a database; an INSERT statement used to insert new data into a table; an UPDATE statement used to modify existing data in a table; a DELETE statement used to delete data from a table, etc.
[0068] DCL statements are used to define the access rights and security levels of a database. This statement can be used to control which users can access the database and how they can access the database. Optionally, DCL statements can be GRANT statements used to grant users access rights to database objects; REVOKE statements used to revoke granted access rights to database objects, etc.
[0069] Alternatively, in a programming language, structured operation statements can be the basic units for building programs, which implement complex algorithms and data processing tasks by combining and nesting different control structures. For example, in structured programming languages such as C, C++, and Java, a program consists of a series of functions and procedures, each of which contains a series of structured operation statements.
[0070] In one embodiment of the present application, a method for parsing a first structured query statement may include: parsing the first structured query statement to obtain a grammatical structure corresponding to the first structured query statement; traversing the grammatical structure to obtain a first operator sequence consisting of multiple grammatical nodes in the grammatical structure.
[0071] Taking the first structured query statement as a structured operation statement as an example, parsing the first structured query statement mainly converts the language code (such as SQL query statement, control structure in programming language, etc.) into an internal representation form that can be directly processed or further analyzed by the computer, that is, the grammatical structure, so that the processing logic contained in the structured operation statement can be conveniently analyzed based on the grammatical structure.
[0072] Optionally, when parsing a structured operation statement, the source code corresponding to the structured operation statement can be decomposed into a series of meaningful units (such as identifiers, keywords, operators, expressions, etc.), and a structured representation can be constructed according to the grammatical rules of the language. This structured representation can be a syntax tree. For example, the syntax tree can be an abstract syntax tree (AST).
[0073] In a specific example, assuming that a structured operation statement contains a function for averaging the results of field A / field B, i.e., AVG(field A / field B), then a portion of the syntax tree obtained by parsing the structured operation statement (this portion corresponds to the function node) can be as follows: Figure 4 As shown. Figure 4 In the syntax tree shown, the root node is represented by sqlNode. Below the root node, there are an average operator AVG and a parameter object. The parameter object includes a ratio operator DIVIDE and a division parameter. The division parameter includes a field A as a dividend and a field B as a divisor.
[0074] By traversing the syntax tree, the first operator sequence "DIVIDE; AVG" can be obtained. The first operator sequence means that a ratio operation DIVIDE is first performed on field A and field B, and then an average operation AVG is performed on the result of the ratio operation.
[0075] In step S220, the execution order of at least one operator in the first operator sequence is adjusted to obtain a second operator sequence.
[0076] Figure 5 A flowchart of adjusting the execution order of operators in one embodiment of the present application is shown. Figure 5As shown, based on the above embodiment, step S220 may further include the following steps S221 to S223.
[0077] S221: Selecting a first data dimension and a second data dimension, from at least two data dimensions, a first data dimension and a second data dimension whose execution order is to be adjusted.
[0078] S222: In the first operator sequence, identify the correspondence between the operator and the data dimension, and obtain a first operator corresponding to the first data dimension and a second operator corresponding to the second data dimension.
[0079] S223: In the first operator sequence, swap the execution order of the first operator and the second operator to obtain a second operator sequence.
[0080] In one embodiment of the present application, the multidimensional database is a relational database including two data dimensions, the first data dimension represents data rows in the relational database, and the second data dimension represents data columns in the relational database; the method for identifying the correspondence between operators and data dimensions may further include: when the operand of the operator is a data item located in the same data row, determining the operator as a first operator corresponding to the first data dimension; when the operand of the operator is a data item located in the same data column, determining the operator as a second operator corresponding to the second data dimension.
[0081] In one embodiment of the present application, the first operator is used to calculate the ratio of two data items in the same data row, and the second operator is used to calculate the average value of multiple data items in the same data column.
[0082] Figure 6 A schematic diagram showing a comparison of the operation logic of the first operator sequence and the second operator sequence in one embodiment of the present application is shown.
[0083] like Figure 6 As shown, the first operator sequence can be expressed as "DIVIDE; AVG". The first operator DIVIDE indicates calculating the ratio of field A and field B in the same data row, and the calculated ratio can be saved as field A / B. The second operator AVG indicates calculating the average value for multiple data items in a data column.
[0084] According to the operation logic of the first operator sequence, the ratio of field A and field B is first calculated, and then the average value of the calculated ratio is calculated. The final operation result can be expressed as AVG (A / B).
[0085] By exchanging the execution order of the first operator and the second operator in the first operator sequence, a corresponding second operator sequence can be obtained. For example, corresponding to the first operator sequence "DIVIDE; AVG", the second operator sequence can be expressed as "AVG; DIVIDE".
[0086] According to the operation logic of the second operator sequence, the average values of field A and field B are calculated respectively, and then the ratio of the average value AVG(A) of field A and the average value AVG(B) of field B is calculated. The final operation result can be expressed as AVG(A) / AVG(B).
[0087] In step S230, a second structured query statement is generated according to the second operator sequence, and the first structured query statement is replaced by the second structured query statement.
[0088] In one embodiment of the present application, the method for generating a second structured query statement for replacing a first structured query statement according to a second operator sequence may further include: obtaining a parameter object of the first structured query statement from a grammatical structure, the parameter object being used to represent a data range for performing data operations on a multidimensional database; encapsulating the parameter object according to the second operator sequence to obtain a second structured query statement for replacing the first structured query statement.
[0089] For example, according to Figure 4 The syntax tree shown can determine that the parameter objects of the first structured query statement include field A and field B, that is, the data range for performing data operations on the multidimensional database is a plurality of records including field A and field B.
[0090] In one embodiment of the present application, the method of encapsulating parameter objects according to a second operator sequence may further include: generating at least one operation expression for the parameter object according to the second operator included in the target second operator sequence; generating a second structured query statement according to the first operator included in the second operator sequence, and at least one operation expression.
[0091] It should be noted that the second operator included in the second operator sequence is used to indicate what kind of operation is performed on the parameter object, such as summation, multiplication, ratio, difference, etc. If the parameter object of the first structured query statement contains multiple parameters, then the second operator included in the second operator sequence can be used to perform operations on each of the multiple parameters separately, or two or more of the multiple parameters can be put together for operation, that is, the parameter operation method for the parameter object in the embodiment of the present application is not limited, as long as it can meet the actual business needs.
[0092] Optionally, the first operator included in the second operator sequence is used to indicate the manner in which the at least one obtained operation expression is integrated, for example, it may be summing, multiplying, ratioing, or difference operations on the at least one operation expression. Similarly, the coupling method for at least one operation expression in the embodiment of the present application is not limited as long as it can meet actual business needs.
[0093] In one embodiment of the present application, the second operator is used to calculate the average value of a parameter object, which includes a first field parameter and a second field parameter; generating at least one operation expression for the parameter object according to the second operator included in the second operator sequence may further include: generating a first averaging operation expression for the first field parameter and a second averaging operation expression for the second field parameter according to the second operator included in the second operator sequence.
[0094] For example, the parameter object includes a first field parameter A and a second field parameter B, then the first averaging operation expression generated according to the second operator can be expressed as AVG(A), and the second averaging operation expression generated according to the second operator can be expressed as AVG(B).
[0095] In one embodiment of the present application, the first operator is used to calculate the ratio of parameter objects; generating a second structured query statement based on the first operator included in the second operator sequence and at least one operation expression may further include: generating a ratio expression between the first averaging operation expression and the second averaging operation expression based on the first operator included in the second operator sequence; and encapsulating the ratio expression to obtain a second structured query statement for replacing the first structured query statement.
[0096] For example, the first averaging operation expression is AVG(A), and the second averaging operation expression is AVG(B), then the ratio expression generated according to the first operator can be expressed as AVG(A) / AVG(B).
[0097] In some optional embodiments, the grammatical structure of the second structured query statement generated by encapsulating the ratio expression is as follows: Figure 7 Specifically, Figure 7In the example shown, the root node is represented as sqlNode, and there are a division operator object and a division parameter object below the root node, and the division parameter object includes AVG(A) and AVG(B). Correspondingly, when the second structured query statement is generated by encapsulation processing, field A can be encapsulated with the AVG function to obtain an AVG(A) object, and field B can be encapsulated with the AVG function to obtain an AVG(B) object, and then AVG(A) and AVG(B) are encapsulated together as division parameter objects and the division operator object to obtain a sqlNode, which is the second structured query statement.
[0098] In order to explain the implementation details of the technical solution of the embodiment of the present application in more detail, the technical solution of the embodiment of the present application is described below in combination with the specific application scenarios shown in Table 1 above.
[0099] Based on the application scenario shown in Table 1 above, after calculating the monthly defect resolution rate of each month in the BI system (monthly defect resolution rate = monthly defect resolution number / monthly total defect number), in order to calculate the defect resolution rate of the code, the SQL statement contained in the SQL data set defined by the business end may be to average the monthly defect resolution rates of multiple months to represent the overall defect resolution rate, that is, to represent AVG (monthly defect resolution number / monthly total defect number). The specific SQL statement expression is: select AVG (A / B) from Table. Among them, A represents the field of the monthly defect resolution number, and B represents the field of the monthly total defect number.
[0100] However, as analyzed above, the defect resolution rate required by the actual business is calculated by the average number of defects resolved and the average number of defects, that is, AVG (monthly number of defects resolved) / AVG (monthly total number of defects). Obviously, the average value of the division result (monthly number of defects resolved / monthly total number of defects) obtained by the SQL statement in the SQL data set defined on the business side does not match the actual business result required.
[0101] Therefore, in the technical solution provided in the embodiment of the present application, the AST tree can be obtained by performing syntax parsing on the SQL statement; then the average value function in the AST tree is identified, and the function parameter is the multi-field expression AVG(A / B); and then AVG(A) / AVG(B) is obtained by exchanging the execution order of the average value operator and the ratio operator.
[0102] The structure of the AST tree obtained by parsing the SQL statement can be as follows Figure 4As shown, the root node is represented as sqlNode (i.e., AVG object), and below the root node there are function objects AVG and parameter objects. The parameter objects contain division operators and division parameters, and the division parameters contain the dividend (i.e., field A) and the divisor (i.e., field B). Figure 8 As shown, the AVG object is the root node. The two attributes of the AVG object represent the function object AVG and the parameter object respectively. The two attributes of the parameter object represent the division operator and the division parameter respectively. The two attributes of the division parameter represent the divisor (i.e., field A) and the dividend (i.e., field B).
[0103] Optionally, the grammatical structure corresponding to the SQL statement in the above example can be expressed as:
[0104] class Node{
[0105] String operator;
[0106] List <node>subNodes;
[0107] String toSql();
[0108] }
[0109] In the above syntax structure, the character type operator is used to represent the AVG function object, and the subnode subNodes list contains the parameter objects of the AVG function, that is, Figure 4 The sub-nodes under the root node in the grammatical structure shown.
[0110] In some optional embodiments, the average value function in the AST tree, whose function parameter is a multi-field expression AVG(A / B), is identified mainly by parsing each node in the AST tree node to determine whether the operator of a certain node represents the average value function AVG.
[0111] For example, you can first search for the AVG object in the nodes of the AST tree, such as the sqlNode name is avgNode, which contains the avg function name and parameter object. Then determine whether the parameter object is a division operator, that is, divideNode. If so, get the division parameters, that is, the divisor divisorNode and the dividend dividendNode.
[0112] Alternatively, if Figure 7 As shown in the figure, the AVG(A) / AVG(B) function node can be represented as a root node sqlNode. Below the root node are a division operator object and a division parameter object. The division parameter object contains AVG(A) and AVG(B). Figure 8 As shown, the AVG(A) / AVG(B) object has two attributes representing the division operator object and the division parameter object respectively; the division parameter object has two attributes representing AVG(A) and AVG(B) respectively; the AVG(A) object has two attributes representing the AVG function and field A respectively; the AVG(B) object has two attributes representing the AVG function and field B respectively.
[0113] based on Figure 7 and Figure 8 Correspondingly, when generating an AVG(A) / AVG(B) object through encapsulation processing, field A and AVG function can be encapsulated to obtain an AVG(A) object, field B and AVG function can be encapsulated to obtain an AVG(B) object, and then AVG(A) and AVG(B) are encapsulated together as division parameter objects and division operator objects to obtain a sqlNode, which is the AVG(A) / AVG(B) object, or it can also be called an AVG(A) / AVG(B) node.
[0114] The above process can be implemented as follows: after finding the divisor divisorNode and the dividend dividendNode, two new averaging nodes avgNode1 and avgNode2 are created. The two averaging nodes use the divisor divisorNode and the dividend dividendNode as their child nodes, respectively, and set the operator to "AVG". The two averaging nodes can be expressed as avgNode1 = AVG (divisorNode); avgNode2 = AVG (dividendNode).
[0115] If we use code language to describe the process of creating the average node avgNode1, it can be expressed as:
[0116] avgNode1 = new Node().setOperator("avg").setSubNodes(divisorNode), which creates a new node (avgNode1) and sets its operator (Operator) to "avg" (indicating the averaging operation). It sets divisorNode (i.e. the divisor node) as the child node (SubNodes) of this averaging node, which means that avgNode1 represents the operation of averaging the values represented by divisorNode.
[0117] If we use code language to describe the process of creating the average node avgNode2, it can be expressed as:
[0118] avgNode2 = new Node().setOperator("avg").setSubNodes(dividendNode), which creates a new node (avgNode2) and sets its operator (Operator) to "avg" (indicating the averaging operation). It sets dividendNode (the dividend node) as the child node (SubNodes) of this averaging node, which means that avgNode2 represents the operation of averaging the values represented by dividendNode.
[0119] After obtaining the averaging nodes avgNode1 and avgNode2, a new division operation node divideNode2 needs to be encapsulated to represent AVG (divisorNode) / AVG (dividendNode). Specifically, the operator of the division node divideNode2 is "divide", which takes the avgNode1 and avgNode2 created in the above embodiment as its child nodes, and then the divideNode2 node can represent first averaging the original divisor and dividend, respectively, and then performing the division operation.
[0120] Optionally, if the process of creating the division node divideNode2 is described in code language, it can be expressed as: divideNode2 = newNode().setOperator("divide").setSubNodes([avgNode1,avgNode2]), that is, a new node (divideNode2) is created and its operator is set to "divide" (indicating a division operation). It uses the two averaging nodes (avgNode1 and avgNode2) created previously as child nodes of this division node, which means that divideNode2 represents an operation, namely avgNode1 divided by avgNode2.
[0121] In some optional embodiments, after obtaining the new division node divideNode2, avgNode in the AST may be replaced with divideNode2, so that the original average value calculation may be converted into an expression that first calculates the average value and then performs a division operation.
[0122] In some optional embodiments, after replacing avgNode in AST with divideNode2, the replaced AST can be converted back to SQL statements by implementing the Node node toSql method. For example, the toSql method can be expressed as: divideNode2 = avgNode1.toSql() + " / " + avgNode2.toSql(), so that the purpose of converting avg(A / B) to AVG(A) / AVG(B) can be achieved. Applied to the example shown in Table 1, the calculation method of the defect resolution rate can be replaced from (0.5+0.75) / 2=0.625 to (1+6) / (2+8)=0.7 to meet actual business needs.
[0123] It can be seen that the technical solutions of the above embodiments of the present application can automatically parse structured operation statements, intelligently identify and encapsulate specific function parameters, so as to dynamically adjust the data processing logic, thereby significantly improving the efficiency of data processing, and better adapting to rapidly changing data processing needs, thereby improving the accuracy of data calculation in database reports.
[0124] It should be noted that although the steps of the method in the present application are described in a specific order in the drawings, this does not require or imply that the steps must be performed in this specific order, or that all the steps shown must be performed to achieve the desired results. Additionally or alternatively, some steps may be omitted, multiple steps may be combined into one step, and / or one step may be decomposed into multiple steps, etc.
[0125] The following introduces an apparatus embodiment of the present application, which can be used to execute the data processing method in the above-mentioned embodiment of the present application. Fig. 9 The structure block diagram of the data processing device provided in the embodiment of the present application is schematically shown. Fig. 9 As shown, the data processing device 900 may include:
[0126] The parsing module 910 is configured to parse the first structured query statement to obtain a first operator sequence, where the first operator sequence includes a plurality of operators executed in sequence, and the first structured query statement is used to perform a first data operation on at least two data dimensions in a multidimensional database according to the plurality of operators executed in sequence;
[0127] An adjustment module 920, configured to adjust the execution order of at least one operator in the first operator sequence to obtain a second operator sequence;
[0128] A generating module 930 is configured to generate a second structured query statement according to the second operator sequence, and replace the first structured query statement with the second structured query statement;
[0129] The execution module 940 is configured to execute a second data operation on at least two data dimensions in the multidimensional database according to the second structured query statement.
[0130] In some embodiments of the present application, based on the above technical solution, the adjustment module 920 may further include:
[0131] A selection module is configured to select a first data dimension and a second data dimension whose execution order is to be adjusted from the at least two data dimensions;
[0132] an identification module configured to identify, in the first operator sequence, a correspondence between operators and data dimensions, and obtain a first operator corresponding to the first data dimension and a second operator corresponding to the second data dimension;
[0133] The exchange module is configured to exchange the execution order of the first operator and the second operator in the first operator sequence to obtain a second operator sequence.
[0134] In some embodiments of the present application, based on the above technical solution, the multidimensional database is a relational database comprising two data dimensions, the first data dimension represents data rows in the relational database, and the second data dimension represents data columns in the relational database; the identification module is further configured to: when the operand of the operator is a data item located in the same data row, determine the operator as a first operator corresponding to the first data dimension; when the operand of the operator is a data item located in the same data column, determine the operator as a second operator corresponding to the second data dimension.
[0135] In some embodiments of the present application, based on the above technical solution, the first operator is used to calculate the ratio of two data items in the same data row, and the second operator is used to calculate the average value of multiple data items in the same data column.
[0136] In some embodiments of the present application, based on the above technical solution, the parsing module 910 can be further configured to: parse the first structured query statement to obtain a grammatical structure corresponding to the first structured query statement; traverse the grammatical structure to obtain a first operator sequence composed of multiple grammatical nodes in the grammatical structure.
[0137] In some embodiments of the present application, based on the above technical solution, the generating module 930 may further include:
[0138] A parameter object acquisition module, configured to acquire a parameter object of the first structured query statement from the grammatical structure, wherein the parameter object is used to represent a data range for performing data operations on a multidimensional database;
[0139] The parameter object encapsulation module is configured to encapsulate the parameter object according to the second operator sequence to obtain a second structured query statement for replacing the first structured query statement.
[0140] In some embodiments of the present application, based on the above technical solution, the parameter object encapsulation module includes:
[0141] an operation expression generating module, configured to generate at least one operation expression for the parameter object according to the second operator included in the second operator sequence;
[0142] The second structured query statement generating module is configured to generate a second structured query statement according to the first operator included in the second operator sequence and the at least one operation expression.
[0143] In some embodiments of the present application, based on the above technical solution, the first operator is used to calculate the ratio of the parameter object, the parameter object includes a first field parameter and a second field parameter; the second operator is used to calculate the average value of the parameter object; the generating at least one operation expression for the parameter object according to the second operator included in the second operator sequence includes: generating a first average value operation expression for the first field parameter and a second average value operation expression for the second field parameter according to the second operator included in the second operator sequence;
[0144] The generating of the second structured query statement according to the first operator included in the second operator sequence and the at least one operation expression includes: generating a ratio expression between the first averaging operation expression and the second averaging operation expression according to the first operator included in the second operator sequence; and encapsulating the ratio expression to obtain the second structured query statement.
[0145] The specific details of the data processing device provided in each embodiment of the present application have been described in detail in the corresponding method embodiments and will not be repeated here.
[0146] Fig.10 The structure block diagram of a computer system for implementing an electronic device according to an embodiment of the present application is schematically shown.
[0147] It should be noted that Fig.10 The computer system 1000 of 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 application.
[0148] like Fig.10 As shown, the computer system 1000 includes a central processing unit 1001 (CPU), which can perform various appropriate actions and processes according to the program stored in the read-only memory 1002 (ROM) or the program loaded from the storage part 1008 to the random access memory 1003 (RAM). Various programs and data required for system operation are also stored in the random access memory 1003. The central processing unit 1001, the read-only memory 1002 and the random access memory 1003 are connected to each other through a bus 1004. The input / output interface 1005 (Input / Output interface, i.e., I / O interface) is also connected to the bus 1004.
[0149] The following components are connected to the input / output interface 1005: an input section 1006 including a keyboard, a mouse, etc.; an output section 1007 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 1008 including a hard disk, etc.; and a communication section 1009 including a network interface card such as a LAN card, a modem, etc. The communication section 1009 performs communication processing via a network such as the Internet. A drive 1010 is also connected to the input / output interface 1005 as needed. A removable medium 1011, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 1010 as needed, so that a computer program read therefrom is installed into the storage section 1008 as needed.
[0150] In particular, according to an embodiment of the present application, the process described in each method flow chart can be implemented as a computer software program. For example, an embodiment of the present application includes a computer program product, which includes a computer program carried on a computer readable medium, and the computer program contains a program code for executing the method shown in the flow chart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 1009, and / or installed from the removable medium 1011. When the computer program is executed by the central processor 1001, various functions defined in the system of the present application are executed.
[0151] It should be noted that the computer-readable medium shown in the embodiment of the present application 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, a system, device or device of electricity, magnetism, light, electromagnetic, infrared, or semiconductor, 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), a 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 application, a computer-readable storage medium may be any tangible medium containing or storing a program, which may be used by an instruction execution system, device or device or used in combination with it. In the present application, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, wherein a computer-readable program code is carried. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, 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 programs 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 suitable medium, including but not limited to: wireless, wired, etc., or any suitable combination of the above.
[0152] 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 application. In this regard, each box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the above-mentioned module, program segment or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two 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 box in the block diagram or flow chart, and the combination of the boxes in the block diagram 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.
[0153] It should be noted that, although several modules or units of the equipment for action execution are mentioned in the above detailed description, this division is not mandatory. In fact, according to the embodiments of the present application, the features and functions of two or more modules or units described above can be embodied in one module or unit. On the contrary, the features and functions of one module or unit described above can be further divided into being embodied by multiple modules or units.
[0154] Through the description of the above implementation methods, it is easy for those skilled in the art to understand that the example implementation methods described here can be implemented by software or by combining software with necessary hardware. Therefore, the technical solution according to the implementation methods of the present application can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, and includes several instructions to enable a computing device (which can be a personal computer, a server, a touch terminal, or a network device, etc.) to execute the method according to the implementation methods of the present application.
[0155] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the invention disclosed herein. The present application is intended to cover any modification, use or adaptation of the present application, which follows the general principles of the present application and includes common knowledge or customary technical means in the art that are not disclosed in the present application.
[0156] It should be understood that the present application is not limited to the precise structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present application is limited only by the appended claims.< / node>
Claims
1. A data processing method, characterized in that: The method comprises: Parsing a first structured query statement to obtain a first operator sequence, wherein the first operator sequence includes a plurality of operators executed in sequence, and the first structured query statement is used to perform a first data operation on at least two data dimensions in a multidimensional database according to the plurality of operators executed in sequence; adjusting the execution order of at least one operator in the first operator sequence to obtain a second operator sequence; generating a second structured query statement according to the second operator sequence, and replacing the first structured query statement with the second structured query statement; According to the second structured query statement, a second data operation is performed on at least two data dimensions in the multidimensional database.
2. The data processing method according to claim 1, characterized in that: The adjusting the execution order of at least one operator in the first operator sequence comprises: From the at least two data dimensions, select a first data dimension and a second data dimension whose execution order is to be adjusted; In the first operator sequence, a correspondence between operators and data dimensions is identified to obtain a first operator corresponding to the first data dimension and a second operator corresponding to the second data dimension; In the first operator sequence, the execution order of the first operator and the second operator is exchanged to obtain a second operator sequence.
3. The data processing method according to claim 2, characterized in that: The multidimensional database is a relational database including two data dimensions, wherein the first data dimension represents data rows in the relational database, and the second data dimension represents data columns in the relational database; The corresponding relationship between the identification operator and the data dimension includes: When the operands of the operator are data items located in the same data row, determining the operator as a first operator corresponding to the first data dimension; When the operands of the operator are data items located in the same data column, the operator is determined as a second operator corresponding to the second data dimension.
4. The data processing method according to claim 3, characterized in that: The first operator is used to calculate the ratio of two data items in the same data row, and the second operator is used to calculate the average value of multiple data items in the same data column.
5. The data processing method according to any one of claims 1 to 4, characterized in that: The parsing of the first structured query statement includes: Parsing the first structured query statement to obtain a grammatical structure corresponding to the first structured query statement; The grammatical structure is traversed to obtain a first operator sequence consisting of a plurality of grammatical nodes in the grammatical structure.
6. The data processing method according to claim 5, characterized in that: Generating a second structured query statement according to the second operator sequence includes: Acquire a parameter object of the first structured query statement from the grammatical structure, the parameter object being used to represent a data range for performing data operations on a multidimensional database; The parameter object is encapsulated according to the second operator sequence to obtain a second structured query statement for replacing the first structured query statement.
7. The data processing method according to claim 6, characterized in that: The encapsulating the parameter object according to the second operator sequence includes: generating at least one operation expression for the parameter object according to the second operator included in the second operator sequence; A second structured query statement is generated according to the first operator included in the second operator sequence and the at least one operation expression.
8. The data processing method according to claim 7, characterized in that: The first operator is used to calculate the ratio of the parameter object, the parameter object includes a first field parameter and a second field parameter; the second operator is used to calculate the average value of the parameter object; and generating at least one operation expression for the parameter object according to the second operator included in the second operator sequence includes: Generate a first averaging operation expression for the first field parameter and a second averaging operation expression for the second field parameter according to a second operator included in the second operator sequence; Generating a second structured query statement according to the first operator included in the second operator sequence and the at least one operation expression includes: generating a ratio expression between the first averaging operation expression and the second averaging operation expression according to the first operator included in the second operator sequence; The ratio expression is encapsulated to obtain a second structured query statement.
9. A computer-readable medium, characterized in that The computer-readable medium stores a computer program, and when the computer program is executed by a processor, the data processing method according to any one of claims 1 to 8 is implemented.
10. An electronic device, characterized in that: include: processor; as well as A memory, configured to store executable instructions of the processor; The processor is configured to execute the executable instructions to implement the data processing method as described in any one of claims 1 to 8.