Computing engine running result comparison method and device, equipment and storage medium
By using a column feature value calculation algorithm during the calculation engine change process, the memory overflow problem caused by sorting the calculation engine result table was solved, and efficient and accurate result consistency checks were achieved.
Patent Information
- Application Number
- CN202310791570.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-29
- Publication Date
- 2026-11-27
- Estimated Expiration
- 2043-06-29
AI Technical Summary
During the process of changing computing engines, when existing technologies need to compare the result tables of the old and new computing engines, they need to sort by primary key. When the amount of computation and data is large, it may cause memory overflow and affect the speed of checking.
The algorithm uses a preset column feature value calculation algorithm to calculate the column feature values of the result table based on the primary key column. It determines the consistency of the results by comparing the column feature values, eliminating the need for sorting and reading all the data, thus reducing memory usage.
It improves data comparison efficiency, avoids memory overflow, and ensures the accuracy and speed of data comparison.
Smart Images

Figure CN116842038B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data processing, and in particular to a method, apparatus, device, and storage medium for comparing the results of a computing engine operation. Background Technology
[0002] With the development of SQL computing engines, not only are there new iterations of the same computing engine with faster performance and richer features, but entirely new computing engines are also emerging. In production environments, users have some existing SQL jobs running on older SQL computing engines, and they want to switch to newer SQL computing engines to achieve faster computing speeds. However, because different computing engines have changes in certain data logic processing, the logical execution results of some jobs on the new computing engine may be inconsistent with those on the old one. Users want to avoid changing the computing engine for these jobs with inconsistent results; therefore, it is necessary to determine whether the logical execution results of the same SQL job are consistent across different computing engines.
[0003] Currently, the common practice is to run the same SQL job using two different computing engines (old and new) and generate two result tables. Then, the data from both result tables is read into memory, and the two result tables are sorted by primary key. Finally, for a specific data column, the consistency of the data is compared row by row. Sorting the two result tables by primary key involves a large amount of computation, and the size of one result table may exceed the memory capacity of a machine. Reading the data from both result tables into memory can lead to memory overflow. Summary of the Invention
[0004] This application provides a method, apparatus, device, and storage medium for comparing the results of a computing engine, in order to solve the problem that when comparing result tables, two result tables need to be sorted according to the primary key, which involves a large amount of computation, and the data size of one result table may be larger than the memory of a machine, which may lead to memory overflow when reading the data of both result tables into memory.
[0005] Firstly, this application provides a method for comparing the results of computing engine operation, including:
[0006] Obtain the target SQL statement to be calculated;
[0007] The target SQL statement to be calculated is executed using a first calculation engine and a second calculation engine, respectively, and a first execution result table corresponding to the first calculation engine and a second execution result table corresponding to the second calculation engine are obtained; the first execution result table and the second execution result table include: primary key column and data column;
[0008] A preset column feature value calculation algorithm is used to calculate the column feature values of each data column in the first and second result tables based on the primary key column;
[0009] If it is determined that the column identifiers of the data columns in the first and second result tables are the same and the column characteristic values of the corresponding data columns are also the same, then it is determined that the first and second calculation engines produce consistent results for the target SQL statement.
[0010] Secondly, this application provides a device for comparing the results of a computing engine, comprising:
[0011] The acquisition module is used to acquire the target SQL statement to be calculated.
[0012] The execution module is used to run the target SQL statement to be calculated using a first calculation engine and a second calculation engine respectively, and to obtain a first execution result table corresponding to the first calculation engine and a second execution result table corresponding to the second calculation engine; the first execution result table and the second execution result table include: a primary key column and a data column;
[0013] The calculation module is used to calculate the column feature values of each data column in the first and second result tables based on the primary key column using a preset column feature value calculation algorithm.
[0014] The comparison module is used to determine that the execution results of the first calculation engine and the second calculation engine on the target SQL statement are consistent if the data column identifiers in the first execution result table and the corresponding column feature values in the second execution result table are the same.
[0015] Thirdly, this application provides an electronic device, including: a processor, and a memory and a transceiver communicatively connected to the processor;
[0016] The memory stores computer-executed instructions; the transceiver is used for sending and receiving data.
[0017] The processor executes the computer execution instructions stored in the memory to implement the method for comparing the running results of the computing engine as described in any of the above aspects.
[0018] Fourthly, this application provides a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, are used to implement the method for comparing the running results of the computing engine as described in any of the above aspects.
[0019] Fifthly, this application provides a computer program product, including computer execution instructions, which, when executed by a processor, implement the method for comparing the running results of a computing engine as described in any of the above aspects.
[0020] The method, apparatus, device, and storage medium for comparing the execution results of computing engines provided in this application obtain a target SQL statement to be calculated; run the target SQL statement using a first computing engine and a second computing engine respectively, and obtain a first execution result table corresponding to the first computing engine and a second execution result table corresponding to the second computing engine; the first and second execution result tables include: a primary key column and data columns; a preset column feature value calculation algorithm is used to calculate the column feature values of each data column in the first and second execution result tables based on the primary key column; if it is determined that the column feature values of the corresponding data columns with the same data column identifier are all the same in the first and second execution result tables, then it is determined that the execution results of the target SQL statement by the first and second computing engines are consistent. By calculating the column feature values of each column, the column feature values are inconsistent when any row of data in the column is inconsistent. By comparing the column feature values of each column, it is possible to determine whether the logical execution results of the same SQL job are consistent in different computing engines, without needing to sort the two result tables according to the primary key, avoiding memory overflow and improving data comparison efficiency. Furthermore, calculating the column characteristic values of each data column in the first and second result tables based on the primary key column ensures that the column characteristic values reflect the order of the data in each data column, thus guaranteeing the accuracy of data comparison. Attached Figure Description
[0021] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.
[0022] Figure 1 Flowchart of the method for comparing the running results of the computing engine provided in the embodiments of this application;
[0023] Figure 2 This is a schematic diagram comparing the running results of the computing engine provided in the embodiments of this application;
[0024] Figure 3 Flowchart of another method for comparing the running results of computing engines provided in this application embodiment;
[0025] Figure 4 A flowchart illustrating another method for comparing the running results of a computing engine, provided in an embodiment of this application;
[0026] Figure 5 This is a schematic diagram of the structure of the computing engine running result comparison device provided in the embodiments of this application;
[0027] Figure 6 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application.
[0028] The accompanying drawings illustrate specific embodiments of this application, which will be described in more detail below. These drawings and descriptions are not intended to limit the scope of the invention in any way, but rather to illustrate the concepts of this application to those skilled in the art through reference to particular embodiments. Detailed Implementation
[0029] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application as detailed in the appended claims.
[0030] The terms "first," "second," etc., are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. In the following descriptions of embodiments, "a plurality of" means two or more, unless otherwise explicitly defined.
[0031] First, the prior art involved in this invention will be described and analyzed in detail.
[0032] In modern software systems, SQL computing engines are widely used in scenarios involving large-scale table processing. With the development of SQL computing engines, not only are there new iterations of the same engine with faster performance and richer features, but entirely new computing engines are also emerging. For example, in the early stages, Hive, based on MapReduce, was the primary SQL computing engine. Subsequently, Spark, based on in-memory computing, offered faster processing speeds and gained increasing popularity, along with the emergence and widespread use of the FlinkSQL streaming computing engine.
[0033] In a production environment, users have some existing SQL jobs running on an older SQL computing engine. Users want to switch to a new SQL computing engine for faster computation speeds. However, due to changes in certain data logic processing across different computing engines, some jobs may produce inconsistent execution results on the new engine compared to the old one. Users want to avoid changing the computing engine for these jobs with inconsistent results. During the computing engine change process, it is necessary to quickly and effectively automatically check whether the logical execution results of the same SQL job are consistent across different computing engines.
[0034] Current industry-standard checks involve running the same SQL job using two different computing engines (one old and one new) to generate two result tables. The data from both tables is then loaded into memory and sorted by primary key. Finally, for each data column, row-by-row consistency is compared. This method is automated, requiring no manual intervention and offering high accuracy. However, it's unsuitable for scenarios with large result tables. The sorting process is computationally intensive. In big data computing scenarios, the size of a result table might exceed the memory capacity of a single machine. To prevent memory overflow, this type of check uses an external sorting algorithm, performing import / export operations between disk and memory during sorting, which is very time-consuming. Therefore, this method is slow when the result table contains a large amount of data.
[0035] The inventors discovered during their research that since consistency checks compare the entire data of two result tables, if any data in either result table is inconsistent, the check result will also be inconsistent. Therefore, by calculating the column characteristic values of each column, and noting that inconsistent column characteristic values occur when any row in a column is inconsistent, the consistency of the logical execution results of the same SQL job on different computing engines can be determined by comparing these column characteristic values. This eliminates the need to sort the two result tables by primary key, thus avoiding loading the data from both result tables into memory, preventing memory overflow, and improving data comparison efficiency.
[0036] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties. Furthermore, the collection, use and processing of the relevant data must comply with relevant laws, regulations and standards, and corresponding operation entry points are provided for users to choose to authorize or refuse.
[0037] It should be noted that the method, apparatus, device and storage medium for comparing the results of the computing engine operation of this application can be used in the field of big data technology, or in any field other than big data technology. The application field of the method, apparatus, device and storage medium for comparing the results of the computing engine operation of this application is not limited.
[0038] The technical solution of this application and how the technical solution of this application solves the above-mentioned technical problems are described in detail below with specific embodiments. These specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described again in some embodiments. The embodiments of this application will now be described with reference to the accompanying drawings.
[0039] Figure 1This is a flowchart illustrating a method for comparing computing engine execution results provided in this application embodiment. This application embodiment addresses the issue that comparing result tables requires sorting two result tables by primary key, resulting in a large computational load. Furthermore, the data size of one result table may exceed the memory capacity of a machine, potentially leading to memory overflow when reading data from both result tables into memory. This embodiment provides a method for comparing computing engine execution results. The method in this embodiment is applied to a computing engine execution result comparison device, which can be located in an electronic device. This electronic device can represent various forms of digital computers, such as laptops, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers.
[0040] like Figure 1 As shown, the specific steps of this method are as follows:
[0041] Step S101: Obtain the target SQL statement to be calculated.
[0042] In this embodiment, the target SQL statement is the SQL statement in the SQL job whose execution results are to be compared. The first and second computing engines can run the target SQL statement, obtain the execution results, and compare them.
[0043] Step S102: Use the first computing engine and the second computing engine to run the target SQL statement to be calculated, and obtain the first running result table corresponding to the first computing engine and the second running result table corresponding to the second computing engine.
[0044] The first and second result tables include a primary key column and data columns. The first and second calculation engines are two different SQL calculation engines whose results are being compared.
[0045] Specifically, the first computing engine is used to run the target SQL statement to be calculated to obtain the first running result table corresponding to the first computing engine, and the second computing engine is used to run the target SQL statement to be calculated to obtain the second running result table corresponding to the second computing engine.
[0046] Step S103: Calculate the column feature values of each data column in the first and second running result tables based on the primary key column using a preset column feature value calculation algorithm.
[0047] The embodiments of this application do not show the preset column feature value calculation algorithm used. It should be understood that the preset column feature value calculation algorithm determines the column feature value of each data column based on the combination of each row of data and the corresponding data in its primary key column.
[0048] For example, the data column whose column feature value is to be calculated may include three rows of data. The column feature value of the data column is determined based on the combination of the first row of data in the data column with the first row of data in the primary key column, the combination of the second row of data in the data column with the second row of data in the primary key column, and the combination of the third row of data in the data column with the third row of data in the primary key column.
[0049] This application does not limit the combination of each row of data with the corresponding data in its primary key column. For example, it can be addition or concatenation.
[0050] In this embodiment, calculating the column characteristic values of each data column in the first and second execution result tables based on the primary key column allows the column characteristic values to reflect the order of the data in each data column. For example, if the data in the first execution result table is 1, 1, 2, and the data in the second execution result table is 1, 2, 1; if the column characteristic values are not calculated based on the primary key column, the column characteristic values of the data columns in the first and second execution result tables will be the same; however, if the column characteristic values are calculated based on the primary key column, the column characteristic values of the data columns in the first and second execution result tables will be different.
[0051] It should be understood that if a value in a primary key column exists in one result table but not in another (i.e., data is missing), then the column characteristic values of each data column in the two result tables will be different. If the value in each row of the primary key column exists in both result tables, but the value of a corresponding data column in a data column is inconsistent in both result tables, then the table characteristic values of that data column in the two result tables will be different. The table characteristic values of each data column in the two result tables will be the same if and only if the value in each row of the primary key column exists in both result tables, and the values of the corresponding data columns in each data column are consistent in both result tables.
[0052] Step S104: If it is determined that the column feature values of the corresponding data columns in the first and second execution result tables are the same, then it is determined that the execution results of the first and second calculation engines on the target SQL statement are consistent.
[0053] In this embodiment of the application, if it is determined that there are different first and second execution result tables with the same column feature values for corresponding data columns, then it is determined that the execution results of the first and second calculation engines on the target SQL statement are inconsistent. If it is determined that the column feature values for corresponding data columns with the same column identifiers in both the first and second execution result tables are identical, then it is determined that the execution results of the first and second calculation engines on the target SQL statement are consistent.
[0054] For example, such as Figure 2As shown, a first computing engine and a second computing engine are used to run the target SQL statement to be calculated, and a first running result table corresponding to the first computing engine and a second running result table corresponding to the second computing engine are obtained. The first running result table and the second running result table include data column A, data column B, and data column C. If it is determined that the column feature value A of data column A in the first running result table is the same as the column feature value A of data column A in the second running result table, and the column feature value B of data column B in the first running result table is the same as the column feature value B of data column B in the second running result table, and the column feature value C of data column C in the first running result table is the same as the column feature value C of data column C in the second running result table, then it is determined that the running results of the first computing engine and the second computing engine on the target SQL statement are consistent.
[0055] In this embodiment, if the data in the first and second result tables are identical, differing only in order, then for a given data column, the column characteristic values in the first and second result tables will still be the same. The computational engine result comparison method provided in this embodiment does not require a specific data order in the result tables, avoiding the sorting operations required in existing methods, reducing computational load, and improving the efficiency of computational engine result comparison.
[0056] The method for comparing the execution results of computing engines provided in this application embodiment obtains the target SQL statement to be calculated; runs the target SQL statement using a first computing engine and a second computing engine respectively, and obtains a first execution result table corresponding to the first computing engine and a second execution result table corresponding to the second computing engine; the first and second execution result tables include: a primary key column and data columns; a preset column feature value calculation algorithm is used to calculate the column feature values of each data column in the first and second execution result tables based on the primary key column; if it is determined that the column feature values of the corresponding data columns with the same data column identifier are all the same in the first and second execution result tables, then it is determined that the execution results of the target SQL statement by the first and second computing engines are consistent. By calculating the column feature values of each column, the column feature values are inconsistent when any row of data in the column is inconsistent. By comparing the column feature values of each column, it is possible to determine whether the logical execution results of the same SQL job are consistent in different computing engines, without needing to sort the two result tables according to the primary key, avoiding memory overflow and improving data comparison efficiency. Furthermore, calculating the column characteristic values of each data column in the first and second result tables based on the primary key column ensures that the column characteristic values reflect the order of the data in each data column, thus guaranteeing the accuracy of data comparison.
[0057] The following example illustrates the method for comparing the results of the computing engine provided in the above embodiments. Figure 3 This is a flowchart of another method for comparing the running results of a computing engine, provided in an embodiment of this application. Based on the above embodiments, as follows... Figure 3 As shown, the specific steps of the method for comparing the results of the computing engine operation may include:
[0058] Step S201: Obtain the target SQL statement to be calculated.
[0059] Step S202: Use the first computing engine to run the target SQL statement to be calculated to obtain the first running result table corresponding to the first computing engine, and use the second computing engine to run the target SQL statement to be calculated to obtain the second running result table corresponding to the second computing engine.
[0060] Specifically, for the target SQL statement of the same SQL job, the two SQL calculation engines to be tested are used to perform the calculations, and the calculation results are written to their respective result tables.
[0061] Step S203: Read the table structure of the first execution result table and the second execution result table to obtain the column identifiers of the primary key column and data column of the first execution result table and the second execution result table.
[0062] Specifically, the table structures of the first and second result tables can be read to identify the primary key column and data column names. Unless otherwise specified, in big data computing scenarios, there is only one primary key column, located in column 1, and there are one or more data columns, located from column 2 to column 1.
[0063] In this embodiment, after reading the column identifiers of the primary key column and data columns of the execution result table, during step S203, the column feature values of each data column in the first and second execution result tables can be calculated sequentially based on the column identifiers of the data columns using a preset column feature value calculation algorithm, using the primary key column. This avoids redundant calculation of column feature values.
[0064] Step S204: Activate two threads in parallel to calculate the column feature values of each data column in the first and second result tables based on the primary key column using a preset column feature value calculation algorithm.
[0065] In this embodiment, two threads are enabled to calculate the column feature values of each data column in the first and second running result tables based on the primary key column using a preset column feature value calculation algorithm. This can improve the calculation efficiency of the column feature values of the data columns, thereby improving the efficiency of comparing the running results of the calculation engine.
[0066] Optionally, the preset column feature value calculation algorithm may include:
[0067] Step S2041: Calculate the row characteristic value of each row of data corresponding to the column identifier of a certain data column using the row characteristic value calculation formula.
[0068] Step S2042: Accumulate the row characteristic values corresponding to each row of data for the column identifier of this data column to obtain the column characteristic value of the data column. The formula for calculating the row characteristic value is:
[0069] RF=Hash(Concat(ToStr(id),ToStr(data)))
[0070] Wherein, RF represents the row characteristic value of a certain data column in a certain row of the table, id represents the value of the primary key column corresponding to the row, data represents the value of this data column in this row, ToStr is a function that converts a value of a certain data type into a string value, Concat is a function that concatenates two strings into a single string, and Hash is a function that maps a string to a 32-bit integer.
[0071] Specifically, the method for calculating the row feature value of a certain row of data is as follows: convert the value of the primary key column corresponding to a certain row into a string type value, and convert the value of the data in that row into a string type value; concatenate the value of the primary key column (string type) with the value of the data in that row (string type) to form a string, map the string into a 32-bit integer, and determine the 32-bit integer as the row feature value of the data in that row.
[0072] Specifically, the row characteristic values corresponding to the column identifiers of this data column are summed to obtain the data column's...
[0073]
[0074] TF represents the column characteristic value of the data column, which is a 32-bit integer. RF represents the row characteristic value of this data column in a specific row of the table, which is also a 32-bit integer. n is the number of rows in the data column. If the calculation result results in data overflow, the calculation continues based on the overflow result.
[0075] Alternatively, the xxhash algorithm can be used to implement the hash function. xxhash supports 32-bit output and, compared to algorithms such as Murmur3 and FNV, has better hashing performance and faster execution speed.
[0076] The method for comparing the running results of the computing engine provided in this application embodiment uses a row feature value calculation formula to calculate the row feature value of each row of data corresponding to the column identifier of a certain data column; it accumulates the row feature values of each row of data corresponding to the column identifier of the data column to obtain the column feature value of the data column; it uses various functions to calculate the row feature value, which improves the calculation efficiency and accuracy of the row feature value; and it maps the string of the row feature value into a 32-bit integer to facilitate the accumulation of the row feature value.
[0077] Step S205: Determine whether the execution results of the first calculation engine and the second calculation engine are consistent for the target SQL statement.
[0078] Optionally, after calculating the column characteristic values of each data column in the first and second result tables, the column characteristic values of each data column can be associated with the column identifiers of the data columns and stored in the storage space so that step S205 can be executed to determine whether the execution results of the first and second calculation engines on the target SQL statement are consistent, thereby improving the comparison efficiency and accuracy.
[0079] Specifically, after calculating the column characteristic value of a certain data column, it can be associated with the column identifier of the data column and stored in the storage space until the column characteristic values of each data column in the first and second running result tables are calculated and stored.
[0080] In this embodiment, if the column characteristic values of all data columns are the same, it can be determined that the data in the first execution result table and the second execution result table are consistent, that is, the execution results of the target SQL statement by the two computing engines are consistent. If the column characteristic values of one or more data columns are different, it can be determined that the data in the first execution result table and the second execution result table are inconsistent, that is, the execution results of the target SQL statement by the two computing engines are different.
[0081] In one optional implementation, step S205, determining whether the execution results of the first computing engine and the second computing engine for the target SQL statement are consistent, may specifically include:
[0082] Step S2051: Obtain the column feature values of the first and second run result tables corresponding to the column identifier of a certain data column.
[0083] Specifically, the column feature values of the first and second result tables corresponding to the column identifier of a certain data column can be obtained sequentially, and it can be determined whether the column feature values of the first and second result tables corresponding to the column identifier of a certain data column are the same. If they are different, step S2052 is executed to determine that the result is inconsistent and the comparison of column feature values is stopped. If they are the same, step S2053 is executed to obtain and compare the column feature values of the first and second result tables corresponding to the column identifier of the next data column, until the column feature values of each data column in the first and second result tables are compared.
[0084] Step S2052: If it is determined that the column feature value of the first execution result table and the column feature value of the second execution result table corresponding to the column identifier of a certain data column are different, then it is determined that the execution results of the first calculation engine and the second calculation engine on the target SQL statement are inconsistent, and the comparison of column feature values is stopped.
[0085] Step S2053: If it is determined that the column feature value of the first run result table and the column feature value of the second run result table corresponding to the column identifier of a certain data column are the same, then obtain and compare the column feature value of the first run result table and the column feature value of the second run result table corresponding to the column identifier of the next data column.
[0086] The computing engine execution result comparison method provided in this application embodiment stops comparing column feature values if it is determined that the column feature values corresponding to the column identifier of a certain data column in the first execution result table and the column feature values in the second execution result table are different. This method determines the inconsistency of execution results and stops comparing column feature values once it is determined that the column feature values corresponding to the column identifiers of each data column are different, thus improving the efficiency of computing engine execution result comparison and reducing the consumption of execution resources.
[0087] Based on the above embodiments, this embodiment involves a refinement of an implementation method for step S103, which uses a preset column feature value calculation algorithm to calculate the column feature values of each data column in the first and second running result tables based on the primary key column. Figure 4 As shown, the specific steps include:
[0088] Step S301: Calculate the row characteristic value of the first row of data and the row characteristic value of the second row of data corresponding to the column identifier of a certain data column in sequence.
[0089] Step S302: Accumulate the row feature values of the first row of data and the row feature values of the second row of data to obtain the current row feature accumulation value, and store the current row feature accumulation value.
[0090] Step S303: Calculate the row feature value of the next row of data in sequence.
[0091] Step S304: Add the row feature value of the next row of data to the current row feature accumulation value to update the current row feature accumulation value.
[0092] In this embodiment of the application, steps S303 and S304 can be executed repeatedly until the row feature value of the last row of the data column is added to the current row feature accumulation value to obtain the column feature value of the data column.
[0093] Step S305: Determine whether the next row of data is the last row of data in this data column.
[0094] In this application, if it is determined that the next row of data is the last row of data in the data column, then step S306 is executed to determine the current row feature accumulation value as the column feature value of the data column; if it is determined that the next row of data is not the last row of data in the data column, then step S303 and subsequent steps are executed until the row feature value of the last row of data in the data column is accumulated with the current row feature accumulation value to obtain the column feature value of the data column.
[0095] Step S306: If the next row of data is determined to be the last row of data in the data column, the accumulated value of the current row feature is determined as the column feature value of the data column.
[0096] Specifically, a row of data can be read, and after calculating the row feature value of the row of data, the feature value can be added to the current row feature accumulation value; after accumulation, the calculated row feature value and the row of data can be cleared.
[0097] In this embodiment, the calculation of column feature values only requires storing the cumulative result of the row feature values from the first row to the previous row, as well as the data of the primary key column and data column of the current row in memory, without needing to store all the data of the data column from the first row to the last row in memory. This makes the calculation process very memory-intensive, greatly reducing the memory pressure on the machine.
[0098] Figure 5 This is a schematic diagram of the structure of a computing engine execution result comparison device provided in an embodiment of this application. The computing engine execution result comparison device provided in this embodiment can execute the processing flow provided in the computing engine execution result comparison method embodiment. Figure 5 As shown, the calculation engine running result comparison device 40 includes: an acquisition module 401, a running module 402, a calculation module 403, and a comparison module 404.
[0099] Specifically, module 401 is used to obtain the target SQL statement to be calculated.
[0100] The running module 402 is used to run the target SQL statement to be calculated using the first computing engine and the second computing engine respectively, and to obtain the first running result table corresponding to the first computing engine and the second running result table corresponding to the second computing engine; the first running result table and the second running result table include: primary key column and data column.
[0101] The calculation module 403 is used to calculate the column feature values of each data column in the first and second running result tables based on the primary key column using a preset column feature value calculation algorithm.
[0102] The comparison module 404 is used to determine that the execution results of the first calculation engine and the second calculation engine on the target SQL statement are consistent if the data column identifiers in the first execution result table and the corresponding column feature values in the second execution result table are the same.
[0103] The apparatus provided in this application embodiment can be specifically used to execute the method embodiment provided in the above embodiment, and the specific functions will not be repeated here.
[0104] Optionally, the calculation module 403 is specifically used to: enable two threads to calculate the column feature values of each data column in the first and second running result tables based on the primary key column using a preset column feature value calculation algorithm.
[0105] Optionally, the calculation module 403 further includes: a reading unit and a calculation unit; the reading unit is used to: read the table structure of the first running result table and the second running result table to obtain the column identifiers of the primary key column and the data column of the first running result table and the second running result table; the calculation unit is used to: calculate the column feature value of each data column in the first running result table and the second running result table based on the primary key column using a preset column feature value calculation algorithm according to the column identifier of the data column.
[0106] Optionally, the calculation unit is specifically used to: calculate the row characteristic value of each row of data corresponding to the column identifier of a data column using the row characteristic value calculation formula; and accumulate the row characteristic values of each row of data corresponding to the column identifier of the data column to obtain the column characteristic value of the data column; the row characteristic value calculation formula is:
[0107] RF=Hash(Concat(ToStr(id),ToStr(data)))
[0108] Wherein, RF represents the row characteristic value of a certain data column in a certain row of the table, id represents the value of the primary key column corresponding to the row, data represents the value of this data column in this row, ToStr is a function that converts a value of a certain data type into a string value, Concat is a function that concatenates two strings into a single string, and Hash is a function that maps a string to a 32-bit integer.
[0109] Optionally, the calculation unit is specifically used to: sequentially calculate the row feature value of the first row of data and the row feature value of the second row of data corresponding to the column identifier of a certain data column; accumulate the row feature value of the first row of data and the row feature value of the second row of data to obtain the current row feature accumulation value, and store the current row feature accumulation value; sequentially calculate the row feature value of the next row of data; accumulate the row feature value of the next row of data with the current row feature accumulation value to update the current row feature accumulation value, until the row feature value of the last row of data in the data column is accumulated with the current row feature accumulation value to obtain the column feature value of the data column.
[0110] Optionally, the calculation module 403 is also used to: associate the column feature values of each data column with the column identifier of the data column and store them in the storage space.
[0111] Optionally, the comparison module 404 is further configured to: obtain the column feature value of the first execution result table and the column feature value of the second execution result table corresponding to the column identifier of a certain data column; if it is determined that the column feature value of the first execution result table and the column feature value of the second execution result table corresponding to the column identifier of a certain data column are different, then it is determined that the execution results of the first calculation engine and the second calculation engine for the target SQL statement are inconsistent, and the comparison of column feature values is stopped; if it is determined that the column feature value of the first execution result table and the column feature value of the second execution result table corresponding to the column identifier of a certain data column are the same, then obtain and compare the column feature value of the first execution result table and the column feature value of the second execution result table corresponding to the column identifier of the next data column.
[0112] The apparatus provided in this application embodiment can be specifically used to execute the above method embodiments, and its specific functions will not be described in detail here.
[0113] Figure 6 This is a schematic diagram of the structure of the electronic device provided in the embodiments of this application, such as... Figure 6 As shown, this application also provides an electronic device 50, including: a processor 501, and a memory 502 and a transceiver 503 communicatively connected to the processor 501. The memory 502 stores computer-executable instructions; the transceiver 503 is used for sending and receiving data; the processor 501 executes the computer-executable instructions stored in the memory 502 to implement the method provided in any embodiment of this application.
[0114] Specifically, the program may include program code, which includes computer-executable instructions. Memory 502 may include high-speed RAM, and may also include non-volatile memory, such as at least one disk storage device. The computer-executable instructions are stored in memory 502 and configured to be executed by processor 501 to implement the method provided in any embodiment of this application. Related descriptions can be understood by referring to the relevant descriptions and effects corresponding to the steps in the accompanying drawings, and will not be elaborated upon here.
[0115] In this embodiment, the memory 502 and the processor 501 are connected via a bus. The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. The bus can be divided into address bus, data bus, control bus, etc. For ease of representation, Figure 6 The bus is represented by a single thick line, but this does not mean that there is only one bus or one type of bus.
[0116] This application also provides a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, are used to implement the method provided in any embodiment of this application.
[0117] This application also provides a computer program product, including computer execution instructions, which, when executed by a processor, implement the method provided in any embodiment of this application.
[0118] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of modules is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple modules or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or modules may be electrical, mechanical, or other forms.
[0119] The modules described as separate components may or may not be physically separate. Similarly, the components shown as modules may or may not be physical modules; they may be located in one place or distributed across multiple network modules. Some or all of the modules can be selected to achieve the purpose of this embodiment, depending on actual needs.
[0120] Furthermore, the functional modules in the various embodiments of this application can be integrated into one processing module, or each module can exist physically separately, or two or more modules can be integrated into one module. The integrated module can be implemented in hardware or in a combination of hardware and software functional modules.
[0121] The program code used to implement the methods of this application may be written in any combination of one or more programming languages. This program code may be provided to the processor or controller of a general-purpose computer, special-purpose computer, or other programmable full-path fusion device, such that when executed by the processor or controller, the functions / operations specified in the flowcharts and / or block diagrams are implemented. The program code may be executed entirely on a machine, partially on a machine, as a standalone software package partially on a machine and partially on a remote machine, or entirely on a remote machine or server.
[0122] In the context of this application, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. Machine-readable media can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0123] Furthermore, although the operations are described in a specific order, this should be understood as requiring that such operations be performed in the specific order shown or in sequential order, or requiring that all illustrated operations be performed to achieve the desired result. In certain environments, multitasking and parallel processing may be advantageous. Similarly, although several specific implementation details are included in the above discussion, these should not be construed as limiting the scope of this application. Certain features described in the context of individual embodiments may also be implemented in combination in a single implementation. Conversely, various features described in the context of a single implementation may also be implemented individually or in any suitable sub-combination in multiple implementations.
[0124] Other embodiments of this application will readily occur to those skilled in the art of big data upon consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of this application that follow the general principles of this application and include common knowledge or customary techniques in the field of big data technology not disclosed herein. The specification and embodiments are to be considered exemplary only, and the true scope and spirit of this application are indicated by the following claims.
[0125] It should be understood that this application is not limited to the precise structure described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this application is limited only by the appended claims.
Claims
1. A method for comparing the results of a computing engine, characterized in that, include: Obtain the target SQL statement to be calculated; The target SQL statement to be calculated is executed using a first computing engine and a second computing engine, respectively, and the first execution result table corresponding to the first computing engine and the second execution result table corresponding to the second computing engine are obtained. The first computing engine and the second computing engine are two different SQL computing engines; The first and second result tables include: a primary key column and one or more data columns; Read the table structures of the first and second execution result tables to obtain the column identifiers of the primary key columns and one or more data columns of the first and second execution result tables; Two threads are enabled to perform the calculation of row feature values for each row of each data column and the accumulation of row feature values in parallel. For each data column, based on its column identifier, the row characteristic value of each row in the data column and its corresponding primary key column is calculated. The row characteristic values of each row are then summed to obtain the column characteristic value of the data column. The row characteristic value is determined by the primary key value of the row and the value of the row in the data column, so that the column characteristic value can distinguish the different arrangement orders of the data in the data column. The calculation method for the row feature value of each row of the data column includes: converting the value of the primary key column corresponding to a certain row into a string type value, converting the value of the data in that row into a string type value; concatenating the value of the primary key column (string type) with the value of the data in that row (string type) to form a string, mapping the string into a 32-bit integer, and determining the 32-bit integer as the row feature value of the data in that row; The step of accumulating the row feature values of each row to obtain the column feature value of the data column includes: sequentially calculating the row feature value of the first row of data and the row feature value of the second row of data corresponding to the column identifier of a data column; accumulating the row feature values of the first row of data and the second row of data to obtain the current row feature accumulated value, and storing the current row feature accumulated value; sequentially calculating the row feature value of the next row of data; accumulating the row feature value of the next row of data with the current row feature accumulated value to update the current row feature accumulated value; after each accumulation of the row feature value of the next row of data with the current row feature accumulated value, Clear the calculated row feature value and the data of the current row; determine if the next row is the last row of the data column; if the next row is the last row, use the accumulated value of the current row feature as the column feature value; if the next row is not the last row, return to execute the sequential calculation of the row feature value of the next row and subsequent steps until the row feature value of the last row is added to the accumulated value of the current row feature to obtain the column feature value; if the calculation result overflows, continue the calculation based on the overflow result. The column characteristic values of each data column are associated with the column identifiers of the data columns and stored in the storage space; Retrieve the column characteristic values of the first and second result tables corresponding to the column identifier of a certain data column; If it is determined that the column feature value of the first execution result table and the column feature value of the second execution result table corresponding to the column identifier of a certain data column are different, then it is determined that the execution results of the first calculation engine and the second calculation engine on the target SQL statement are inconsistent, and the comparison of column feature values is stopped. If it is determined that the column feature value of the first run result table and the column feature value of the second run result table corresponding to the column identifier of a certain data column are the same, then obtain and compare the column feature value of the first run result table and the column feature value of the second run result table corresponding to the column identifier of the next data column. If it is determined that the column identifiers of the data columns in the first and second result tables are the same and the column characteristic values of the corresponding data columns are also the same, then it is determined that the first and second calculation engines produce consistent results for the target SQL statement.
2. A device for comparing the results of a computing engine operation, characterized in that, include: The acquisition module is used to acquire the target SQL statement to be calculated. The running module is used to run the target SQL statement to be calculated using the first computing engine and the second computing engine respectively, and to obtain the first running result table corresponding to the first computing engine and the second running result table corresponding to the second computing engine. The first computing engine and the second computing engine are two different SQL computing engines; The first and second result tables include: a primary key column and one or more data columns; The calculation module is used to read the table structures of the first and second execution result tables to obtain the primary key columns and column identifiers of one or more data columns in the first and second execution result tables; enable two threads to execute the calculation operation of row characteristic values of each row of each data column and the accumulation operation of row characteristic values of each row in parallel; sequentially for each data column according to the column identifier, based on the data of each row of the data column and the data of each row of the corresponding primary key column, calculate the row characteristic value of each row of the data column, and accumulate the row characteristic values of each row to obtain the column characteristic value of the data column; wherein, the row characteristic value is determined by the primary key value of the row and the value of the row in the data column, so that the column characteristic value distinguishes the different arrangement order of the data in the data column; and associate the column characteristic value of each data column with the column identifier of the data column and store them in the storage space. The calculation module is specifically used to: convert the value of the primary key column corresponding to a certain row into a string value, convert the value of the data in that row into a string value; concatenate the value of the primary key column (string type) with the value of the data in that row (string type) to form a string, map the string into a 32-bit integer, and determine the 32-bit integer as the row feature value of the data in that row; The calculation module is specifically used for: sequentially calculating the row feature values of the first row and the second row of data corresponding to the column identifier of a data column; accumulating the row feature values of the first and second rows to obtain the current row feature accumulation value, and storing the current row feature accumulation value; sequentially calculating the row feature value of the next row of data; accumulating the row feature value of the next row of data with the current row feature accumulation value to update the current row feature accumulation value; and clearing the calculated row number after each accumulation of the row feature value of the next row of data with the current row feature accumulation value. The algorithm calculates the row feature value and the data in that row; it then determines whether the next row is the last row of the data column; if the next row is the last row, the accumulated value of the current row feature is used as the column feature value; if the next row is not the last row, the algorithm returns to calculate the row feature value of the next row sequentially and continues until the row feature value of the last row is added to the accumulated value of the current row feature to obtain the column feature value; if there is data overflow in the calculation result, the calculation continues based on the overflow result. The comparison module is used to obtain the column feature values of the first and second result tables corresponding to the column identifiers of a certain data column. If it is determined that the column feature values of the first and second result tables corresponding to the column identifiers of a certain data column are different, it is determined that the execution results of the first and second calculation engines on the target SQL statement are inconsistent, and the comparison of column feature values is stopped. If it is determined that the column feature values of the first and second result tables corresponding to the column identifiers of a certain data column are the same, the module obtains and compares the column feature values of the first and second result tables corresponding to the column identifiers of the next data column. If it is determined that the column feature values of the data columns corresponding to the same column identifiers in the first and second result tables are all the same, it is determined that the execution results of the first and second calculation engines on the target SQL statement are consistent.
3. An electronic device, characterized in that, include: A processor, and a memory and a transceiver communicatively connected to the processor; The memory stores computer-executed instructions; the transceiver is used for sending and receiving data. The processor executes computer execution instructions stored in the memory to implement the method as described in claim 1.
4. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions, which, when executed by a processor, are used to implement the method as described in claim 1.
Citation Information
Patent Citations
Business data verification method, device and equipment, and storage medium
CN111506578A
Data processing method and device
CN113760963A
Main and bypass switching method and device for decision engine upgrading, equipment and storage medium
CN115981744A
