Data testing method, equipment, medium and product
By generating reference code segments that comply with syntax rules and business logic, the existing data testing methods have solved the problem that high demands on testers are required by testers, and faster test cycles and higher problem mining rates are achieved.
Patent Information
- Application Number
- CN202411461974.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-18
- Publication Date
- 2025-02-14
AI Technical Summary
The existing data testing methods have high requirements for the testers' technical level and experience, resulting in a long test cycle and low problem mining rate.
By obtaining the script to be tested and the product requirements text, the pre-trained model is used to generate reference code segments that conform to the syntax rules and business logic, which are used to replace manual written test cases and implement testing of syntax and functional logic.
It reduces the requirements for testers, reduces the test cycle, improves the problem mining rate, and eliminates the process of manually writing test cases.
Smart Images

Figure CN119441031A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a data testing method, device, medium and product. Background Art
[0002] Big data scripts are usually written based on the syntax rules of Structured Query Language (SQL) and are used to perform computing tasks for big data. During the data testing phase, the syntax and functional logic of the big data scripts will be tested to ensure the correctness of the big data scripts.
[0003] Currently, big data scripts are mainly tested using manually designed test cases, and testers need to analyze product requirement texts and combine their own experience to write test cases.
[0004] However, since the quality of test case writing mainly depends on the technical level and experience of testers, current data testing has high requirements for testers and has problems such as long testing cycle and low problem discovery rate. Summary of the invention
[0005] In view of the above problems, the embodiments of the present application provide a data testing method, device, medium and product to overcome the above problems or at least partially solve the above problems.
[0006] In a first aspect of an embodiment of the present application, a data testing method is provided, the method comprising: Acquire a script to be tested and a product requirement text associated with the script to be tested, wherein the product requirement text includes: a semantic description of the business-related functional logic that needs to be implemented when the script to be tested performs a computing task on a database table in a target database; Acquire each first keyword from the product requirement text, where the first keyword is a semantic description associated with a preset table information type, where the preset table information type includes at least one of a table name and a table field of a database table; Acquire target table information corresponding to each of the first keywords from the target database; According to the product requirement text and each of the target table information, a reference code segment is generated through a pre-trained first model, which complies with the grammatical rules corresponding to the script to be tested and is used to implement the business-related functional logic described in the product requirement text; The generated reference code segment is matched with the script to be tested to obtain a first test result.
[0007] According to a second aspect of an embodiment of the present application, an electronic device is provided, including a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus; the memory is used to store computer programs; and the processor is used to implement the data testing method as described in the first aspect of the embodiment of the present application when executing the program stored in the memory.
[0008] According to a third aspect of an embodiment of the present application, a computer-readable storage medium is provided, on which a computer program / instruction is stored. When the computer program / instruction is executed by a processor, the data testing method as described in the first aspect disclosed in the embodiment of the present application is implemented.
[0009] According to a fourth aspect of the embodiments of the present application, a computer program product is provided, including a computer program / instruction, which, when executed by a processor, implements the data testing method as described in the first aspect of the embodiments of the present application.
[0010] The embodiments of the present application include the following advantages: Based on the product requirement text and the information of each target table, with the help of the first model, a reference code segment can be automatically generated that conforms to the grammatical rules corresponding to the script to be tested and is used to implement the business-related functional logic described in the product requirement text. The reference code segment can be used to test the grammatical correctness and functional logic correctness of the script to be tested, and the manual writing of test cases can be eliminated, thereby reducing the requirements for testers and solving the problems of long testing cycle and low problem mining rate caused by manually writing test cases. BRIEF DESCRIPTION OF THE DRAWINGS
[0011] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the description of the embodiments of the present application will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0012] Figure 1 It is a flowchart of the steps of a data testing method in an embodiment of the present application; Figure 2 It is a structural schematic diagram of a data testing system in an embodiment of the present application; Figure 3 This is a schematic diagram of the workflow of a data testing system in an embodiment of the present application; Figure 4 It is a structural schematic diagram of a data testing device in an embodiment of the present application; Figure 5It is a schematic diagram of an electronic device in an embodiment of the present application. DETAILED DESCRIPTION
[0013] In order to make the above-mentioned objects, features and advantages of the present application more obvious and easy to understand, the present application is further described in detail below in conjunction with the accompanying drawings and specific implementation methods.
[0014] Big data scripts such as Hive scripts are usually written based on SQL syntax rules and are used to perform computing tasks for big data (or massive data), such as aggregating and filtering wide tables (i.e. database tables with more fields) in related databases, and then calculating the desired data according to preset logic.
[0015] Among them, Hive is a data warehouse analysis system built on the distributed file system (Hadoop). It can map structured data files into a database table and provide SQL query functions.
[0016] During the data testing phase, the syntax and functional logic of the big data script will be tested to ensure the correctness of the big data script. Currently, manually designed test cases are mainly used to test big data scripts. Testers need to understand the relevant grammatical rules of the script and combine the product requirement text (also known as product documentation) and their own experience to sort out the relevant functional logic in order to write test cases.
[0017] However, the learning cost of data testing is high, and the functional logic involved is complex. The above-mentioned data testing methods usually have difficult to meet the technical level and experience requirements of testers, resulting in the current data testing methods having problems such as long testing cycle and low problem discovery rate.
[0018] Based on the above analysis, in order to solve the problems of low testing efficiency and low problem mining rate caused by manually written test cases in related technologies, an embodiment of the present application provides a data testing solution, which automatically generates a reference code segment according to the product requirement text through a first model, and uses the reference code segment to replace the manually written test case to perform script correctness testing related to syntax and functional logic of the script to be tested. This can eliminate the need for manually writing test cases, thereby reducing the requirements for testers and solving the problems of long testing cycle and low problem mining rate caused by manually writing test cases.
[0019] Reference Figure 1 FIG. 1 is a flowchart of a data testing method according to an embodiment of the present application, wherein the method comprises the following steps: Step S11: Acquire the script to be tested and the product requirement text associated with the script to be tested, wherein the product requirement text includes: a semantic description of the business-related functional logic that needs to be implemented when the script to be tested performs a computing task on a database table in a target database.
[0020] In specific implementation, a data interaction interface can be created in advance. For example, the data interaction interface can be a web page that supports user data input to receive the script to be tested and the product requirement text entered by the tester in the web page, thereby achieving the acquisition of the script to be tested and the product requirement text.
[0021] Step S12: Acquire each first keyword from the product requirement text, where the first keyword is a semantic description associated with a preset table information type, and the preset table information type includes at least one of a table name and a table field of a database table.
[0022] In specific implementation, testers can pre-mark semantic descriptions (i.e. keywords) that may be related to the table name or table field of the database table in the product requirement text based on experience; for example, if the product requirement text is "need to read advertising revenue data", since the semantic description of "advertising revenue" is more likely to be associated with the table name or table field of the database table, the semantic description of "advertising revenue" can be marked with an underscore in the product requirement text. Then, testers can write code to build a keyword extraction service, which can automatically extract each semantic description pre-marked in the product requirement text, and then obtain each first keyword.
[0023] Alternatively, the tester can also set reference semantic descriptions for the table name values and table field values of each database table in the target database in advance based on experience, such as setting a reference semantic description of "advertising income" for the table name value "ad_income" of the database table. The tester can then write code to build a keyword detection service, which can automatically detect whether there are semantic descriptions with high similarity to each of the reference semantic descriptions in the product demand text. If a semantic description with high similarity is detected in the product demand text, the detected semantic description is determined as the first keyword.
[0024] It should be noted that, considering that the database table object required for the script to be tested to perform the computing task is usually the entire database table (usually described by the value of the relevant table name in the code segment), or part of the data contained in the database table (usually described by the value of the relevant table field in the code segment). This application uses the table name and / or table field of the database table as the preset table information type, and obtains the semantic description (i.e., each first keyword) associated with the preset table information type in the product requirement text to determine the specific database table object required for the script to be tested to perform the computing task through the product requirement text; subsequently, by obtaining the target table information corresponding to each of the first keywords, the information required to describe the specific database table object in the code segment (i.e., the value of the table name and / or the value of the table field) can be obtained. Therefore, with the help of the target table information, it can be ensured that the reference code segment generated by the first model can perform the computing task for the specific database table object, thereby ensuring that the reference code segment can implement the business-related functional logic described in the product requirement text.
[0025] Step S13: Acquire target table information corresponding to each of the first keywords from the target database.
[0026] The target table information is: the value of the table name of the database table, or the value of the table field contained in the database table; the target database is a database that supports the use of big data scripts to perform data operations such as query and grouping aggregation to achieve big data computing tasks.
[0027] In specific implementation, the table information (ie, the value of the table name and / or the value of the table field) in the target database that conforms to the preset table information type may be queried to find out the target table information corresponding to each first keyword.
[0028] For example, if the product requirement text is "need to read advertising revenue data", then when extracting keywords that match the preset type of table name (i.e. semantic description), "advertising revenue" can be used as the keyword to be extracted (i.e. the first keyword), and the value of the table name "ad_income" in the target database is used as the target table information corresponding to "advertising revenue". Among them, "ad_income" is the value of the table name of an existing database table in the target database (which is responsible for recording the revenue data of various types of advertisements).
[0029] It should be noted that when there are only first keywords that meet the preset type of table field in the product requirement text, the tester can also flexibly decide whether to configure the table name values of the database table associated with these first keywords as the target table information based on actual needs; similarly, when there are only first keywords that meet the preset type of table name in the product requirement text, the tester can also decide whether to configure the table field values of the database table associated with these first keywords as the target table information based on actual needs.
[0030] Step S14: Based on the product requirement text and the information of each target table, a reference code segment that conforms to the grammatical rules corresponding to the script to be tested and is used to implement the business-related functional logic described in the product requirement text is generated through a pre-trained first model. The pre-trained first model has the ability to generate a code segment that conforms to the grammatical rules corresponding to the script to be tested.
[0031] The grammar rules corresponding to the script to be tested may be SQL grammar rules.
[0032] In the specific implementation, different product requirement text samples and the code segments corresponding to each of these product requirement text samples (that is, the code segments expected to be generated that conform to the grammatical rules corresponding to the script to be tested) can be collected in advance, and the values of the table names and / or table fields associated with each of these product requirement text samples can be determined.
[0033] These product requirement text samples and the corresponding determined table name values and / or table field values are used as different input text samples of the model, and the collected code segments are used as labels of these input text samples (i.e., the expected model outputs). The generative artificial intelligence (AIGC) model is trained using these input text samples and their labels, and the AIGC model that meets the training end conditions, such as the AIGC model that has been trained for a certain number of times, or the model output loss has reached convergence, or the AIGC model that can correctly convert more than 85% of the product requirement text samples into code segments, is used as the first model.
[0034] It should be noted that the present application does not impose any specific restrictions on the manner in which the product requirement text and its corresponding target table information, as well as the product requirement text sample and its corresponding table name values and / or table field values are input into the model.
[0035] Taking a single product requirement text sample as an example, the mapping relationship between each first keyword associated with the product requirement text sample and the value of each table name and / or the value of the table field can be recorded in the form of a mapping table, and the mapping table and the product requirement text sample can be used as an input text sample of the model; or, each first keyword in the product requirement text sample can be replaced with the value of each table name and / or the value of the table field, and the replaced product requirement text sample can be used as an input text sample of the model.
[0036] In the application stage, the first model can automatically analyze the business-related functional logic described in the product requirement text, and automatically generate the reference code segment in combination with the information of each target table.
[0037] Taking the SQL grammar rule corresponding to the script to be tested as an example, the product requirement text is "read the data in the advertising revenue table, calculate the total advertising revenue, the total advertising revenue = brand advertising revenue + performance advertising revenue".
[0038] The target table information includes: the table name value "ad_income" corresponding to the "advertising income table", the table field value "ad_income.brand_income" corresponding to the "brand advertising income", and the table field value "ad_income.effect_income" corresponding to the "effect advertising income".
[0039] The first model will generate the SQL code segment "select sum (brand_income) + sum (effect_income) from ad_income" according to the above product demand text and the information of each target table.
[0040] Step S15: Match the generated reference code segment with the script to be tested to obtain a first test result.
[0041] The script to be tested may be a big data script such as a Hive script.
[0042] In specific implementation, the tester can write code to build a verification service, and the verification service can automatically match the input reference code segment with the script to be tested to obtain the first test result.
[0043] In the above matching process, it is detected whether there is a code segment in the script to be tested whose similarity with the reference code segment reaches a set value. If such a code segment exists in the script, it is determined that the reference code segment matches the script to be tested successfully, and a first test result representing that the test has passed is generated accordingly. If such a code segment does not exist in the script, it means that the corresponding code segment in the script to be tested may have problems such as syntax errors or functional logic errors, resulting in a large difference from the reference code segment. At this time, it is determined that the reference code segment fails to match the script to be tested, and a first test result representing that the test has failed is generated accordingly.
[0044] By adopting the technical solution of the embodiment of the present application, based on the product requirement text and the information of each target table, with the help of the first model, a reference code segment that conforms to the grammatical rules corresponding to the script to be tested and is used to implement the business-related functional logic described in the product requirement text can be automatically generated. The reference code segment can be used to test the grammatical correctness and functional logic correctness of the script to be tested, and the manual writing of test cases can be eliminated, thereby reducing the requirements for testers and solving the problems of long testing cycle and low problem mining rate caused by manually writing test cases.
[0045] In one embodiment, before the above step S14, the method further includes: Step S16: Acquire each second keyword from the product requirement text, where the second keyword is a semantic description associated with a preset functional logic type, and the preset functional logic type includes at least one of date and time restrictions and group aggregation.
[0046] During specific implementation, the tester obtains the semantic description of date-time (DT) restrictions and / or grouping aggregation in the product requirement text to obtain each second keyword.
[0047] It should be noted that group aggregation refers to the operation of grouping data and performing aggregation operations on each group; in SQL, the group by clause is usually used to group data, and aggregation functions such as sum() or avg() are used to calculate the data in each group; DT restriction refers to restricting the date and time of the data, which can be used as a filtering condition when querying data. In SQL, the where clause with the date and time value as the restriction condition is usually used to restrict the date and time of the data.
[0048] Step S17: Determine the mapping value of each of the second keywords in the reference code segment.
[0049] In specific implementation, a mapping table can be pre-established, and the mapping table is used to record the mapping value of the second keyword in the code segment. For example, the mapping table can record the mapping value of the second keyword associated with the DT restriction in the code segment as "DT restriction" or "{$dt}", and the parameter {$dt} is used to characterize the date and time variable (i.e., it does not represent the specific value of the date and time); or the mapping table can record the mapping value of the second keyword associated with the grouping aggregation in the code segment as "groupby x1" and "sum (x2)", and the parameters x1 and x2 respectively represent the table field information to be supplemented. Subsequently, the mapping value of each second keyword in the reference code segment can be quickly determined by querying the mapping table.
[0050] After executing the above step S17 to obtain the mapping values, the reference code segment is generated by combining the mapping values, that is, the above step S12 can be implemented by the following step S121: Step S121: Generate the reference code segment according to the product requirement text, each target table information, and each determined mapping value through a pre-trained first model.
[0051] In this embodiment, for DT restrictions, group aggregation or other more complex functional logics, the present application adopts a method of pre-determining mapping values to assist the first model in generating code segments for implementing these functional logics, thereby improving the accuracy of the code segments generated by the first model, making it more consistent with the business-related functional logic described in the product requirement text, thereby ensuring the test quality.
[0052] Optionally, the above step S121 can be implemented by the following steps S1211 to S1212: Step S1211: In the product requirement text, each of the first keywords and each of the second keywords are replaced with each of the target table information and each of the mapping values to obtain a target product requirement text.
[0053] In specific implementation, when the second keyword contains the first keyword, a clause (including a where clause associated with DT restriction, or a group by clause and aggregation function associated with group aggregation, etc.) can be formed by combining the mapping value corresponding to the second keyword and the target table information corresponding to the first keyword, such as forming a group by clause "group by product", and / or forming an aggregation function with parameters, such as forming an aggregation function with parameters "sum (brand_income)". Then, the constructed clause or aggregation function with parameters is used to replace the second keyword as a whole.
[0054] Step S1212: input the target product requirement text into the first model to obtain the reference code segment generated by the first model.
[0055] Taking the product requirement text "T+1 reads the total advertising revenue data, calculates the daily total advertising revenue, and the total advertising revenue = brand advertising revenue + effect advertising revenue" as an example, the target product requirement text obtained after keyword replacement is "DT limits ad_income data, calculates the daily total advertising revenue, and the total advertising revenue = ad_income.brand_income + ad_income.effect_income".
[0056] The above target product demand text is input into the first model, and the first model immediately generates a reference code segment “select sum(brand_income)+sum(effect_income) from ad_income where dt={$dt};”.
[0057] In this embodiment, the product requirement text, target table information and predetermined mapping values are combined and summarized into a target product requirement text by using keyword replacement, which can reduce the complexity of model input data and thus improve model processing efficiency.
[0058] Optionally, the reference code segment includes: a where clause associated with the date and time restriction, and / or a group by clause and an aggregation function associated with the group aggregation; the above step S17 can be implemented by the following steps S171 to S172: Step S171: For the second keyword associated with the date and time restriction, a representation value of a preset date and time or a specific value of the date and time described by the second keyword is determined as a mapping value of the second keyword in the reference code segment, so that when the first model generates the reference code segment, the mapping value is used as a restriction condition of the where clause to generate the where clause associated with the date and time restriction.
[0059] In specific implementation, the mapping value of the second keyword associated with the DT restriction in the code segment can be determined as a specific value that matches the date and time described by the second keyword, such as determining the relevant mapping value as "2023-05-09" or "CURRENT_DATE" (which is a function for returning the current date and time), etc. For example, when generating a code segment, the first model can generate a where clause "where dt='2023-05-09';" with "2023-05-09" as the restriction condition according to the mapping value "2023-05-09" of the second keyword associated with the DT restriction, thereby obtaining the where clause associated with the DT restriction.
[0060] Alternatively, the mapping value of the second keyword associated with the DT restriction in the code segment can also be determined as a time representation value, such as the parameter {$dt} or the semantic description "DT restriction". In this case, the mapping value is used to represent the variable of date and time, and does not specifically refer to a specific date and time. For example, when generating a code segment, the first model can generate a where clause "where dt={$dt};" with the parameter {$dt} as the restriction condition based on the parameter {$dt}, thereby obtaining the where clause associated with the DT restriction.
[0061] Step S172: For the second keyword associated with the grouping aggregation, the group by clause and aggregation function that are used to implement the grouping operation and aggregation operation described by the second keyword and to be filled in with the table information are determined as the mapping value of the second keyword in the reference code segment, so that when the first model generates the reference code segment, the target table information associated with the second keyword is filled in the mapping value to obtain the group by clause and aggregation function associated with the grouping aggregation.
[0062] In specific implementation, the mapping value of the second keyword associated with group aggregation in the code segment can be determined as the group by clause and aggregation function that match the grouping operation and aggregation operation described by the second keyword. For example, for the second keywords "group by product" and "calculate the total sales of each group", the mapping values "group by x1" and "sum (x2)" can be determined accordingly. Among them, x1 and x2 respectively represent the table field information to be supplemented. Before entering the first model, the above mapping value can be combined with the target table information corresponding to the first keyword. For example, x1 can be replaced with the table field information corresponding to the first keyword "product", and x2 can be replaced with the table field information corresponding to the first keyword "sales".
[0063] In this embodiment, for the two more commonly used functional logics, DT restriction and group aggregation, the present application provides a specific implementation method for determining relevant mapping values to ensure that the mapping values related to DT restriction and group aggregation can be correctly determined, and based on the mapping values to assist the first model in generating code segments for implementing the aforementioned two functional logics, the accuracy of the code segments generated by the first model can be further improved.
[0064] In one embodiment, the reference code segment includes sub-code segments corresponding to at least one of a projection, an association relationship, and a filtering condition.
[0065] Among them, projection is used to describe the data to be retrieved (such as a database table or a column of data in a database table), which can correspond to the sub-code segment where the select operation is located in the SQL code segment; association relationship is used to describe the rules used to associate different database tables, which can correspond to the sub-code segment where the join operation is located in the SQL code segment; filter condition (or restriction condition) is used to filter the retrieved data, which can correspond to the sub-code segment where the subsequent fields of the where field in the SQL code segment are located.
[0066] In specific implementation, the reference code segment generated by the first model can be divided into sub-code segments corresponding to projection, association relationship and filtering condition, that is, the reference code segment is divided into three parts.
[0067] Alternatively, by adjusting the labels of the samples used in model training, the first model can generate sub-code segments according to the three parts of projection, association relationship and filtering conditions; or by adjusting the model structure (such as adding a module for dividing sub-code segments), the first model can be capable of dividing the generated code segments into sub-code segments according to the three parts of projection, association relationship and filtering conditions.
[0068] Taking the product requirement text sample "The company will provide employee benefits to employees who have been in office for more than five years and have received two or more A+ performance ratings in the past five years before March 25, 2024. 5 A+ employees will receive 5,000 yuan shopping vouchers; 4 A+ employees will receive 4,000 yuan shopping vouchers; 3 A+ employees will receive 3,000 yuan shopping vouchers; 2 A+ employees will receive 2,000 yuan shopping vouchers. Other employees will not receive bonuses. Query the employee number, employee name, number of A+ ratings, and bonus amount for bonuses" as an example, the label (i.e., code segment) set for the product requirement text sample can be expressed as follows: projection: select employee_id, employee_name, count(performance) as A_plus_count, case when A_plus_count>=5 then 5000 when A_plus_count=4 then 4000 when A_plus_count=3 then 3000 when A_plus_count=2 then 2000 end as bonus Relationship: from employee_info left join performance_info Filter by: performance in (S,A+); A_plus_count>2; dt="2024-03-25"; on_job_years>=5; year>=2018 It is understandable that, since the content details of different product requirement texts may vary, the reference code segment generated by the first model will also include sub-code segments corresponding to one or more of the projection, association, and filtering conditions. Compared with generating code segments as a whole, this method of partially generating sub-code segments based on the content details of the product requirement text can improve the matching degree between the content generated by the first model and the product requirement text.
[0069] Optionally, the above step S15 can be implemented by the following steps S151 to S152: Step S151: Match the reference code segment with the script to be tested to obtain a first matching result and at least one second matching result, wherein the first matching result is used to characterize the overall matching degree between the script to be tested and all sub-code segments in the reference code segment, and the second matching result is used to characterize the matching degree between the script to be tested and a single sub-code segment in the reference code segment.
[0070] In specific implementation, the first matching result can be obtained by calculating the matching ratio (i.e., similarity) between the reference code segment as a whole and the script to be tested, and the second matching result can be obtained by calculating the matching ratio between a single sub-code segment in the reference code segment and the script to be tested.
[0071] It should be noted that the number of second results to be determined or the sub-code segments used for matching can be freely set according to actual needs. For example, when it is only necessary to further combine the degree of matching between the sub-code segment corresponding to the filtering condition and the script to be tested to determine the first test result, only the second matching result corresponding to the filtering condition can be determined.
[0072] Step S152: Generate the first test result according to the first matching result and the at least one second matching result.
[0073] In specific implementation, testers can freely set the test pass conditions according to actual needs, such as setting the test pass conditions as: the overall matching rate of the development script reaches more than 65%, and the matching rate of the filtering rules reaches more than 80%. Subsequently, the verification service pre-created by the tester will generate a first test result indicating that the test has passed or failed based on the matching ratio in the first matching result and the matching ratio in the second matching result corresponding to the filtering condition, combined with the test conditions.
[0074] In this embodiment, the test result is determined by combining the overall matching result between the code segment and the script to be tested, as well as the local matching result between the sub-code segment and the script to be tested. Thus, on the basis of testing the overall correctness of the script to be tested, the local correctness of the script to be tested can be tested in a targeted manner according to business needs, thereby improving the flexibility of the test and being more in line with actual business needs.
[0075] Optionally, after obtaining the first test result, a test report including the first test result, sub-code segments that are successfully matched, and sub-code segments that are unmatched is generated.
[0076] In specific implementation, each sub-code segment in the reference code segment can be saved as a record in the database, and its type (such as projection, association relationship and filter condition) can be identified. The type of the sub-code segment to be matched is determined, and each sub-code segment that meets the type in the database record is matched with the script to be tested. If the match is successful, the corresponding record stored in the database is marked as 1, and if the match fails, the corresponding record stored in the database is marked as 0.
[0077] Subsequently, the sub-code segments identified as 1 and the sub-code segments identified as 0 in the database record are respectively summarized, and the combination of the sub-code segments and the first test result is used as a test report, and the test report is sent to relevant personnel in the form of an email.
[0078] In one embodiment, the above step S13 can be implemented by the following steps S131 to S132: Step S131: For the first keyword associated with the table field, obtain, from the values of the table fields included in each database table of the target database, the values of the target table fields whose similarity to the first keyword is higher than the first set value, and determine the values of the target table fields as the target table information corresponding to the first keyword.
[0079] Step S132: For the first keyword associated with the table name, obtain, from the values of the table names of each database table of the target database, the values of the target table names whose similarity to the first keyword is higher than the second set value, and determine the values of the target table names as the target table information corresponding to the first keyword.
[0080] In this embodiment, considering that there is usually a high similarity between the values of the table fields or table names in the database table and their related semantic descriptions. For example, a combination of some letters in the relevant English words (i.e., the related semantic descriptions in English form) is usually used as the value of the table field or table name, so that the user can infer the related semantic description based on the value of the table field or table name, and then know the data content stored in the relevant database table. For example, "ad_income" is usually used as the value of the table name of the database table for storing advertising income data. Since "ad_income" has a high similarity to the English word "advertisingincome" (the corresponding Chinese word is "广告收入"), the user can know that the database table is used to store advertising income data based on the value of the table name.
[0081] In this application, by matching each table information (i.e., the values of each table name or each table field) in the target database with the first keyword based on similarity, the first keyword with a similarity higher than the preset value is determined to be successfully matched with the table information. Thus, by virtue of the high similarity between the value of the table field or table name and its related semantic description, the target table information corresponding to each first keyword can be quickly and accurately found.
[0082] In one embodiment, the syntax rule corresponding to the script to be tested is: the Structured Query Language (SQL) syntax rule, and the pre-trained first model is used to generate code segments that conform to the SQL syntax rule; before the above step S14, the method further includes: Step S21: Construct a first training sample set according to each product requirement text sample, the table information corresponding to each first keyword in each product requirement text sample, and the sample label corresponding to each product requirement text sample, where the sample label includes: the expected generated code segments that conform to the SQL syntax rule.
[0083] In a specific implementation, for each product requirement text sample, an input text sample is constructed according to the product requirement text sample and its corresponding table information, and the code segment generated by the expected model according to the input text sample is used as the sample label of the input text sample. The input text samples and their sample labels corresponding to each product requirement text sample are summarized to obtain a first training sample set.
[0084] Step S22: training the generative pre-trained language model using the first training sample set to obtain a second model.
[0085] In the specific implementation, the pre-trained generative pre-trained (GPT) model (i.e., generative pre-trained language model) with text generation capability is trained through the first training sample set, that is, the GPT model is supervised fine-tuned (Supervised FineTune, SFT), where supervised fine-tuning refers to the process of further training the pre-trained model using labeled samples.
[0086] Specifically, when using the first training sample set for model training, the output of the GPT model is compared with the target output (i.e., the sample label of the relevant input text sample in the first training sample set) to calculate the loss function value, and the model parameters in the GPT model are updated according to the calculated loss function value. This process is repeated until the GPT model meets the training end conditions, and then the GPT model that meets the training end conditions is used as the second model.
[0087] Step S23: determining a reward value for the code segment generated by the second model through a pre-trained reward model, wherein the reward value is used to characterize the degree of matching between the code segment generated by the second model and the expected code segment that complies with SQL grammar rules.
[0088] During specific implementation, some product requirement text samples may be collected in advance, and these product requirement text samples are different from the product requirement text samples used to create the first training sample set.
[0089] Corresponding input text samples are created based on the collected product requirement text samples, and after obtaining the second model with code segment generation capability, these input text samples are respectively input into the second model. The reward model is used to automatically determine the reward value for each code segment correspondingly generated by the second model to evaluate whether the code segments generated by the second model meet expectations (such as user preferences), thereby estimating the similarity between the code segments generated by the second model and the code segments written by the user without the user actually writing the code segments.
[0090] When training the Reword Model (RM), users (such as testers) can pre-label the reward values for each code segment generated by the second model according to their own preferences. The higher the labeled reward value, the more the generated code segment conforms to the expected code segment. These code segments and the labeled reward values are then used as training samples and their labels to train the neural network model, and a reward model is obtained that can automatically determine (that is, predict) the reward value for the code segment according to the user's preferences, thereby eliminating the need for manual labeling of reward values in the subsequent model training process.
[0091] Step S24: training the second model according to the reward value corresponding to the code segment generated by the second model to obtain the first model.
[0092] In a specific implementation, the model parameters of the second model are iteratively updated with the goal of maximizing the reward value determined by the reward model to obtain the first model.
[0093] The training process of the second model can be implemented using a reinforcement learning algorithm such as a proximal policy optimization (PPO) algorithm.
[0094] Taking the PPO algorithm as an example, the second model mentioned above is used as the actor model and the reference model, and the parameters of the reference model are frozen. The reward model mentioned above is used as the critic model and the target reward model. The critic model is used to predict the expected total return and requires parameter updates; the target reward model is used to calculate the instant return of generating tokens, and the parameters of the target reward model are frozen. Among them, token is the basic building block of text processing. It represents a discrete element in text (such as a code snippet), which can be a word, character, subword or character.
[0095] After building the model required by the PPO algorithm, the model training is implemented through the following steps: The first step is to collect product requirement text samples in batches and construct multiple input text samples based on them.
[0096] In this step, in order to ensure the generalization ability of the trained model, the richness of the product requirement text samples must be ensured. For example, the collected product requirement text samples should cover a variety of semantic description methods and their combinations related to association relationships, filtering conditions and projections.
[0097] The second step is to input the above multiple input text samples into the Actor Model to generate corresponding code segments.
[0098] In the third step, the above multiple input text samples are input into the reference model, and the corresponding code segments generated by the Actor Model are input into the critic model and the target reward model respectively. According to the outputs of the reference model, the critic model and the target reward model, the actor loss and the critic loss are calculated. Among them, the actor loss is the sum of all token losses in the code segments generated by the Actor Model.
[0099] In this step, a first parameter value can be determined based on the output difference between the actor model and the reference model, and the first parameter value is used to constrain the update of the actor model during the fine-tuning process not to deviate too far from the second model. A second parameter value reward is determined based on the output of the target reward model and the first parameter value, and a third parameter value adv is determined based on the second parameter value reward and the output of the critic model, and adv is used to evaluate the degree of goodness of an action taken by the actor model (such as generating a token) relative to other actions (such as generating other tokens).
[0100] The actor loss is determined according to the output difference between the actor model before the last update and the current (corresponding to the same input) and the third parameter value adv. The critic loss is determined according to the output difference between the critic model before the last update and the current (corresponding to the same input) and the second parameter value reward.
[0101] In the fourth step, the actor model and the critic model are updated with the goal of minimizing the actor loss and the critic loss respectively.
[0102] In this embodiment, the second model is obtained by training the generative pre-trained language model, which can reduce the number of training samples required, and the second model is further trained (i.e., fine-tuned) in combination with the reward model to obtain the first model, so that the code segment generated by the first model can be more in line with user preferences, thereby ensuring the test quality.
[0103] In one embodiment, the method further comprises: Step S31: According to pre-established verification rules, the syntax errors in the script to be tested are detected to generate a second test result, wherein the second test result is used to indicate whether there are syntax errors in the script to be tested, and the location and type of the syntax errors.
[0104] The pre-established verification rule includes at least one of the following: Syntax validation rules for projections; Syntax validation rules for association relationships; Syntax validation rules for filter conditions.
[0105] In this embodiment, the syntax verification rules for the projection may include: verification rules for whether the field order and type in the sub-code segment corresponding to the projection are consistent with the table declaration, or verification rules for whether the null value conversion function (nvl function) is used for processing when the divisor in the sub-code segment corresponding to the projection is 0 or a null value (null), etc.
[0106] The syntax verification rules for the association relationship may include: verification rules for whether the database table with DT fields in the sub-code segment corresponding to the association relationship has added DT restrictions, or verification rules for the correctness of the enumeration values of the limited fields in the sub-code segment corresponding to the association relationship.
[0107] The syntax verification rules for the filtering conditions may include: verification rules for whether the DT partition filtering restrictions are added to the table with DT fields in the sub-code segment corresponding to the filtering conditions, or verification rules for the correctness of the meaning of the condition field and the enumeration value of the limited field in the sub-code segment corresponding to the filtering conditions, etc.
[0108] Step S32: Generate a final test result according to the first test result and the second test result.
[0109] In a specific implementation, the combination of the first test result and the second test result can be directly determined as the final test result, or when both the first test result and the second test result indicate that the test has passed, a final test result indicating that the test has passed is generated; when at least one of the first test result and the second test result indicates that the test has failed, a final test result indicating that the test has failed is generated.
[0110] In this embodiment, considering that the level of detail of the product requirement text is usually limited, such as the description of many detail fields will not be very sufficient, resulting in the reference code segment generated by the first model not being very complete, which in turn results in the lack of certain integrity and standardization of the data test based only on the reference code segment. Therefore, this application divides the code segments in the script into three common components: projection, association, and filter conditions, and allows testers to set syntax verification rules based on the three common components, so as to ensure the integrity of the data test, and also facilitate testers to specifically design common verification rules for the three common components that are applicable to different scripts.
[0111] Optionally, the above step S31 can be implemented by the following step S311: Step S311: According to the pre-established verification rule, the grammatical errors in the script to be tested are detected by using a pre-trained third model to generate the second test result.
[0112] In the specific implementation, the script to be tested is input into the third model, and the third model then detects whether there are grammatical errors in the script to be tested based on the verification rules. When it is detected that there are no grammatical errors in the script to be tested, the first model generates a second test result indicating that the test has passed. When it is detected that there are grammatical errors in the script to be tested, the first model generates a second test result indicating that the test has failed, and the location and type of the grammatical errors in the script to be tested can be explained in the second test result, thereby eliminating the manual verification step based on the verification rules and ensuring the degree of automation of data testing.
[0113] Optionally, the third model can be trained by the following steps: Step S41: Acquire each annotated big data script, wherein the annotated big data script is obtained by annotating the location and type of syntax errors in the big data script according to the pre-established verification rule; In specific implementation, big data scripts can be collected in batches, and the syntax errors in these big data scripts can be found and marked according to the verification rules. For example, the relevant fields with a divisor of 0 in the sub-code segment corresponding to the projection can be circled with an anchor frame, and descriptions such as "divisor is 0" or "syntax error corresponding to the projection" can be set as the label of the anchor frame, thereby achieving the marking of the location and type of syntax errors.
[0114] Step S42: Use the labeled big data scripts to train the deep learning model to obtain the third model.
[0115] In the specific implementation, the deep learning model is trained using the labeled big data scripts, and the deep learning model that meets the training end conditions, such as the deep learning model that has been trained a certain number of times or the model output loss has reached convergence, is used as the third model.
[0116] Exemplarily, taking a data testing system implementing a data testing method as an example, the data testing method described in the embodiments of the present application is illustrated.
[0117] Reference Figure 2 The structural diagram of the data testing system shown in the figure includes a platform and external dependencies configured on the platform. The platform mainly includes a front-end, an interface layer, a business layer and a data layer. The external dependencies mainly include an AIGC model and a verification service.
[0118] The front end is mainly used to interact with users. Figure 3As shown in the workflow diagram of the data testing system, the user can fill in or modify the task content related to data testing in the web page provided by the front end, including filling in or modifying the verification rules, verification tasks (such as the script to be tested and its corresponding product requirement text, etc.), and the table information and mapping values involved, so as to manage and maintain the data required for data testing; the data testing system can also display test results and other data to the user through the front end. For example, after the user enters the value of the table name, the back end (that is, other parts of the platform) will save the value of the table name, and automatically connect to the big data cloud platform to query the value of the table field of the associated database table for saving. When the user needs to query the value of the table field, the saved table field value is displayed through the front end, so that the user can further configure the value of the table field corresponding to the first keyword on the front end, and then the mapping relationship between the first keyword configured by the user and the value of the table field can be recorded in the form of a mapping table.
[0119] The interface layer is used to call related interfaces to implement functions according to the functional requirements of the front-end, such as calling database-related interfaces such as MySQL to save data, or calling AIGC model-related interfaces to fine-tune or use the AIGC model.
[0120] The business layer is the code service layer, which is used to execute relevant codes according to the interface calls of the interface layer to realize relevant data interaction, such as data interaction with MySQL, AIGC model or verification service of the data layer.
[0121] After the user configures the verification rules, the script to be tested, the product requirement text, and the product requirement text after keyword replacement (i.e., the target product requirement text) on the platform, the platform submits the target product requirement text to the AIGC model. The AIGC model generates a reference code segment (including sub-code segments corresponding to projections, associations, or filtering conditions) and returns the reference code segment to the platform.
[0122] The platform submits the reference code segment, the script to be tested and the verification rules to the verification service. The verification service automatically matches the reference code segment with the script to be tested to generate a first test result, and uses a third model pre-trained in the verification service to generate a second test result based on the script to be tested and the verification rules. The verification service then generates a test report containing the final test result based on the first test result and the second test result and returns it to the platform.
[0123] It should be noted that, for the method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the embodiments of the present application are not limited by the described order of actions, because according to the embodiments of the present application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily required by the embodiments of the present application.
[0124] Figure 4 : is a structural schematic diagram of a data testing device according to an embodiment of the present application, the device comprising: A first acquisition module is used to acquire a script to be tested and a product requirement text associated with the script to be tested, wherein the product requirement text includes: a semantic description of the business-related functional logic that needs to be implemented when the script to be tested performs a computing task on a database table in a target database; A second acquisition module is used to acquire each first keyword from the product requirement text, where the first keyword is a semantic description associated with a preset table information type, where the preset table information type includes at least one of a table name and a table field of a database table; A third acquisition module, used to acquire target table information corresponding to each of the first keywords from the target database; A first generating module is used to generate, according to the product requirement text and each of the target table information, a reference code segment that conforms to the grammatical rules corresponding to the script to be tested and is used to implement the business-related functional logic described in the product requirement text through a pre-trained first model, wherein the pre-trained first model has the ability to generate a code segment that conforms to the grammatical rules corresponding to the script to be tested; The first test module is used to match the generated reference code segment with the script to be tested to obtain a first test result.
[0125] By adopting the technical solution of the embodiment of the present application, based on the product requirement text and the information of each target table, with the help of the first model, a reference code segment that conforms to the grammatical rules corresponding to the script to be tested and is used to implement the business-related functional logic described in the product requirement text can be automatically generated. The reference code segment can be used to test the grammatical correctness and functional logic correctness of the script to be tested, and the manual writing of test cases can be eliminated, thereby reducing the requirements for testers and solving the problems of long testing cycle and low problem mining rate caused by manually writing test cases.
[0126] Optionally, the device further comprises: A fourth acquisition module is used to acquire each second keyword from the product requirement text, where the second keyword is a semantic description associated with a preset functional logic type, where the preset functional logic type includes at least one of date and time restriction and group aggregation; A first processing module, configured to determine a mapping value of each of the second keywords in the reference code segment; The first generation module comprises: The second generating module is used to generate the reference code segment according to the product requirement text, each target table information, and each determined mapping value through a pre-trained first model.
[0127] Optionally, the second generating module includes: A first generating submodule is used to replace each of the first keywords and each of the second keywords in the product requirement text with each of the target table information and each of the mapping values, so as to obtain a target product requirement text; The second generating submodule is used to input the target product requirement text into the first model to obtain the reference code segment generated by the first model.
[0128] Optionally, the reference code segment includes: a where clause associated with date and time restrictions, and / or a group by clause and aggregation function associated with group aggregation; The first processing module comprises: a second processing module, configured to determine, for a second keyword associated with the date and time restriction, a representation value of a preset date and time or a specific value of the date and time described by the second keyword as a mapping value of the second keyword in the reference code segment, so that when the first model generates the reference code segment, the mapping value is used as a restriction condition of a where clause to generate the where clause associated with the date and time restriction; The third processing module is used to determine, for a second keyword associated with the grouping aggregation, a group by clause and an aggregation function that are used to implement the grouping operation and aggregation operation described by the second keyword and to which the table information is to be supplemented, as a mapping value of the second keyword in the reference code segment, so that when the first model generates the reference code segment, the target table information associated with the second keyword is supplemented into the mapping value to obtain the group by clause and aggregation function associated with the grouping aggregation.
[0129] Optionally, the reference code segment includes sub-code segments corresponding to at least one of the projection, the association relationship and the filtering condition; The first test module includes: A first test submodule is used to match the reference code segment with the script to be tested to obtain a first matching result and at least one second matching result, wherein the first matching result is used to characterize the overall matching degree between the script to be tested and all sub-code segments in the reference code segment, and the second matching result is used to characterize the matching degree between the script to be tested and a single sub-code segment in the reference code segment; The second testing submodule is configured to generate the first testing result according to the first matching result and the at least one second matching result.
[0130] Optionally, the third acquisition module includes: A first acquisition submodule is used to acquire, for a first keyword associated with a table field, a value of a target table field whose similarity with the first keyword is higher than a first set value from the values of the table fields contained in each database table of the target database, and determine the value of the target table field as the target table information corresponding to the first keyword; The second acquisition submodule is used to obtain, for a first keyword associated with a table name, a value of a target table name whose similarity with the first keyword is higher than a second set value from the values of the table names of each database table in the target database, and determine the value of the target table name as the target table information corresponding to the first keyword.
[0131] Optionally, the grammatical rules corresponding to the script to be tested are: structured query language SQL grammatical rules, and the pre-trained first model is used to generate a code segment that complies with the SQL grammatical rules; The device also includes: A first construction module is used to construct a first training sample set according to each product requirement text sample, table information corresponding to each first keyword in each product requirement text sample, and a sample label corresponding to each product requirement text sample, wherein the sample label includes: a code segment that is expected to be generated and conforms to SQL grammar rules; A first training module, used to train the generative pre-trained language model using the first training sample set to obtain a second model; a reward value determination module, used to determine a reward value for the code segment generated by the second model by using a pre-trained reward model, wherein the reward value is used to represent the degree of match between the code segment generated by the second model and the expected code segment that complies with SQL grammar rules; The second training module is used to train the second model according to the reward value corresponding to the code segment generated by the second model to obtain the first model.
[0132] Optionally, the device further comprises: A second test module is used to detect grammatical errors in the script to be tested according to a pre-established verification rule, and generate a second test result, wherein the second test result is used to indicate whether there are grammatical errors in the script to be tested, and the location and type of the grammatical errors; A third test module, used to generate a final test result according to the first test result and the second test result; The pre-established verification rule includes at least one of the following: Syntax validation rules for projections; Syntax validation rules for association relationships; Syntax validation rules for filter conditions.
[0133] Optionally, the second test result is generated by a pre-trained third model, and the device further includes: A script acquisition module, used to acquire each annotated big data script, wherein the annotated big data script is obtained by annotating the location and type of grammatical errors in the big data script according to the pre-established verification rules; The model training module is used to train the deep learning model using the annotated big data scripts to obtain the third model.
[0134] It should be noted that the device embodiment is similar to the method embodiment, so the description is relatively simple, and the relevant parts can be referred to the method embodiment.
[0135] The present application also provides an electronic device, such as Figure 5 As shown, it includes a processor 701, a communication interface 702, a memory 703 and a communication bus 704, wherein the processor 701, the communication interface 702, and the memory 703 communicate with each other through the communication bus 704. Memory 703, used for storing computer programs; The processor 701 is used to execute the program stored in the memory 703, such as the steps of the data testing method disclosed in the embodiment of the present application.
[0136] The communication bus mentioned in the above terminal can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 5 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0137] The communication interface is used for communication between the above terminal and other devices.
[0138] The memory may include a random access memory (RAM) or a non-volatile memory (non-volatile memory), such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.
[0139] The above-mentioned processor can be a general-purpose processor, including a central processing unit, a network processor (Network Processor, NP), etc.; it can also be a digital signal processor (Digital Signal Processing, DSP), an application specific integrated circuit (Application Specific Integrated Circuit, ASIC), a field programmable gate array (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
[0140] The embodiment of the present application also provides a computer-readable storage medium on which a computer program / instruction is stored. When the computer program / instruction is executed by a processor, the data testing method disclosed in the embodiment of the present application is implemented.
[0141] The embodiment of the present application also provides a computer program product, including a computer program / instruction, which, when executed by a processor, implements the data testing method disclosed in the embodiment of the present application.
[0142] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from a website site, a computer, a server or a data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, server or data center. The computer-readable storage medium may be any available medium that a computer can access or a data storage device such as a server or a data center that includes one or more available media integrated. The available medium may be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive Solid State Disk (SSD)), etc.
[0143] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0144] Each embodiment in this specification is described in a related manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0145] The above description is only a preferred embodiment of the present application and is not intended to limit the protection scope of the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application are included in the protection scope of the present application.
Claims
1. A data testing method, characterized in that: The method comprises: Acquire a script to be tested and a product requirement text associated with the script to be tested, wherein the product requirement text includes: a semantic description of the business-related functional logic that needs to be implemented when the script to be tested performs a computing task on a database table in a target database; Acquire each first keyword from the product requirement text, where the first keyword is a semantic description associated with a preset table information type, where the preset table information type includes at least one of a table name and a table field of a database table; Acquire target table information corresponding to each of the first keywords from the target database; According to the product requirement text and each of the target table information, a reference code segment that conforms to the grammatical rules corresponding to the script to be tested and is used to implement the business-related functional logic described in the product requirement text is generated through a pre-trained first model, and the pre-trained first model has the ability to generate a code segment that conforms to the grammatical rules corresponding to the script to be tested; The generated reference code segment is matched with the script to be tested to obtain a first test result.
2. The method according to claim 1, characterized in that Before generating a reference code segment that complies with the grammatical rules corresponding to the script to be tested and is used to implement the business-related functional logic described in the product requirement text and each of the target table information through a pre-trained first model according to the product requirement text, the method further includes: Acquire each second keyword from the product requirement text, where the second keyword is a semantic description associated with a preset function logic type, where the preset function logic type includes at least one of date and time restriction and group aggregation; Determine a mapping value of each of the second keywords in the reference code segment; The method of generating, according to the product requirement text and each of the target table information, a reference code segment that conforms to the grammatical rules corresponding to the script to be tested and is used to implement the business-related functional logic described in the product requirement text through a pre-trained first model, includes: The reference code segment is generated according to the product requirement text, each target table information, and each determined mapping value through a pre-trained first model.
3. The method according to claim 2, characterized in that The step of generating the reference code segment according to the product requirement text, each target table information, and each determined mapping value by using a pre-trained first model includes: In the product requirement text, each of the first keywords and each of the second keywords are replaced with each of the target table information and each of the mapping values to obtain a target product requirement text; The target product requirement text is input into the first model to obtain the reference code segment generated by the first model.
4. The method according to claim 2, characterized in that: The reference code segment includes: a where clause associated with date and time restrictions, and / or a group by clause and an aggregation function associated with group aggregation; The determining of the mapping values of the respective second keywords in the reference code segment includes: For a second keyword associated with the date and time restriction, a representation value of a preset date and time or a specific value of the date and time described by the second keyword is determined as a mapping value of the second keyword in the reference code segment, so that when the first model generates the reference code segment, the mapping value is used as a restriction condition of a where clause to generate the where clause associated with the date and time restriction; For the second keyword associated with the grouping aggregation, the group by clause and aggregation function that will be used to implement the grouping operation and aggregation operation described by the second keyword and to which the table information is to be added are determined as the mapping value of the second keyword in the reference code segment, so that when the first model generates the reference code segment, the target table information associated with the second keyword is added to the mapping value to obtain the group by clause and aggregation function associated with the grouping aggregation.
5. The method according to claim 1, characterized in that The reference code segment includes sub-code segments corresponding to at least one of the projection, the association relationship and the filtering condition; The step of matching the generated reference code segment with the script to be tested to obtain a first test result includes: Matching the reference code segment with the script to be tested to obtain a first matching result and at least one second matching result, wherein the first matching result is used to characterize the overall matching degree between the script to be tested and all sub-code segments in the reference code segment, and the second matching result is used to characterize the matching degree between the script to be tested and a single sub-code segment in the reference code segment; The first test result is generated according to the first matching result and the at least one second matching result.
6. The method according to claim 1, characterized in that Acquiring target table information corresponding to each of the first keywords from the target database includes: For a first keyword associated with a table field, obtaining a value of a target table field whose similarity with the first keyword is higher than a first set value from values of table fields contained in respective database tables of the target database, and determining the value of the target table field as target table information corresponding to the first keyword; For a first keyword associated with a table name, a value of a target table name whose similarity with the first keyword is higher than a second set value is obtained from the values of the table names of each database table of the target database, and the value of the target table name is determined as the target table information corresponding to the first keyword.
7. The method according to any one of claims 1 to 6, characterized in that: The grammatical rules corresponding to the script to be tested are: structured query language SQL grammatical rules, and the pre-trained first model is used to generate a code segment that complies with the SQL grammatical rules; Before generating a reference code segment that complies with the grammatical rules corresponding to the script to be tested and is used to implement the business-related functional logic described in the product requirement text and each of the target table information through a pre-trained first model according to the product requirement text, the method further includes: Constructing a first training sample set according to each product requirement text sample, table information corresponding to each first keyword in each product requirement text sample, and sample labels corresponding to each product requirement text sample, wherein the sample labels include: a code segment that is expected to be generated and conforms to SQL grammar rules; Training the generative pre-trained language model using the first training sample set to obtain a second model; Determine a reward value for the code segment generated by the second model by using a pre-trained reward model, wherein the reward value is used to represent the degree of match between the code segment generated by the second model and the expected code segment that complies with SQL grammar rules; The second model is trained according to the reward value corresponding to the code segment generated by the second model to obtain the first model.
8. The method according to any one of claims 1 to 6, characterized in that: The method further comprises: According to a pre-established verification rule, a grammatical error in the script to be tested is detected to generate a second test result, wherein the second test result is used to indicate whether there is a grammatical error in the script to be tested, and the location and type of the grammatical error; Generate a final test result according to the first test result and the second test result; The pre-established verification rule includes at least one of the following: Syntax validation rules for projections; Syntax validation rules for association relationships; Syntax validation rules for filter conditions.
9. The method according to claim 8, characterized in that The second test result is generated by a pre-trained third model, and the third model is trained by the following steps: Obtaining each annotated big data script, wherein the annotated big data script is obtained by annotating the location and type of syntax errors in the big data script according to the pre-established verification rule; The deep learning model is trained using the annotated big data scripts to obtain the third model.
10. An electronic device, characterized in that: It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; Memory, used to store computer programs; A processor, for implementing the data testing method according to any one of claims 1 to 9 when executing a program stored in a memory.
11. A computer-readable storage medium having a computer program / instruction stored thereon, characterized in that: When the computer program / instructions are executed by a processor, the data testing method according to any one of claims 1 to 9 is implemented.
12. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instructions are executed by a processor, the data testing method according to any one of claims 1 to 9 is implemented.