CN114661747A - Index calculation method and device, storage medium and computer equipment - Google Patents

Index calculation method and device, storage medium and computer equipment Download PDF

Info

Publication number
CN114661747A
CN114661747A CN202210204164.0A CN202210204164A CN114661747A CN 114661747 A CN114661747 A CN 114661747A CN 202210204164 A CN202210204164 A CN 202210204164A CN 114661747 A CN114661747 A CN 114661747A
Authority
CN
China
Prior art keywords
index
calculation
expression
configuration information
access
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202210204164.0A
Other languages
Chinese (zh)
Inventor
黄容萍
黄强存
贺南芳
李美平
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Yuanguang Software Co Ltd
Original Assignee
Yuanguang Software Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Yuanguang Software Co Ltd filed Critical Yuanguang Software Co Ltd
Priority to CN202210204164.0A priority Critical patent/CN114661747A/en
Publication of CN114661747A publication Critical patent/CN114661747A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/242Query formulation
    • G06F16/2433Query languages
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/22Indexing; Data structures therefor; Storage structures
    • G06F16/2282Tablespace storage structures; Management thereof
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/25Integrating or interfacing systems involving database management systems
    • G06F16/254Extract, transform and load [ETL] procedures, e.g. ETL data flows in data warehouses
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/166Editing, e.g. inserting or deleting
    • G06F40/177Editing, e.g. inserting or deleting of tables; using ruled lines
    • G06F40/18Editing, e.g. inserting or deleting of tables; using ruled lines of spreadsheets
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q40/00Finance; Insurance; Tax strategies; Processing of corporate or income taxes
    • G06Q40/12Accounting
    • G06Q40/125Finance or payroll

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Databases & Information Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Business, Economics & Management (AREA)
  • Finance (AREA)
  • Data Mining & Analysis (AREA)
  • Accounting & Taxation (AREA)
  • Computational Linguistics (AREA)
  • General Health & Medical Sciences (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • Artificial Intelligence (AREA)
  • Health & Medical Sciences (AREA)
  • Software Systems (AREA)
  • Development Economics (AREA)
  • Economics (AREA)
  • Marketing (AREA)
  • Strategic Management (AREA)
  • Technology Law (AREA)
  • General Business, Economics & Management (AREA)
  • Mathematical Physics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The embodiment of the application discloses an index calculation method, an index calculation device, a storage medium and computer equipment, and relates to the field of data processing. The method of the present application comprises: after the configuration information table is analyzed, determining an access expression, a source table and a target table; converting the access expression into an SQL statement according to a regular expression; executing the SQL statement, taking data from the source table, and calculating according to the obtained numerical value to obtain a calculation result; the calculation result is inserted into the target table, the access expression of the index can be adjusted according to actual requirements, the code logic of the SQL is not required to be adjusted, the coding amount of the SQL statement is greatly reduced, and the development efficiency is greatly improved.

Description

Index calculation method and device, storage medium and computer equipment
Technical Field
The present application relates to the field of data processing, and in particular, to an index calculation method, apparatus, storage medium, and computer device.
Background
Financial statements, accounting or budget subjects are the most common data sources, and the index results are usually calculated based on the 3 types of business entities. In actual business, the items and formats of financial statements are irregularly (usually year-by-year) adjusted according to the needs of operation management, and although accounting subjects and budget subjects are relatively stable, adjustment also exists. When data in the source table is adjusted, in order to ensure accuracy of an index calculation result, it is necessary to adjust code logic of an index calculation SQL statement synchronously, and a developer needs to redesign the SQL (Structured Query Language) statement, which also brings a large amount of work for analyzing data operation and maintenance of application.
Disclosure of Invention
The embodiment of the application provides an index calculation method, an index calculation device, a storage medium and computer equipment, and can solve the problem of large workload when index calculation is performed in the prior art. The technical scheme is as follows:
in a first aspect, an embodiment of the present application provides an index calculation method, where the method includes:
after the configuration information table is analyzed, determining an access expression, a source table and a target table;
converting the data fetching expression into an SQL statement according to a regular expression;
executing the SQL statement, taking data from the source table, and calculating according to the obtained numerical value to obtain a calculation result;
inserting the calculation result into the target table.
In a second aspect, an embodiment of the present application provides an index calculation apparatus, including:
the analysis unit is used for determining the access expression, the source table and the target table after analyzing the configuration information table;
the conversion unit is used for converting the access expression into an SQL statement according to a regular expression;
the calculation unit is used for executing the SQL statement, taking data from the source table and calculating according to the obtained numerical value to obtain a calculation result;
an inserting unit, configured to insert the calculation result into the target table.
In a third aspect, embodiments of the present application provide a computer storage medium storing a plurality of instructions adapted to be loaded by a processor and to perform the above-mentioned method steps.
In a fourth aspect, an embodiment of the present application provides a computer device, which may include: a processor and a memory; wherein the memory stores a computer program adapted to be loaded by the processor and to perform the above-mentioned method steps.
The beneficial effects brought by the technical scheme provided by some embodiments of the application at least comprise:
first, a large amount of repeated development work is reduced. The financial index data is various and is stored in different reports and subjects, and when a single index is carried out for fetching, a plurality of similar ETL (Extract-Transform-Load) development works need to be repeated. The index is uniformly managed in a mode of index definition and index access expression configuration, and index value access or calculation is carried out by a method of converting the access expression into SQL by using the regular expression, so that the SQL statement is developed once, the index access expression can be increased or decreased as required, the coding amount of the SQL statement is reduced to a great extent, and the development efficiency is greatly improved. Secondly, supporting complex index calculation logic: regular expressions have strong flexibility and logicality and can quickly achieve complex control of character strings in an extremely simple mode. Therefore, the method and the device support flexible configuration of various complex index calculation logics in the access expression, such as multiple addition, subtraction, multiplication and division operations, PRE _ YEAR _ END and other time functions, and business personnel can configure the access expression, so that the workload of developers is reduced. Thirdly, adapting to variable access calibers: in order to meet the development needs of enterprise operation activities, financial statements, accounting subjects and budget subjects are correspondingly adjusted, which means that the access source and the access aperture of the index may also be changed. According to the method and the device, different access expressions are configured in different time periods of the same index through the start time and the end time in the configuration information table, and the change of the access aperture of the index is flexibly coped with.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present application, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
Fig. 1 is a schematic diagram of a network architecture provided by an embodiment of the present application;
FIG. 2 is a schematic flowchart of an index calculation method according to an embodiment of the present disclosure;
FIG. 3 is a schematic structural diagram of an index calculation apparatus provided in the present application;
fig. 4 is a schematic structural diagram of a computer device provided in the present application.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more clear, embodiments of the present application will be described in further detail below with reference to the accompanying drawings.
It should be noted that, the index calculation method provided in the present application is generally executed by a computer device, and accordingly, the index calculation apparatus is generally disposed in the computer device.
Fig. 1 shows an exemplary system architecture to which the index calculation method or the index calculation apparatus of the present application can be applied.
As shown in fig. 1, the system architecture may include: computer device 101 and server 102. Communication between computer device 101 and server 102 may be via a network, which is the medium used to provide the communication links between the various elements described above. The network may include various types of wired or wireless communication links, such as: the wired communication link includes an optical fiber, a twisted pair wire, or a coaxial cable, and the WIreless communication link includes a bluetooth communication link, a WIreless-FIdelity (Wi-Fi) communication link, or a microwave communication link, etc.
The server 102 is deployed with an SQL database, which is used to store a configuration information table, a source table and a target table, where the configuration information table is configuration information of one or more indexes, the source table is a table for storing source data, and the target table is a table for storing calculation results of the indexes, and according to the configuration information of the indexes in the configuration information table, the data read from the source table is operated to obtain a calculation result, and then the calculation result is inserted into the target table.
In view of the index processing and calculating method based on the financial statement, accounting subject and budget subject 3-class business entities in the financial field, a large number of repeated and similar model designs and SQL statement developments exist, and the requirement that the index data source can be quickly adjusted when the business entities change cannot be met under the condition that SQL statement code logic is not adjusted. The method utilizes the relatively regular index access logic of 3 types of business entities of financial statements, accounting subjects and budget subjects, and the regular expression has stronger flexibility, logicality and functionality, can quickly achieve complex control of character strings in a very simple mode.
It should be noted that the computer device 101 and the server 102 may be hardware or software. When the computer device 101 and the server 102 are hardware, they may be implemented as a distributed server cluster composed of a plurality of servers, or may be implemented as a single server. When the computer device 101 and the server 102 are software, they may be implemented as a plurality of software or software modules (for example, for providing distributed services), or may be implemented as a single software or software module, and are not limited in this regard.
Various communication client applications may be installed on the computer device of the present application, for example: video recording application, video playing application, voice interaction application, search application, instant messaging tool, mailbox client, social platform software, etc.
The computer device may be hardware or software. When the computer device is hardware, it may be various computer devices having a display screen, including but not limited to smart phones, tablet computers, laptop portable computers, desktop computers, and the like. When the computer device is software, the software may be installed in the computer device listed above. Which may be implemented as multiple software or software modules (e.g., to provide distributed services) or as a single software or software module, and is not particularly limited herein.
When the computer equipment is hardware, the computer equipment can also be provided with display equipment, the display equipment can display various equipment capable of realizing the display function, and the camera is used for collecting video streams; for example: the display device may be a cathode ray tube (CR) display, a light-emitting diode (LED) display, an electronic ink screen, a Liquid Crystal Display (LCD), a Plasma Display Panel (PDP), or the like. The user can utilize the display device on the computer device to view the displayed information such as characters, pictures, videos and the like.
It should be understood that the number of computer devices, networks, and servers in FIG. 1 is illustrative only. Any number of computer devices, networks, and servers are possible, as desired for an implementation.
The index calculation method provided by the embodiment of the present application will be described in detail below with reference to fig. 2. The index calculation device in the embodiment of the present application may be a computer device shown in fig. 1.
Please refer to fig. 2, which provides a flowchart of an index calculation method according to an embodiment of the present application. As shown in fig. 1, the method of the embodiment of the present application may include the steps of:
s201, determining an access expression, a source table and a target table after analyzing the configuration information table.
The configuration information table is used for storing configuration information of one or more indexes, the configuration information comprises an attribute value of the access expression, an attribute value of the source table and an attribute value of the target table, and the configuration information table can be stored in the SQL database. The attribute values of the mathematical expression comprise operators and numerical values, the attribute values of the source table comprise a source table name, an item ID of the source table and a measurement of the source table, and the attribute values of the target table comprise: a target table name and a set of metrics, the set of metrics including one or more metrics. The source table is a table for taking data, and the target table is a table for inserting calculation results.
Wherein, the source table contains the following fields: time, organization, item ID, item name, metric, the target table contains the following fields: time, organization, index ID, metric; further, the method is further provided with an index information table for representing the attribute of the index, and the index information table comprises the following fields: index ID, index name, index measurement unit, etc.
In one or more possible embodiments, the configuration information table includes configuration information for one or more metrics, the configuration information including the following fields: index ID, index name, metric set, fetch expression, target table name, start time, end time, and sequence number. The index ID represents an ID of an index that needs to be calculated; the index name represents the name of an index to be calculated; the measurement set includes one or more measurements used for inserting calculation results (calculation results, namely, values corresponding to the above-mentioned indexes, namely, index values) into the target table; taking a numerical expression as an expression for executing calculation; the target table name represents the name of the table into which the calculation result is inserted; the start time and the end time represent the valid time range of the counting expression in the configuration information table; the sequence number indicates the order of the index.
For example, the configuration information of a certain index in the configuration information table is shown in table 1:
Figure BDA0003530778200000041
TABLE 1
The number of the metric sets of the target table in table 1 is 4, and the metric sets respectively correspond to 1 access expression, that is, the number of the access expressions is also 4, and the access expressions are separated by commas, that is, the access expression for measuring BYSJ is: ($ (TWC _ CW _ REP _ KB,228, BYS) - $ (TWC _ CW _ REP _ KB,239, BYS))/1.16; the access expression for measuring BNLJ is as follows: ($ (TWC _ CW _ REP _ KB,228, BNLJ) - $ (TWC _ CW _ REP _ KB,239, BNLJ))/1.16; the mathematical expression for the metric SNLJ is: ($ (TWC _ CW _ REP _ KB,228, SNTQ) - $ (TWC _ CW _ REP _ KB,239, SNTQ))/1.16; the fetch expression for measuring BNYS is as follows: $ (TWC _ CW _ REP _ YY _ SDSRYS,31, BNYS _ SDJ) - $ (TWC _ CW _ REP _ YY _ GDCBYS,1, BNYS _ GDDJ _ BHS).
The number-taking expression comprises one or more calculation factors, two adjacent calculation factors are connected through operators, the operators can be +, -, ×, ÷ and the like, and each calculation factor comprises a locator, a source table name, an item ID of the source table and a measurement of the source table. For example: the calculation factor is $ (TWC _ CW _ REP _ DLCP _ ZYJYZBB,71, BYS), $ is the locator, TWC _ CW _ REP _ DLCP _ ZYJYZBB denotes the source table name, 71 denotes the item ID of the source table, BYS is the measure of the source table.
In one or more possible embodiments, the configuration information table has an editable function, and the user modifies or deletes the configuration information of the index according to the actual requirement by adding the configuration information of the index into the configuration information table. For example: the effective time range of the modification index, the access expression of the modification index, the metric set of the modification index and the like. And displaying a configuration interface, wherein a user can use an input device to perform configuration operation on the configuration information of each index in the configuration information table through the configuration interface, and the configuration operation comprises the steps of modifying the configuration information of the index, increasing the configuration information of the index and deleting the configuration information of the index, so that a visual editing function is realized, and the editing efficiency is improved.
It should be noted that, the data of the configuration information table, the source table, and the target table in the present application may be deployed in the same SQL database, or deployed in different SQL databases, which is not limited in the present application. Preferably, the source table and the target table are deployed in the same database, so that the data efficiency can be improved, and the security risk of cross-database access is reduced.
S202, converting the access expression into an SQL statement according to the regular expression.
The regular expression is a logic formula for operating character strings, namely a 'rule character string' is formed by using a plurality of specific characters defined in advance and a combination of the specific characters, and the 'rule character string' is used for expressing and filtering logic processing on the access expression so as to automatically generate SQL sentences.
In the method, when the source table is changed, the change of the access expression is realized by editing the configuration information table, at the moment, only a specific field in the regular expression needs to be modified to match the change of the access expression, and then, the SQL sentence is automatically generated according to the changed access expression.
In one or more possible embodiments, a method of converting an SQL statement comprises:
splitting according to the locators in the access expression to obtain a plurality of calculation factors;
converting each calculation factor into a calculation field;
and obtaining the SQL statement according to all the calculation fields.
For example, the fetch expression is expressed as:
($ (TWC _ CW _ REP _ KB,228, BYS) - $ (TWC _ CW _ REP _ KB,239, BYS))/1.16), ($ (TWC _ CW _ REP _ KB,228, BNLJ) - $ (TWC _ CW _ REP _ KB,239, BNLJ))/1.16, ($ (TWC _ CW _ REP _ KB,228, SNTQ) - $ (TWC _ CW _ REP _ KB,239, SNTQ))/1.16, $ (TWC _ CW _ REP _ YY _ SDSRYS,31, BNYS _ SDJ) - $ (TWC _ CW _ YY _ GDCBYS,1, BNYS _ DJGDBHS) 1.13, ((TWC _ CW _ REP _ DLCP _ ZYZYZJLBB), 71, BNCWJCW _ REP _ JGYZYZBB, BNTYZYZYZQ _ SNTQ), SNTYZYZYZYZYZQ _ SNTYZQ _ 1, SNTYZYZQ), and (TWC _ REP _ CW _ REP _ YZYZYZYZYZYZYZYZBB, 71, BNTYZYZYZYZYZYZYZYZYZYZYZYZQ, SNTYZYZYZYZQ, 31, BNTYZYZYZYZYZYZYZYZYZYZQ, 31, BNTYZYZYZYZYZYZYZYZYZYZYZYZYZYZYZYZYZYZYZYZYZYZYZYZYZYZYZBQ, 71, BNTYZYZYZYZYZYZYZYZYZYZYZYZYZYZYZYZYZYZYZYZYZYZYZYZBYZYZYZBYZBQ, TWC, SNTYZYZTZBYZYZYZBYZBYZBYZBYZBYZYZYZBYZBYZYZBYZBYZBYZBYZBYZBYZBYZBYZK, 31, TWC _ SNTYZBYZYZBYZBYZBYZBYZBYZBYZBYZBYZBYZBYZBYZBYZBYZBYZBYZBYZBYZBYZK, TWC, SNTZBYZBYZBYZBYZBYZBYZBYZBYZBYZBYZBYZBYZBYZK, 31, TWC, 31, TWC, SNTYZYZYZYZYZYZYZYZYZYZYZYZYZYZYZYZYZYZYZYZYZYZYZYZYZYZYZYZYZYZYZYZYZYZYZYZYZYZYZYZYZYZYZYZYZYZYZYZYZYZYZYZYZ, 1, bnys _ GDDJ _ BHS), the locator is $, the fetch expression is identified to contain 8 calculation factors according to the locator, and the fetch expression is split according to the following SQL statement:
Figure BDA0003530778200000051
the inputs of the above SQL are the index ID and the index expression, and the subquery returns all the strings matching the regular expression in the index expression by using the REGEXP _ MATCHES function. And outputting the index ID and the calculation factor of each part of the index expression.
And replacing the sub-character strings matched with the regular expression by the outer layer query by using a REGEXP _ REPLACE function, wherein '\\ \ 1' represents that the part matched with the 1 st circularconvert sub-expression in the source character string is replaced.
The output index ID, the line number, the calculation factor of each part of the index expression, the table name of each calculation factor, and the date condition (being empty is the current month).
The results obtained by running the above SQL statements are shown in table 2:
Figure BDA0003530778200000052
Figure BDA0003530778200000061
TABLE 2
As can be seen from table 2, the final split results in 8 calculation factors, each distinguished by a locator $.
Further, the calculation factors in table 2 are converted into calculation fields by regular expressions, and the calculation factors and the calculation fields are in a one-to-one correspondence relationship. For example: the factors will be calculated: ' $ (TWC _ CW _ REP _ KB,228, BYS) SQL code that converts to compute fields is as follows:
Figure BDA0003530778200000062
the input of the SQL is a calculation factor for each part of the index expression, then a REGEX P _ REPLACE function is used for replacing the sub-character strings matched with the regular expression with new character strings, "\\ \ 1" represents that the part matched with the 1 st circular bracket sub-expression in the source character string is replaced, and "\ \ 2" and the like. SQL outputs a spliced summing script and the line number of the report. The resulting structure is shown in table 3:
regexp_replace text regexp_replace text
1 SUM(CASE WHEN TEXT(ITEMID)=`228`THEN BYS::NUMERIC ELSE O END) 228
TABLE 3
Further, all the calculation fields are used for obtaining an SQL statement of the calculation formula, and the SQL statement is used for generating a calculation result.
For example, the SQL statement of the calculation formula obtained from the converted calculation fields in table 2 is:
(COALESCE(COL1,0)-COALESCE(COL2,0))/1.16,
(COALESCE(COL3,0)-COALESCE(COL4,0))/1.16,
(COALESCE(COL5,0)-COALESCE(COL6,0))/1.16,
COALESCE(COL7,0)-COALESCE(COL8,0)
s203, executing the SQL statement, taking data from the source table, and calculating according to the obtained numerical value to obtain a calculation result.
And S204, inserting the calculation result into the target table.
For example, the SQL statement that inserts the computation result into the target table is:
Figure BDA0003530778200000063
Figure BDA0003530778200000071
the SQL is the SQL with indexes analyzed and spliced through the previous steps, the SQL obtains bysj, bnlj and snlj from the snapshot and bnys from the budget report, and the result of the SQL statement query is inserted into the DWCW. And finishing the data extraction of one index.
The fields of the SQL output (i.e., the insert target table) are: rq, organid, itemid, bysj, bnlj, snlj, bnys.
The situation of the calculation result inserted into the target table is shown in table 3:
rq organid itemid bysj bnlj snlj bnys
2019-1-31 202 15 167.849741 186.666002 180.959961 208.6307
2019-1-31 300 15 172.79326 165.097018 162.084756 180.2754
2019-1-31 377 15 152.831593 144.410819 160.754767 137.8705
2019-1-31 514 15 118.496993 128.212055 127.358406 184.7403
2019-1-31 636 15 251.545647 258.291326 231.099105 283.5723
TABLE 3
According to the embodiment of the application, financial index data are various and are stored in different reports and subjects, and when a single index is carried out for fetching, a plurality of similar ETL development works need to be repeated. The index is uniformly managed in a mode of access expression configuration, index numerical access or calculation is carried out by a method of converting the access expression into the SQL by using the regular expression, so that the SQL sentence is developed only once, the access expression of the index can be adjusted according to actual requirements, the coding amount of the SQL sentence is reduced to a great extent, and the development efficiency is greatly improved.
The following are embodiments of the apparatus of the present application that may be used to perform embodiments of the method of the present application. For details which are not disclosed in the embodiments of the apparatus of the present application, reference is made to the embodiments of the method of the present application.
Referring to fig. 3, a schematic structural diagram of an index calculation apparatus provided in an exemplary embodiment of the present application is shown, which is hereinafter referred to as an apparatus 3. The apparatus 3 may be implemented as all or part of a computer device, in software, hardware or a combination of both. The apparatus 3 comprises: analysis section 301, conversion section 302, calculation section 303, and insertion section 304.
The analysis unit 301 is configured to determine an access expression, a source table, and a target table after analyzing the configuration information table;
a conversion unit 302, configured to convert the access expression into an SQL statement according to a regular expression;
a calculating unit 303, configured to execute the SQL statement, obtain a value from the source table, and calculate according to the obtained value to obtain a calculation result;
an inserting unit 304, configured to insert the calculation result into the target table.
In one or more possible embodiments, the access expression includes one or more calculation factors, and an operator is arranged between two adjacent calculation factors; each calculation factor includes a locator, a source table name, an entry ID of the source table, and a metric of the source table.
In one or more possible embodiments, the calculation factor supports the use of a time function for obtaining data for a specified time range in the source table.
In one or more possible embodiments, the configuration information table includes configuration information of at least one index, the configuration information including an index ID, an index name, a set of metrics, an access expression, a target table name, a start time, an end time, and a sequence number.
In one or more possible embodiments, the converting the access expression into an SQL statement according to a regular expression includes:
splitting the access expression into a plurality of calculation factors according to the locator;
converting all the calculation factors into calculation fields;
and generating SQL sentences of the calculation formulas according to the calculation fields.
In one or more possible embodiments, the method further comprises:
the configuration unit is used for displaying a configuration interface and executing configuration operation on the configuration information table through the configuration interface; wherein the configuration operation comprises modifying configuration information of the index, deleting configuration information of the index or adding configuration information of the index.
In one or more possible embodiments, modifying the configuration information of the metric includes: modifying one or more of the set of metrics, modifying the access expression, modifying the start time, and modifying the end time.
It should be noted that, when the apparatus 3 provided in the foregoing embodiment executes the index calculation method, only the division of the functional modules is illustrated, and in practical applications, the functions may be distributed by different functional modules according to needs, that is, the internal structure of the device may be divided into different functional modules to complete all or part of the functions described above. In addition, the index calculation apparatus and the index calculation method provided by the above embodiments belong to the same concept, and details of implementation processes thereof are referred to in the method embodiments and are not described herein again.
The above-mentioned serial numbers of the embodiments of the present application are merely for description and do not represent the merits of the embodiments.
An embodiment of the present application further provides a computer storage medium, where the computer storage medium may store a plurality of instructions, where the instructions are suitable for being loaded by a processor and executing the method steps in the embodiment shown in fig. 2, and a specific execution process may refer to a specific description of the embodiment shown in fig. 2, which is not described herein again.
The present application further provides a computer program product, which stores at least one instruction, and the at least one instruction is loaded and executed by the processor to implement the index calculation method according to the above embodiments.
Referring to fig. 4, a schematic structural diagram of a computer device is provided in an embodiment of the present application. As shown in fig. 4, the computer device 400 may include: at least one processor 401, at least one network interface 404, a user interface 403, memory 405, at least one communication bus 402.
Wherein a communication bus 402 is used to enable connective communication between these components.
The user interface 403 may include a Display screen (Display) and a Camera (Camera), and the optional user interface 403 may also include a standard wired interface and a wireless interface.
The network interface 404 may optionally include a standard wired interface, a wireless interface (e.g., WI-FI interface), among others.
Processor 401 may include one or more processing cores, among others. The processor 401 interfaces with various components throughout the computer device 400 using various interfaces and lines to perform various functions of the computer device 400 and process data by executing or executing instructions, programs, code sets, or instruction sets stored in the memory 405 and invoking data stored in the memory 405. Alternatively, the processor 401 may be implemented in at least one hardware form of Digital Signal Processing (DSP), Field-Programmable gate Array (FPGA), and Programmable Logic Array (PLA). The processor 401 may integrate one or more of a Central Processing Unit (CPU), a Graphics Processing Unit (GPU), a modem, and the like. Wherein, the CPU mainly processes an operating system, a user interface, an application program and the like; the GPU is used for rendering and drawing the content required to be displayed by the display screen; the modem is used to handle wireless communications. It is understood that the modem may not be integrated into the processor 401, but may be implemented by a single chip.
The Memory 405 may include a Random Access Memory (RAM) or a Read-Only Memory (Read-Only Memory). Optionally, the memory 405 includes a non-transitory computer-readable medium. The memory 405 may be used to store instructions, programs, code sets, or instruction sets. The memory 405 may include a stored program area and a stored data area, wherein the stored program area may store instructions for implementing an operating system, instructions for at least one function (such as a touch function, a sound playing function, an image playing function, etc.), instructions for implementing the various method embodiments described above, and the like; the storage data area may store data and the like referred to in the above respective method embodiments. The memory 405 may alternatively be at least one storage device located remotely from the aforementioned processor 401. As shown in fig. 4, the memory 405, which is a type of computer storage medium, may include therein an operating system, a network communication module, a user interface module, and an application program.
In the computer device 400 shown in fig. 4, the user interface 403 is mainly used as an interface for providing input for a user, and acquiring data input by the user; the processor 401 may be configured to call the application program stored in the memory 405 and specifically execute the method shown in fig. 2, and the specific process may refer to fig. 2 and is not described herein again.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by a computer program, which can be stored in a computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. The storage medium can be a magnetic disk, an optical disk, a read-only memory or a random access memory.
The above disclosure is only for the purpose of illustrating the preferred embodiments of the present application and is not to be construed as limiting the scope of the present application, so that the present application is not limited thereto, and all equivalent variations and modifications can be made to the present application.

Claims (10)

1. A method of calculating an index, comprising:
after the configuration information table is analyzed, determining an access expression, a source table and a target table;
converting the access expression into an SQL statement according to a regular expression;
executing the SQL statement, taking data from the source table, and calculating according to the obtained numerical value to obtain a calculation result;
inserting the calculation result into the target table.
2. The method according to claim 1, wherein the mathematical expression includes one or more calculation factors, and an operator is provided between two adjacent calculation factors; each calculation factor includes a locator, a source table name, an entry ID of the source table, and a metric of the source table.
3. The method of claim 2, wherein a calculation factor supports the use of a time function that is used to obtain data for a specified time range in the source table.
4. The method of claim 1, 2 or 3, wherein the configuration information table comprises configuration information of at least one index, and the configuration information comprises an index ID, an index name, a metric set, a fetch expression, a target table name, a start time, an end time, and a sequence number.
5. The method of claim 3, wherein converting the access expression into an SQL statement according to a regular expression comprises:
splitting the access expression into a plurality of calculation factors according to the locator;
converting all the calculation factors into calculation fields;
and generating SQL sentences of the calculation formulas according to the calculation fields.
6. The method of claim 1, 2 or 5, wherein the parsing the configuration information table before determining the access expression, the source table and the target table further comprises:
displaying a configuration interface, and executing configuration operation on the configuration information table through the configuration interface; wherein the configuration operation comprises modifying configuration information of the index, deleting configuration information of the index or adding configuration information of the index.
7. The method of claim 6, wherein modifying configuration information for metrics comprises: modifying one or more of the set of metrics, modifying the access expression, modifying the start time, and modifying the end time.
8. An index calculation apparatus, comprising:
the analysis unit is used for determining the access expression, the source table and the target table after analyzing the configuration information table;
the conversion unit is used for converting the access expression into an SQL statement according to a regular expression;
the calculation unit is used for executing the SQL statement, taking data from the source table and calculating according to the obtained numerical value to obtain a calculation result;
an inserting unit, configured to insert the calculation result into the target table.
9. A computer storage medium, characterized in that it stores a plurality of instructions adapted to be loaded by a processor and to carry out the method steps according to any one of claims 1 to 7.
10. A computer device, comprising: a processor and a memory; wherein the memory stores a computer program adapted to be loaded by the processor and to perform the method steps of any of claims 1 to 7.
CN202210204164.0A 2022-03-03 2022-03-03 Index calculation method and device, storage medium and computer equipment Pending CN114661747A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210204164.0A CN114661747A (en) 2022-03-03 2022-03-03 Index calculation method and device, storage medium and computer equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210204164.0A CN114661747A (en) 2022-03-03 2022-03-03 Index calculation method and device, storage medium and computer equipment

Publications (1)

Publication Number Publication Date
CN114661747A true CN114661747A (en) 2022-06-24

Family

ID=82028153

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210204164.0A Pending CN114661747A (en) 2022-03-03 2022-03-03 Index calculation method and device, storage medium and computer equipment

Country Status (1)

Country Link
CN (1) CN114661747A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115759019A (en) * 2022-11-15 2023-03-07 广州天维信息技术股份有限公司 Business data calculation method and device, storage medium and computer equipment

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115759019A (en) * 2022-11-15 2023-03-07 广州天维信息技术股份有限公司 Business data calculation method and device, storage medium and computer equipment
CN115759019B (en) * 2022-11-15 2023-10-20 广州天维信息技术股份有限公司 Service data calculation method, device, storage medium and computer equipment

Similar Documents

Publication Publication Date Title
CN111177231B (en) Report generation method and report generation device
CN108027833B (en) Method for creating structured data language query
US9460083B2 (en) Interactive dashboard based on real-time sentiment analysis for synchronous communication
US9690775B2 (en) Real-time sentiment analysis for synchronous communication
CN109376153B (en) System and method for writing data into graph database based on NiFi
CN111125064B (en) Method and device for generating database schema definition statement
CN110689268A (en) Method and device for extracting indexes
CN110837356A (en) Data processing method and device
CN114661747A (en) Index calculation method and device, storage medium and computer equipment
CN113900944A (en) Logic verification method and device applied to Flink SQL
CN112364617A (en) File information processing method and device, electronic equipment and storage medium
CN116450723A (en) Data extraction method, device, computer equipment and storage medium
CN112541718B (en) Material processing method and device
CN114817297A (en) Method and device for processing data
CN113760240A (en) Method and device for generating data model
CN113609128A (en) Method and device for generating database entity class, terminal equipment and storage medium
CN113760969A (en) Data query method and device based on elastic search
CN111078230A (en) Code generation method and device
CN110309062A (en) Case generation method, device, electronic equipment and storage medium
US20240104297A1 (en) Analysis of spreadsheet table in response to user input
CN111127077A (en) Recommendation method and device based on stream computing
CN111523295B (en) Data rendering method, device, medium and electronic equipment
CN113760945A (en) Method and device for auditing SQL (structured query language) statements
CN117892704A (en) Chart generation method, system, terminal and readable storage medium
CN116185380A (en) Method, equipment and storage medium for realizing static report designer based on luckyleet

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination