Software script processing method and apparatus, device, and computer-readable storage medium
By generating reference and recommended snippets and combining them with historical scripts and parameter attribute information, the accuracy and efficiency issues in software script writing are resolved, enabling more efficient software script generation and updating.
Patent Information
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- HUAWEI TECH CO LTD
- Filing Date
- 2025-12-11
- Publication Date
- 2026-07-09
AI Technical Summary
Existing technologies suffer from low accuracy and low generation efficiency in software script writing, especially in complex logic and low code reusability, resulting in high development costs and difficulty in maintenance.
By acquiring the attribute information of the first historical script and the first parameter, a reference fragment is generated. Combined with end-to-end computing logic and business metadata, the recommended fragment is determined, thereby improving the accuracy and efficiency of the software script.
The generated recommended snippets accurately reflect the developers' writing intentions, meet business needs, improve the accuracy and generation efficiency of software scripts, and reduce manual content writing.
Smart Images

Figure CN2025141804_09072026_PF_FP_ABST
Abstract
Description
Software script processing methods, apparatus, devices and computer-readable storage media
[0001] This application claims priority to Chinese Patent Application No. 202411997411.2, filed on December 31, 2024, entitled "Software Script Processing Method, Apparatus, Device and Computer-Readable Storage Medium", the entire contents of which are incorporated herein by reference. Technical Field
[0002] This application relates to the field of computer technology, and in particular to methods, apparatus, devices and computer-readable storage media for processing software scripts. Background Technology
[0003] Software scripts are codes written to automate the operations of software. They allow software to perform tasks according to predefined steps; for example, data storage software can automatically perform tasks such as data backup and storage according to a software script. Summary of the Invention
[0004] This application provides a method, apparatus, device, and computer-readable storage medium for processing software scripts to improve the accuracy of software scripts. The technical solution is as follows.
[0005] Firstly, a method for processing software scripts is provided, comprising: acquiring a first software script; generating a reference fragment based on the attribute information corresponding to a first historical script and a first parameter, wherein the first historical script is a historical script whose similarity to the context information of the first parameter is not less than a first similarity threshold, and the first parameter is any parameter in the first software script; acquiring a first candidate fragment corresponding to the information of end-to-end computation logic, wherein the end-to-end computation logic indicates the computation flow between the source table and the destination table of a second historical script, wherein the second historical script refers to a historical script that references a data table related to the first parameter, the source table is the data table referenced by the second historical script, and the destination table is a data table generated based on the second historical script and the source table; performing conversion processing on the business metadata of the first parameter and the business to which the first software script belongs to obtain a second candidate fragment; and determining a recommended fragment according to the similarity between the reference fragment and the first candidate fragment and the second candidate fragment, wherein the similarity between the recommended fragment and the reference fragment is not less than a second similarity threshold, and the recommended fragment is one or more of the first candidate fragment or the second candidate fragment.
[0006] In this application, recommended segments are determined based on the similarity between reference segments and first and second candidate segments. Since the reference segment is generated based on a first historical script with contextual information similar to the first parameter and the attribute information corresponding to the first parameter, the reference segment can represent the writing intent of the software script related to the first parameter. Since the first candidate segment corresponds to the end-to-end computation logic information of the second historical script, the first candidate segment satisfies the correct end-to-end computation logic and has high accuracy. The second candidate segment is obtained by transforming the business metadata corresponding to the first parameter and the first software script, so the second candidate segment matches the business requirements reflected by the business metadata. That is, the recommended segments generated in this application are determined by combining multiple factors such as the writing intent of the software script related to the first parameter, the end-to-end computation logic, and business requirements, making the recommended segments not only consistent with the writing intent and business requirements, but also improving accuracy and rationality. Furthermore, automatically generating recommended segments can reduce manually written script content and improve the efficiency of software script generation.
[0007] In one possible implementation, the number of second historical scripts is one or more. Obtaining the first candidate fragment corresponding to the information of the end-to-end computation logic includes: determining one or more computation methods for the data in the first parameter from the information of the end-to-end computation logic corresponding to one or more second historical scripts. The information of the end-to-end computation logic corresponding to any second historical script includes one or more computation methods for the data in the source table referenced by any second historical script. The one or more computation methods for any data refer to one or more computation methods used between any data in the source table and the corresponding data in the destination table; generating a first candidate fragment describing one or more computation methods for the data in the first parameter. Determining one or more computation methods for the data in the first parameter from the information of the end-to-end computation logic corresponding to one or more historical scripts allows for accurate and efficient generation of first candidate fragments describing one or more computation methods for the data in the first parameter, ensuring that the first candidate fragment conforms to the correct end-to-end computation logic related to the first parameter.
[0008] In one possible implementation, the business metadata includes one or more of the following: metadata describing data standards, metadata describing data metrics, or metadata describing entity relationships. A second candidate fragment, obtained by transforming one or more of these metadata, satisfies one or more of the following criteria: data standards, data metrics, or entity relationships, thus ensuring high accuracy of the second candidate fragment.
[0009] In one possible implementation, the business metadata includes metadata describing a data standard. The data standard defines one or more first transformation segments and constraints corresponding to multiple types of parameters. Each first transformation segment includes a first reference constraint. The business metadata of the first parameter and the business to which the first software script belongs is transformed to obtain a second candidate segment. This transformation includes: for any first transformation segment, converting the first reference constraint in the first transformation segment into a constraint of the first parameter, thus obtaining a second candidate segment corresponding to the first transformation segment. The constraint of the first parameter corresponds to the type of the first parameter. Converting the first reference constraint in the first transformation segment into a constraint of the first parameter efficiently generates a second candidate segment that matches the first parameter, improving the accuracy of the generated second candidate segment.
[0010] In one possible implementation, the business metadata includes metadata describing the data standard, which defines one or more second transformation segments and constraints corresponding to multiple types of parameters. Each second transformation segment includes a second reference constraint and descriptive information. The business metadata of the first parameter and the business to which the first software script belongs is transformed to obtain a second candidate segment. This transformation includes: for any second transformation segment, converting the second reference constraint in the segment into a constraint of the first parameter, and converting the descriptive information in the segment into attribute sub-information corresponding to the first parameter, thus obtaining a second candidate segment corresponding to the segment. The constraint of the first parameter corresponds to the type of the first parameter, and the attribute sub-information corresponding to the first parameter is a subset of the attribute information corresponding to the first parameter. Converting the second reference constraint in the second transformation segment into a constraint of the first parameter and converting the descriptive information into attribute sub-information corresponding to the first parameter efficiently generates second candidate segments that match the first parameter and its attribute information, improving the accuracy of the generated second candidate segments.
[0011] In one possible implementation, the business metadata includes metadata describing data metrics. The data metrics define one or more third transformation fragments. Each third transformation fragment includes calculated attribute parameters and dimensional attribute parameters. The business metadata of the first parameter and the business to which the first software script belongs is transformed to obtain a second candidate fragment. This transformation includes: for any third transformation fragment, converting the calculated attribute parameters in the third transformation fragment into calculated sub-information of the first parameter, and converting the dimensional attribute parameters in the third transformation fragment into dimensional sub-information of the first parameter, thus obtaining a second candidate fragment corresponding to any third transformation fragment. The calculated sub-information of the first parameter is a subset of the attribute information corresponding to the first parameter that is related to calculation, and the dimensional sub-information of the first parameter is a subset of the attribute information corresponding to the first parameter that is related to dimension. Converting the calculated attribute parameters in the third transformation fragment into calculated sub-information of the first parameter and the dimensional attribute parameters into dimensional sub-information can efficiently generate a second candidate fragment that matches the first parameter and the data metrics, improving the accuracy of the generated second candidate fragment.
[0012] In one possible implementation, the business metadata includes metadata describing entity relationships, which define the connections between different data tables related to the business. The business metadata of the first parameter and the business to which the first software script belongs is transformed to obtain a second candidate fragment. This transformation includes: identifying metadata describing a first entity relationship from the metadata describing entity relationships, which defines the connections between different data tables related to the first parameter; and transforming the metadata describing the first entity relationship to obtain a second candidate fragment, which includes a parameter describing the connections between different data tables related to the first parameter. Transforming the connections between different data tables related to the first parameter into a second candidate fragment improves the efficiency of generating the second candidate fragment, and the generated second candidate fragment matches the entity relationship related to the first parameter, thus exhibiting high accuracy.
[0013] In one possible implementation, before generating the reference fragment based on the first historical script and the attribute information corresponding to the first parameter, the method further includes: determining the second historical script, which is transformed into a first vector, as the first historical script; the similarity between the first vector and the second vector is not less than a first similarity threshold; and the second vector is transformed based on the context information of the first parameter in the first software script. The similarity between the first vector and the second vector reflects the similarity between the second historical script and the context information of the first parameter, thereby accurately determining the first historical script whose similarity to the context information of the first parameter is not less than the first similarity threshold.
[0014] In one possible implementation, before determining the second historical script, which yields the first vector, as the first historical script, the method further includes: segmenting the context information of the first parameter in the first software script; performing vector transformation on the segmentation results of the context information to obtain a second vector related to the context information; segmenting the second historical script; performing vector transformation on the segmentation results of the second historical script to obtain multiple third vectors; and determining, among the multiple third vectors, a first vector whose similarity to the second vector is not less than a first similarity threshold. By segmenting the second historical script and the context information of the first parameter and performing vector transformation, the similarity between vectors can be efficiently determined based on the obtained vectors, thereby identifying the first historical script whose similarity to the context information of the first parameter is not less than the first similarity threshold.
[0015] In one possible implementation, a reference fragment is generated based on a first historical script and the attribute information corresponding to the first parameter. This includes: inputting the first historical script and attribute information into a first model, and generating the reference fragment through the first model. The first model enables efficient and automatic generation of reference fragments.
[0016] In one possible implementation, after determining the recommended segment based on the similarity between the reference segment and the first candidate segment and the second candidate segment, the method further includes: displaying the recommended segments, wherein the number of recommended segments is one or more; and, upon receiving a confirmation operation for any recommended segment, updating the first software script based on that recommended segment to obtain the second software script. Displaying the recommended segments provides a more intuitive representation of the recommended segments determined in this application, facilitating the selection of the desired recommended segment from the displayed segments, and enabling accurate and efficient updating of the first software script based on the confirmed recommended segments.
[0017] In one possible implementation, the method further includes: displaying source information for the recommended segments, where the source information of any recommended segment refers to the information on which the generation of any recommended segment is based. Displaying the source information of the recommended segments facilitates more accurate selection of recommended segments based on the source information.
[0018] Secondly, a software script processing apparatus is provided, comprising: an acquisition module for acquiring a first software script; a generation module for generating a reference fragment based on a first historical script and attribute information corresponding to a first parameter, wherein the first historical script is a historical script whose similarity to the context information of the first parameter is not less than a first similarity threshold, and the first parameter is any parameter in the first software script; the acquisition module is further configured to acquire a first candidate fragment corresponding to information of end-to-end computation logic, wherein the end-to-end computation logic indicates the computation flow from the source table to the destination table of a second historical script, wherein the second historical script refers to a historical script that references a data table related to the first parameter, the source table is the data table referenced by the second historical script, and the destination table is a data table generated based on the second historical script and the source table; the generation module is further configured to perform conversion processing on the business metadata of the first parameter and the business to which the first software script belongs, to obtain a second candidate fragment; and a determination module for determining a recommended fragment according to the similarity between the reference fragment and the first candidate fragment and the second candidate fragment, wherein the similarity between the recommended fragment and the reference fragment is not less than a second similarity threshold, and the recommended fragment is one or more of the first candidate fragment or the second candidate fragment.
[0019] In one possible implementation, the number of second historical scripts is one or more. The acquisition module is used to determine one or more calculation methods for the data in the first parameter from the information of the end-to-end calculation logic corresponding to one or more second historical scripts. The information of the end-to-end calculation logic corresponding to any second historical script includes one or more calculation methods for the data in the source table referenced by any second historical script. The one or more calculation methods for any data refers to one or more calculation methods used between any data in the source table and the corresponding data in the destination table. A first candidate fragment is generated to describe one or more calculation methods for the data in the first parameter.
[0020] In one possible implementation, business metadata includes one or more of the following: metadata for describing data standards, metadata for describing data metrics, or metadata for describing entity relationships.
[0021] In one possible implementation, the business metadata includes metadata for describing data standards, which define constraints corresponding to one or more first transformation segments and multiple types of parameters. Each first transformation segment includes a first reference constraint. The generation module is used to convert the first reference constraint in any first transformation segment into a constraint of a first parameter for any first transformation segment, thereby obtaining a second candidate segment corresponding to any first transformation segment. The constraint of the first parameter corresponds to the type of the first parameter.
[0022] In one possible implementation, the business metadata includes metadata for describing data standards, which define constraints corresponding to one or more second transformation segments and multiple types of parameters. Each second transformation segment includes a second reference constraint and descriptive information. The generation module is used to convert the second reference constraint in any second transformation segment into the constraint of a first parameter, and to convert the descriptive information in any second transformation segment into attribute sub-information corresponding to the first parameter, thereby obtaining a second candidate segment corresponding to any second transformation segment. The constraint of the first parameter corresponds to the type of the first parameter, and the attribute sub-information corresponding to the first parameter is a subset of the attribute information corresponding to the first parameter.
[0023] In one possible implementation, the business metadata includes metadata describing data metrics, which define one or more third transformation fragments. Each third transformation fragment includes calculated attribute parameters and dimensional attribute parameters. The generation module is used to, for any third transformation fragment, convert the calculated attribute parameters in the third transformation fragment into calculated sub-information of a first parameter, and convert the dimensional attribute parameters in the third transformation fragment into dimensional sub-information of the first parameter, thereby obtaining a second candidate fragment corresponding to any third transformation fragment. The calculated sub-information of the first parameter is a subset of the attribute information corresponding to the first parameter that is related to calculation, and the dimensional sub-information of the first parameter is a subset of the attribute information corresponding to the first parameter that is related to dimension.
[0024] In one possible implementation, the business metadata includes metadata describing entity relationships, which define the connections between different data tables related to the business; a generation module is used to determine metadata describing a first entity relationship from the metadata describing entity relationships, which defines the connections between different data tables related to a first parameter; the metadata describing the first entity relationship is transformed to obtain a second candidate fragment, which includes a parameter describing the connections between different data tables related to the first parameter.
[0025] In one possible implementation, the determining module is further configured to determine the second historical script that has been transformed into the first historical script as the first historical script, wherein the similarity between the first vector and the second vector is not lower than a first similarity threshold, and the second vector is transformed based on the context information of the first parameter in the first software script.
[0026] In one possible implementation, the determining module is further configured to segment the context information of the first parameter in the first software script, perform vector transformation on the segmentation result of the context information to obtain a second vector related to the context information; segment the second historical script, perform vector transformation on the segmentation result of the second historical script to obtain multiple third vectors; and determine the first vector among the multiple third vectors whose similarity to the second vector is not lower than a first similarity threshold.
[0027] In one possible implementation, a generation module is used to input a first historical script and attribute information into a first model, and generate a reference fragment through the first model.
[0028] In one possible implementation, the device further includes a display module and an update module. The display module is used to display recommended segments, and the number of recommended segments is one or more. The update module is used to update the first software script based on any recommended segment to obtain a second software script upon receiving a confirmation operation for any recommended segment.
[0029] In one possible implementation, the display module is also used to display source information of the recommended segments, where the source information of any recommended segment refers to the information on which the generation of any recommended segment is based.
[0030] Thirdly, a computer program (product) is provided, comprising: computer program code, which, when executed by a computer, causes the computer to perform the methods described in the above aspects.
[0031] Fourthly, a computer-readable storage medium is provided that stores a program or instructions, wherein when the program or instructions are run on a computer, the methods described in the above aspects are executed.
[0032] Fifthly, a chip is provided, including a processor, for retrieving and executing instructions stored in memory, causing a computer equipped with the chip to perform the methods described in the foregoing aspects.
[0033] Sixthly, another chip is provided, including: an input interface, an output interface, a processor, and a memory, wherein the input interface, the output interface, the processor, and the memory are connected by an internal connection path, the processor is used to execute code in the memory, and when the code is executed, the computer with the chip installed performs the methods in the above aspects.
[0034] In a seventh aspect, a software script processing device is provided, the device including a processor coupled to a memory; the memory stores at least one instruction, which is loaded and executed by the processor, so that the software script processing device implements the software script processing methods of the above aspects.
[0035] It should be understood that the beneficial effects achieved by the technical solutions and corresponding possible implementations of the second to seventh aspects of this application can be found in the technical effects of the first and second aspects and their corresponding possible implementations described above, and will not be repeated here. Furthermore, the software script processing device mentioned in the second aspect can be the chip mentioned in the fifth or sixth aspect, or the software script processing device can also be the device mentioned in the seventh aspect. Attached Figure Description
[0036] Figure 1 is a flowchart of a software script completion method provided by related technologies;
[0037] Figure 2 is a schematic diagram of an implementation scenario provided by an embodiment of this application;
[0038] Figure 3 is a flowchart illustrating a software script processing method provided in an embodiment of this application;
[0039] Figure 4 is a schematic diagram of a first software script provided in an embodiment of this application;
[0040] Figure 5 is a schematic diagram of a process for generating a reference fragment according to an embodiment of this application;
[0041] Figure 6 is a schematic diagram of a second history script provided in an embodiment of this application;
[0042] Figure 7 is a logical relationship diagram provided in an embodiment of this application;
[0043] Figure 8 is a schematic diagram of a data standard definition conversion segment and constraints provided in an embodiment of this application;
[0044] Figure 9 is a schematic diagram of the key attributes of a data indicator definition and the third transformation segment provided in an embodiment of this application;
[0045] Figure 10 is a schematic diagram of entity relationship conversion provided in an embodiment of this application;
[0046] Figure 11 is a schematic diagram of a process for determining the similarity between segments based on an abstract syntax tree according to an embodiment of this application;
[0047] Figure 12 is a schematic diagram of a display interface provided in an embodiment of this application;
[0048] Figure 13 is a schematic diagram of another display interface provided in an embodiment of this application;
[0049] Figure 14 is a schematic diagram of another display interface provided in an embodiment of this application;
[0050] Figure 15 is a schematic diagram of another display interface provided in an embodiment of this application;
[0051] Figure 16 is a schematic diagram of another display interface provided in an embodiment of this application;
[0052] Figure 17 is a schematic diagram of another display interface provided in an embodiment of this application;
[0053] Figure 18 is a schematic diagram of a software script processing procedure provided in an embodiment of this application;
[0054] Figure 19 is a schematic diagram of the structure of a software script processing device provided in an embodiment of this application;
[0055] Figure 20 is a schematic diagram of the structure of a software script processing device provided in an embodiment of this application. Detailed Implementation
[0056] The terminology used in the implementation section of this application is for the purpose of explaining specific embodiments of this application only, and is not intended to limit this application.
[0057] Software scripts are code written to automate the operations of software, specifically to execute a series of operations within a particular software application. Software scripts can be written in various languages, such as Structured Query Language (SQL), Python (a scripting language), or JavaScript (a client-side scripting language), or in compiled languages like C++ or Java.
[0058] A software script consists of one or more script fragments (or code fragments). A software fragment consists of one or more lines of statements (or one or more lines of program code). Software scripts are typically generated by developers manually inputting statements containing functions, variables, or other software script elements into the client. However, some scripting languages are quite complex, or the logic corresponding to the software script is quite complex, which places high demands on the developer's skills. Developers are required to be proficient in the characteristics of complex scripting languages and the basic knowledge of function libraries. Furthermore, when encountering complex logic, developers need to write statements corresponding to complex operations such as nested functions and multi-level queries, which may make the software script verbose, increase the developer's writing cost, and make the software script difficult to maintain.
[0059] For example, SQL is a declarative language that is relatively cumbersome to write. Extract-transform-load (ETL) is a data processing workflow used in data governance platforms, and business operations can be defined through software scripts. Developers define ETL-related business operations such as data transformation, cleaning, and aggregation by writing SQL software scripts. The process of writing SQL software scripts to define ETL-related business operations requires developers to be proficient in various features of SQL and the details of different function libraries supported by different SQL dialects. When encountering more complex processing logic, advanced operations such as nested subqueries, multi-table multi-condition joins, and unions are also required. This often makes the software scripts lengthy and difficult to maintain, making the writing of SQL software scripts used to define ETL-related business operations even more complex.
[0060] In addition, some scripting languages have low code reusability, which means that developers need to write a large number of basic or general statements when writing each software script, resulting in low efficiency in software script generation.
[0061] For example, because SQL is a declarative language, different software scripts written in SQL do not have the referencing mechanism common in high-level programming languages (such as Java, C++, etc.), resulting in a low reuse rate of duplicate code in software scripts written in SQL, which in turn makes the software scripts written in SQL less efficient.
[0062] In the field of computer technology, code completion is typically performed on the client side to improve the efficiency of software script generation. Code completion is a common programming tool feature for software scripts, widely used in code editors for various web-based front-ends and standalone application (APP) clients. By providing intelligent suggestions and code snippets while writing software scripts, it helps developers write software scripts faster and better, improving development efficiency and reducing errors.
[0063] Referring to Figure 1, a flowchart of a software script completion method provided by related technologies is shown. Developers interact with an editor on the client side to write software scripts and generate the software script for editing. The software script is input into an editor during editing. The editor identifies the dialect environment of the currently edited software script and outputs basic completion suggestions based on basic information such as function libraries, data tables, fields, or functions in the basic metadata database of the platform-supported data cluster. These basic completion suggestions include function names, database names, data table names, field names in the data tables, or commonly used keywords in the software script, determined based on the basic information.
[0064] However, the script completion capabilities of related technologies are limited, and the coding elements suggested by these technologies do little to improve the efficiency of software script writing. Because these technologies cannot identify the actual business process and developer intent corresponding to the factors to be completed (such as a specific transformation, cleansing, or aggregation operation), they cannot provide suggestions or hints based on the actual business process or developer intent, resulting in low accuracy. If these technologies are used to complete software scripts for specific business operations requiring completion, relying on developers to write them manually, the editor's auxiliary functions are very limited. Furthermore, this limited script completion capability of these technologies cannot solve the problem of low reusability in software scripts; some similar, reusable code within software scripts cannot be suggested by these technologies, thus limiting their ability to improve the efficiency of software script writing.
[0065] Therefore, there is an urgent need for a method to improve the accuracy and generation efficiency of software scripts. This application provides a software script processing method that can improve the accuracy and generation efficiency of software scripts.
[0066] Referring to Figure 2, a schematic diagram of an implementation scenario provided by an embodiment of this application is shown. This implementation scenario includes one or more processing devices 11, each equipped with an editor or data development module for generating software scripts. The types of the one or more processing devices 11 can be the same or different; for example, the processing device 11 can be a terminal such as a mobile phone, personal computer, or laptop computer, or a network device such as a server, or a data processing platform, etc.
[0067] Referring to Figure 3, a flowchart illustrating a software script processing method according to an embodiment of this application is shown. This method can be applied to one or more processing devices shown in Figure 2, and includes, but is not limited to, S301 to S305 below.
[0068] S301, Obtain the first software script.
[0069] The first software script can be a software script generated based on any scripting language or programming language. The first software script can be an incomplete software script or a completed script. This application embodiment does not limit the method for obtaining the first software script. For example, the processing device can receive the first software script input or uploaded by the developer through the processing device; or, the processing device can also receive the first software script sent by other devices; or, the processing device can automatically generate the first software script based on the developer's needs, thereby achieving the acquisition of the first software script.
[0070] In this embodiment, the first software script is processed to generate recommended fragments, that is, script fragments used to implement the functions of the first software script are generated, so as to perform different processing on different types of first software scripts based on the recommended fragments.
[0071] For example, recommended snippets can be used to automatically complete incomplete first software scripts, improving the efficiency and accuracy of generating the first software script. Alternatively, recommended snippets can be used to update or validate completed first software scripts, improving their accuracy and rationality.
[0072] In this embodiment, the function of the processing device to generate recommended segments can be triggered in different ways. For example, if the first software script is an incomplete software script that a developer is entering through an editor on the processing device, the function of generating recommended segments is automatically triggered when a certain statement in the first software script has been partially entered. Referring to Figure 4, a schematic diagram of a first software script provided in this embodiment is shown. The first software script in Figure 4 includes multiple lines of statements, where the statements within the dashed boxes are partial statements that the developer is entering through an editor on the processing device. The processing device recognizes the statements being entered and automatically triggers the function of generating recommended segments.
[0073] Alternatively, developers can select parameters, statements, or fragments in the first software script and execute an operation to request the generation of recommended fragments, at which point the processing device will generate recommended fragments.
[0074] Optionally, when the processing device enables the function of generating recommended snippets, it may display a pop-up window related to permissions, requesting developers to grant read permissions to the metadata center and historical scripts, or asking developers whether to allow sharing of historical scripts to enable the function of generating recommended snippets. After obtaining authorization from the developers, the recommended snippets are generated.
[0075] S302, based on the attribute information corresponding to the first historical script and the first parameter, a reference fragment is generated. The first historical script is a historical script whose similarity to the context information of the first parameter is not lower than the first similarity threshold. The first parameter is any parameter in the first software script.
[0076] The first parameter can be one or more types of parameters in the first software script. The first parameter can be a field, field name, character, character name, numerical value, or date / time parameter. The first parameter can be a parameter from an incomplete input statement in the first software script, or a parameter from the selected content in the first software script that needs to generate a recommended segment.
[0077] The attribute information corresponding to the first parameter refers to the attribute information of the data table to which the data related to the first parameter in the first software script belongs. The attribute information of any data table is used to describe the characteristics and settings of the data table and its columns. The attribute information of any data table includes the table's description, storage engine information, comment information, data type, data length or auto-increment attribute information of the data in the data table, constraint information or index information, etc.
[0078] The context information of the first parameter includes all other statements in the first software script besides the statement to which the first parameter belongs. For example, in the first software script shown in Figure 4, the first parameter is upstream_response_time. The other statements in the first software script constitute the context information of the first parameter. For example, the statements upstream_response_time tp99_response_time and fromsre_dwd.dwd_cls_apig_log_common_full_1d in Figure 4 all belong to the context information of the first parameter.
[0079] Before generating a reference fragment based on the first historical script and the attribute information corresponding to the first parameter, the processing device first obtains the first historical script. Optionally, the first historical script may be determined by other processing devices or management devices connected to the processing device and sent to the processing device used to execute the software script processing method provided in the embodiments of this application; or, the first historical script may be determined by the processing device itself. Other processing devices, management devices, or the processing device used to execute the software script processing method provided in the embodiments of this application may determine the first historical script in the same way. The following description uses the example of the first historical script being determined by the processing device used to execute the software script processing method provided in the embodiments of this application to illustrate the method of determining the first historical script.
[0080] The processing device can identify the second historical script from which the first vector is transformed as the first historical script. The similarity between the first vector and the second vector is not lower than a first similarity threshold. The second vector is transformed based on the context information of the first parameter in the first software script. The second historical script refers to a historical script that references a data table related to the first parameter. The second historical script can be a historical script written by the same developer as the first software script, or it can be a historical script belonging to the same business as the first software script but written by a different developer. Regardless of which developer wrote the second historical script, it is a completed historical script that was published before the recommended segment was determined.
[0081] This application embodiment uses the similarity between the first vector and the second vector to reflect the similarity between the second historical script and the context information of the first parameter, thereby accurately determining the first historical script whose similarity with the context information of the first parameter is not lower than the first similarity threshold.
[0082] For example, before determining the second historical script from which the first vector is transformed as the first historical script, the method further includes: segmenting the context information of the first parameter in the first software script; performing vector transformation on the segmentation results of the context information to obtain a second vector related to the context information; segmenting the second historical script; performing vector transformation on the segmentation results of the second historical script to obtain multiple third vectors; and determining a first vector among the multiple third vectors whose similarity to the second vector is not lower than a first similarity threshold. Here, the segmentation results of the context information and the segmentation results of the second historical script are both script fragments, and a script fragment may include one or more lines of statements. Performing vector transformation on the segmentation results refers to embedding the segmentation results, using one or more vectors to describe the features of the content of a segmentation result.
[0083] There are several ways to determine the first vector among multiple third vectors whose similarity to the second vector is not less than a first similarity threshold. For example, one can determine the distance between each second vector and each third vector, and from the obtained distances, determine a set of second and third vectors whose similarity is not greater than the first distance threshold. The distance between the second and third vectors can be a distance measured using different methods, such as Euclidean distance, cosine distance, Manhattan distance, or Chebyshev distance. The first distance threshold is a distance threshold consistent with the measurement method, and it is obtained by converting it through a first similarity threshold. The first similarity threshold can be set based on experience or user needs.
[0084] For example, if the number of second vectors is 2 and the number of third vectors is 5, calculate the distances between each of the 5 third vectors and the second vector 1, obtaining 5 distances L1 to L5. Then calculate the distances between each of the 5 third vectors and the second vector 2, obtaining another 5 distances L6 to L10, for a total of 10 distances L1 to L10. Here, L1, L3, and L5 are distances greater than a first distance threshold. L1 is the distance between the third vector 1 and the second vector 1, therefore the third vector 1 is the first vector with a similarity to the second vector 1 that is not less than the first similarity threshold. L3 is the distance between the third vector 3 and the second vector 1, therefore the third vector 2 is the first vector with a similarity to the second vector 1 that is not less than the first similarity threshold. L5 is the distance between the third vector 5 and the second vector 2, therefore the third vector 5 is the first vector with a similarity to the second vector 2 that is not less than the first similarity threshold.
[0085] After identifying a first vector whose similarity to the second vector is not less than a first similarity threshold, the script segment from which this first vector is transformed can be identified, and the second historical script to which this script segment belongs can be identified, thereby determining the first historical script. This embodiment of the application segments and transforms the second historical script and the context information of the first parameter into vectors, thereby efficiently determining the similarity between vectors based on the obtained vectors, and thus efficiently and accurately determining the first historical script whose similarity to the context information of the first parameter is not less than the first similarity threshold.
[0086] After determining the first historical script, a reference fragment can be generated based on the first historical script and the attribute information corresponding to the first parameter. Optionally, the processing device can input the first historical script and attribute information into a first model, and generate the reference fragment through the first model. The first model can be a large language model (LLM) or a Weaviate (a database model), etc. The first model can efficiently and automatically generate reference fragments. For example, the reference fragment generated based on the attribute information corresponding to the first parameter and the first historical script in Figure 4 can be as follows.
[0087] Max(upstream_response_time)over(partition by hour,minute,second)
[0088] The generated reference fragment has a high degree of relevance to the first parameter and can reflect the developer's writing intent for the software script related to the first parameter. In this embodiment, the process of vectorizing the context information of the first parameter and the second historical script, and determining the first vector and the first historical script based on the distance between the second vector and the third vector, and generating a reference fragment based on the attribute information corresponding to the first historical script and the first parameter, can be called the retrieval-augmented generation (RAG) process.
[0089] Referring to Figure 5, a schematic diagram of a process for generating reference fragments according to an embodiment of this application is shown. The second historical script and the current context (i.e., the context information of the first parameter) are segmented and vectorized to obtain a third vector and a second vector. Semantic retrieval is performed on the third and second vectors, that is, by calculating the similarity between each third vector and the second vector, a first historical script with a similarity to the context information of the first parameter not lower than a first similarity threshold is determined, resulting in TOP K related documents, which include the first historical script. Then, the TOP K related documents and related table attribute (Schema) information (i.e., the attribute information corresponding to the first parameter) are combined to obtain the input LLM prompt. The Prompt content is: You are a professional ETL engineer, and you are proficient in writing ETL scripts using SQL. Please provide several most reasonable SQL operation fragments for the first parameter in the format of SQL fragments, which are consistent with the current context, based on the TOP K related documents and related table Schema information as reference materials. The LLM is required to perform an SQL continuation task. Based on the input Prompt, TOP K related documents, and related table Schema information, the LLM generates reference fragments for SQL continuation. Using RAG for SQL continuation allows LLM to help identify the developer's possible coding intent for the software script and predict what actions the developer might take on the first parameter.
[0090] S303, obtain the first candidate segment corresponding to the information of the end-to-end computation logic. The end-to-end computation logic indicates the computation process between the source table and the destination table of the second historical script. The second historical script refers to the historical script that references the data table related to the first parameter. The source table is the data table referenced by the second historical script. The destination table is the data table generated based on the second historical script and the source table.
[0091] Referring to Figure 6, a schematic diagram of a second historical script provided in an embodiment of this application is shown. The source table referenced by this second historical script is: zgh_test5`.`dwd_t_customer_count_metrics_add. The source table includes multiple fields or multiple attributes, or in other words, multiple columns of data. For example, in the logical relationship diagram shown in Figure 7, user_cnt, region_code, rep_office_code, cust_track_code, and rep_office_code each represent 5 fields, that is, 5 columns of data. Analyzing the second historical script shown in Figure 6, it can be seen that based on the second historical script and the source table, an intermediate table a0 is first generated. During the generation of intermediate table a0, as shown in Figures 6 and 7, the `Select` operation directly selects `user_cnt`, `rep_office_code`, `cust_track_code`, and `public_cloud_na` from the source table. It also selects `region_code` and calculates it using method 3, which is `upper(`region_code`)`, essentially changing the letters in `region_code` from the source table to their corresponding uppercase letters. Similarly, it selects `rep_office_code` from the source table and calculates it using method 4, which extracts three characters from the string `rep_office_code` in the source table, resulting in the substring `office_code` in intermediate table a0.
[0092] After generating intermediate table a0, intermediate table a1 is generated based on the second historical script and intermediate table a0. During the generation of intermediate table a1, as shown in Figures 6 and 7, the Select operation directly selects region_code, rep_office_code, cust_track_code, and public_cloud_na from intermediate table a0. It also selects user_cnt from intermediate table a0 and calculates it using calculation method 2 to obtain sum_cnt in intermediate table a1. Calculation method 2 is sum(`a0`.`user_cnt`)over(partitionby……), which sums the data in the user_cnt column of intermediate table a0 and uses the sum function as a window function to obtain sum_cnt in intermediate table a1.
[0093] After generating intermediate table a1, a common table expression (CTE) table is generated based on the second historical script and intermediate table a1. During the CTE table generation process, as shown in Figures 6 and 7, the `select` operation directly selects `sum_cnt`, `regiom_code`, `rep_office_code`, and `public_cloud_na` from intermediate table a1. It also selects `cust_track_code` from intermediate table a1 and calculates it using calculation method 1 to obtain `track_code_len` in the CTE table. Calculation method 1 is to calculate the length using `char_length(`a1`.`cust_track_code`), which means calculating the length of the data in the `cust_track_code` column of intermediate table a1 and using the calculated length as `track_code_len` in the CTE table.
[0094] After generating the CTE table, the destination table `output_abc` is generated based on the second historical script and the CTE table. During the generation of the destination table, as shown in Figures 6 and 7, the `select` operation directly selects `sum_cnt`, `region_code`, `rep_office_code`, `track_code_len`, and `public_cloud_na` from the CTE table to obtain the destination table.
[0095] As shown in Figures 6 and 7, the process of transferring data from the source table referenced by the second historical script to the corresponding data in the destination table generated based on the second historical script may involve one or more calculations, or it may not require any calculations at all. Based on the content shown in Figures 6 and 7, the end-to-end computation logic (or processing logic) corresponding to the second historical script that can be extracted includes:
[0096] upper(`region_code`);
[0097] char_length(`cust_track_code`);
[0098] sum(`user_cnt`)over(partition by…….);
[0099] substring(`rep_office_code`,1,3) etc.
[0100] One of the end-to-end computation logics records a computation method that data needs to go through from the source table to the destination table.
[0101] This application embodiment does not limit the method by which the processing device obtains the end-to-end computation logic corresponding to each second historical script. Optionally, the processing device can, based on the second historical script, parse the code structure of each second historical script, starting from the Insert statement, and parse the correspondence between the data in the destination table and the source table layer by layer from top to bottom to obtain the end-to-end computation logic corresponding to the source table. Alternatively, other processing devices or management devices can extract the end-to-end computation logic corresponding to each second historical script and then send it to the processing device used to execute the software script processing method provided in this application embodiment.
[0102] The number of second historical scripts is one or more. For example, the processing device obtains a first candidate segment corresponding to information about end-to-end computation logic, including: determining one or more computation methods for data in a first parameter from the information about end-to-end computation logic corresponding to one or more second historical scripts, wherein the information about end-to-end computation logic corresponding to any second historical script includes one or more computation methods for data in a source table referenced by any second historical script, and the one or more computation methods for any data refer to one or more computation methods used between any data in the source table and the corresponding data in the destination table; generating a first candidate segment describing one or more computation methods for the data in the first parameter.
[0103] Since the data in the source table referenced by any second historical script may include the data in the first parameter, or it may include data other than the data in the first parameter, it is necessary to filter the information of the end-to-end computation logic corresponding to each second historical script, filter out the information of the end-to-end computation logic describing one or more computation methods for the data in the first parameter, and thus determine one or more computation methods for the data in the first parameter.
[0104] After determining one or more calculation methods for the data in the first parameter, a first candidate fragment can be generated to describe these calculation methods. The first candidate fragment may include fragments describing calculation methods that occur frequently in the second historical script; in other words, the first candidate fragment can describe high-frequency historical operations on the data in the first parameter. For example, in the information of the end-to-end calculation logic corresponding to one or more second historical scripts, there are calculation methods 1, 2, and 3 for data A in the first parameter. Calculation method 1 appears 3 times in the information of the end-to-end calculation logic corresponding to one or more second historical scripts, calculation method 2 appears 13 times, and calculation method 3 appears 21 times. The average occurrence count of calculation methods 1, 2, and 3 is determined to be 9 times. Calculation methods 2 and 3, whose occurrence counts are higher than the average, are the calculation methods that occur frequently, and thus represent high-frequency historical operations on data A in the first parameter. The first candidate fragment generated can be a fragment used to describe calculation method 2 and calculation method 3.
[0105] For example, the first candidate fragment generated can be as follows.
[0106] round(upstream_time_response)
[0107] case when upstream_time_response>10.0then`time_out`else`success`
[0108] In this application embodiment, one or more calculation methods for the data in the first parameter are determined in the end-to-end calculation logic corresponding to one or more second historical scripts. This allows for the accurate and efficient generation of one or more calculation methods for the data in the first parameter. Then, a first candidate segment is generated to describe one or more calculation methods for the data in the first parameter, so that the first candidate segment conforms to the correct end-to-end calculation logic related to the first parameter, thereby improving the reuse rate of similar segments among related software scripts.
[0109] S304, the business metadata of the first parameter and the business to which the first software script belongs is transformed to obtain the second candidate fragment.
[0110] Business metadata is a crucial concept in data governance platforms. It describes the business meaning of data and includes elements such as data definition, format specifications, executable computational logic on the data, and relationships between the data and other data. Business metadata provides necessary contextual information for data, making it easier to understand and use. Business metadata is typically user-defined.
[0111] Optionally, business metadata includes one or more of the following: metadata describing data standards, metadata describing data metrics, or metadata describing entity relationships. Different metadata leads to different methods of transforming to obtain the second candidate fragment, resulting in different second candidate fragments.
[0112] In one possible implementation, business metadata includes metadata describing data standards. Data standards define normative constraints on data consistency, accuracy, and integrity. The purpose of data standards is to ensure the consistency and accuracy of data during internal and external use and exchange, thereby improving data quality and availability, supporting effective data sharing and interoperability, and reducing data management costs. In embodiments of this application, data standards are used to define constraints corresponding to one or more first transformation segments and multiple types of parameters, where each first transformation segment includes a first reference constraint.
[0113] For example, referring to Figure 8, a schematic diagram of a data standard definition transformation segment and constraint conditions provided in an embodiment of this application is shown. As shown in Figure 8, the data standard defines various constraint types according to the different parameter types, and different constraint types correspond to different constraint conditions. The constraint types shown in Figure 8 include field type constraints corresponding to field type parameters, non-empty constraints corresponding to non-empty parameters, character type constraints corresponding to character type parameters, numeric type constraints corresponding to numeric type parameters, and date and time type constraints corresponding to date and time type parameters.
[0114] The field type constraint condition is: `typeof(parameter col) = type name`, where the parameter is the type name, and `typeof` is an SQL operator. The NOT NULL constraint condition is: `parameter col is not null`. Character type constraints include length constraints, encoding format constraints, and enumeration value constraints. The length constraint condition is: `length(col) ≤ upper bound`, where the parameters are the upper and lower bounds. The encoding format constraint condition is: `col rlike regular expression`, where the parameter is the encoding format regular expression. The enumeration value constraint condition is: `col in(enumeration set)`, where the parameter is the enumeration set. Numeric type constraints include numeric range constraints and step constraints. The numeric range constraint condition is: `col between lower bound and upper bound`, where the parameters are the upper and lower bounds. The step constraint condition is: `col % step = 0`, where the parameter is the step size. Date and time type constraints include format constraints, range constraints, and enumeration value constraints. The format constraint condition is: to_date(col, format), and the corresponding parameter is the format. The range constraint condition is: col between lower bound and upper bound, and the corresponding parameters are the upper bound of the date and the lower bound of the date. The enumeration value constraint condition is: col in(enumeration set), and the corresponding parameter is the enumeration set.
[0115] The data standard also defines different actions, each corresponding to a different transformation segment. In other words, a transformation segment is a script segment used to describe the format of an action. As shown in Figure 8, the transformation segment corresponding to the repair action is: `case when not constraint then default value else col`; the transformation segment corresponding to the marking action is: `case when constraint then true else false`; the transformation segment corresponding to the statistics action is: `count_if(constraint)`; and the transformation segment corresponding to the filtering action is: `select * from table_xxx where constraint`. The constraint in each transformation segment is the first reference constraint in that segment.
[0116] In another possible implementation, as shown in Figure 8, each transformation segment may include not only constraints but also other descriptive information. For example, the transformation segment corresponding to a repair action may include default values in addition to constraints. That is, business metadata includes metadata describing data standards. Data standards can also be used to define constraints corresponding to one or more second transformation segments and multiple types of parameters. Any second transformation segment includes second reference constraints and descriptive information.
[0117] When the business metadata includes metadata describing data standards, the business metadata of the first parameter and the business to which the first software script belongs is transformed to obtain a second candidate fragment. This transformation includes: for any first transformed fragment, converting the first reference constraint in the first transformed fragment into the constraint of the first parameter, thus obtaining a second candidate fragment corresponding to the first transformed fragment, where the constraint of the first parameter corresponds to the type of the first parameter. Alternatively, it includes: for any second transformed fragment, converting the second reference constraint in the second transformed fragment into the constraint of the first parameter, and converting the descriptive information in the second transformed fragment into attribute sub-information corresponding to the first parameter, thus obtaining a second candidate fragment corresponding to the second transformed fragment, where the constraint of the first parameter corresponds to the type of the first parameter, and the attribute sub-information corresponding to the first parameter is a subset of the attribute information corresponding to the first parameter.
[0118] Assuming the first parameter is the first parameter in Figure 4, and the first parameter is field A, field A is a floating-point type field with the data standard constraint that "the value must be greater than 0.0 and the default value (default value) is 3.0". That is, the constraint condition of the first parameter is that the value must be greater than 0.0, and the attribute sub-information includes the default value of 3.0. Then the second candidate fragment obtained based on the first parameter and the first conversion fragment or the second conversion fragment can be as follows.
[0119] The second candidate fragment corresponding to the repair action is: case when not A>0.0then 3.0else col, where A>0.0 is the constraint condition for replacing the first parameter of the second reference constraint condition in the second transformation fragment, and 3.0 is the attribute sub-information for replacing the default value of the description information.
[0120] The second candidate segment corresponding to the marked action is: case when A>0.0then true else false, where A>0.0 is the constraint condition that replaces the first parameter of the first reference constraint condition in the first transformation segment.
[0121] The second candidate fragment corresponding to the statistical action is: count_if(A>0.0)over()as count_A, where A>0.0 is the constraint condition of the first parameter of the second reference constraint condition in the second transformation fragment, and over()as count A is the attribute sub-information of the replacement description information, which is defined by the relevant information in the metadata corresponding to the first parameter.
[0122] The second candidate segment corresponding to the filtering action is: select…from T where A>0.0, where A>0.0 is the constraint condition of the first parameter of the second reference constraint condition in the second transformation segment, T is the attribute sub-information of the replacement description information table_xxx, and T is the source table to which the first parameter A belongs.
[0123] In this embodiment, the first reference constraint in the first transformed segment is converted into a constraint of the first parameter, which can efficiently generate a second candidate segment that matches the first parameter and improve the accuracy of the generated second candidate segment. Alternatively, the second reference constraint in the second transformed segment is converted into a constraint of the first parameter, and the description information is converted into attribute sub-information corresponding to the first parameter, which can efficiently generate a second candidate segment that matches the first parameter and its attribute information and improve the accuracy of the generated second candidate segment.
[0124] In another possible implementation, business metadata includes metadata describing data metrics. Data metrics define how data is aggregated and are quantitative indicators used to evaluate the data. They typically include a business explanation of the metric's meaning and purpose, a technical explanation of the calculation logic and data source, and descriptions of the unit of measurement and the time range of the measurement. Good data metrics can support business personnel's decision-making and operations, drive business growth, and standardize statistical standards. In this application embodiment, data metrics define one or more third transformation fragments, each of which includes calculated attribute parameters and dimensional attribute parameters.
[0125] Referring to Figure 9, a schematic diagram of the key attributes and third transformation segment of a data metric definition provided in an embodiment of this application is shown. The key attributes of the data metric definition include the calculation method (aggregate function g(x)) and dimensions. The calculation method (aggregate function g(x)) corresponds to the calculated attribute parameter, and the dimensions correspond to the dimensional attribute parameter. The actions of the data metric definition include aggregation into a new table and window functions. Different actions define different third transformation segments. The third transformation segment corresponding to aggregation into a new table is: `select g(col) group by dimensions`, and the third transformation segment corresponding to the window function is: `g(col) over(partition by dimensions)`. In the third transformation segment, `g(col)` is the calculated attribute parameter, and `dimensions` is the dimensional attribute parameter.
[0126] In this implementation, the business metadata of the first parameter and the business to which the first software script belongs is transformed to obtain the second candidate fragment, including: for any third transformation fragment, converting the calculated attribute parameters in any third transformation fragment into the calculated sub-information of the first parameter, converting the dimensional attribute parameters in any third transformation fragment into the dimensional sub-information of the first parameter, and obtaining the second candidate fragment corresponding to any third transformation fragment. The calculated sub-information of the first parameter is the subset of the attribute information corresponding to the first parameter that is related to calculation, and the dimensional sub-information of the first parameter is the subset of the attribute information corresponding to the first parameter that is related to dimension.
[0127] For example, if the first parameter is field A, and a summation operation based on region ID, date, hour, and minute is defined on field A using metadata to represent "the request response latency per minute in a certain region on a certain day," then the resulting second candidate fragment is: `sum(upstream_response_time)over(partition by region_id,dates,hour,minute)as sum_response_time`. This second candidate fragment is obtained by transforming the third transformation fragment corresponding to this window function action, where `sum(upstream_response_time)` is the calculated sub-information used to replace the calculated attribute parameter, and `region_id`, `dates`, `hour`, and `minute` are the dimension sub-information used to replace the dimension attribute parameter.
[0128] This application embodiment converts the calculated attribute parameters in the third transformation segment into calculated sub-information of the first parameter, and converts the dimensional attribute parameters into dimensional sub-information, which can efficiently generate a second candidate segment that matches the first parameter and data indicators, thereby improving the accuracy of the generated second candidate segment.
[0129] In another possible implementation, business metadata includes metadata describing entity relationships. Entity relationships define the connections between different data tables related to the business. An entity definition can be viewed as modeling the data table structure, including the definition of the entity itself and the definitions of its attribute values. Entity relationships define the connection between two different entities, including basic entity information, relationship type, primary and foreign keys, etc. Entity relationships describe how data should be related between different data tables.
[0130] In this implementation, the business metadata of the first parameter and the business to which the first software script belongs is transformed to obtain a second candidate fragment, including: determining the metadata used to describe the first entity relationship in the metadata used to describe the entity relationship, the first entity relationship being used to define the relationship between different data tables related to the first parameter; transforming the metadata used to describe the first entity relationship to obtain a second candidate fragment, the second candidate fragment including the parameter used to describe the relationship between different data tables related to the first parameter.
[0131] Referring to Figure 10, a schematic diagram of entity relationship conversion provided by an embodiment of this application is shown. Figure 10 shows two data tables: Entity A, which includes flight information, and Entity B, which includes aircraft information. The flight information includes flight number pk, departure point, destination, aircraft number fk, airline number, estimated departure time, and estimated arrival time; the aircraft information includes aircraft number pk, aircraft type, airline, manufacturing date, and estimated lifespan.
[0132] Based on the primary and foreign keys defined in the entity relationship between entity A and entity B, the relationship between entity A and entity B is determined to be an inner join. Based on the primary and foreign keys, which are the metadata describing the first entity relationship, the second candidate fragment is obtained by transformation: entity A join entity B on A.fk=B.pk. The meaning of the second candidate fragment is to combine entity A and entity B according to certain conditions, and entity A and entity B have an N-to-1 relationship. The condition for combining them is that fk in entity A and pk in entity B are the same.
[0133] For example, if there are multiple entity tables A, and each entity table A has a different fk, then the entity table A to which the fk that is the same as the pk in entity table B belongs will be combined with entity table B to form a new data table.
[0134] This application embodiment transforms the relationship between different data tables related to the first parameter into a second candidate fragment, thereby improving the efficiency of generating the second candidate fragment. Furthermore, the generated second candidate fragment matches the entity relationship related to the first parameter, and the generated second candidate fragment has high accuracy.
[0135] S305, determine the recommended segment based on the similarity between the reference segment and the first candidate segment and the second candidate segment. The similarity between the recommended segment and the reference segment is not lower than the second similarity threshold. The recommended segment is one or more of the first candidate segment or the second candidate segment.
[0136] In some cases, the reference fragment generated according to S302 may conform to the developer's intent, but may not conform to the end-to-end computation logic corresponding to the first parameter or the operating environment of the first software script, or the format of the reference fragment may be incorrect. Therefore, if the reference fragment is directly determined as the recommended fragment, the accuracy of the recommended fragment may be low.
[0137] For example, the reference fragment generated by the attribute information of the first parameter in Figure 4 and the first historical script mentioned above is: Max(upstream_response_time)over(partition by hour, minute, second). The intention of this reference fragment is to perform a maximum value aggregation operation on the first parameter. However, based on the explanation in S304, the first parameter is field A. The business metadata related to field A, as explicitly defined in the metadata center, is converted into operations such as fixing or marking the standard "value must be greater than 0.0," or a dimension-based summation operation for field A, not a maximum value aggregation operation. Therefore, the reference fragment does not conform to the definition of the business metadata corresponding to the first parameter. Furthermore, the source table T to which field A belongs does not have a `second` field; therefore, making recommendations strictly according to the reference fragment will result in an error.
[0138] Similarly, although the first and second candidate segments are in the correct format, there may be candidate segments that do not conform to the developer's intention. Therefore, this application embodiment needs to screen the candidate segments according to the similarity between the reference segment and the first and second candidate segments, and select the recommended segment that is in the correct format and conforms to the developer's intention, thereby reducing the uncertainty of the reference segment.
[0139] This application does not specify the method for determining the similarity between the reference segment and the first candidate segment and the second candidate segment. For example, the first candidate segment, the second candidate segment, and the reference segment can be transformed into vectors respectively, and the distance between each transformed vector can be calculated to determine the similarity between the segments corresponding to each vector. Alternatively, the abstract syntax tree (AST) corresponding to each reference segment, the first candidate segment, and the second candidate segment can be extracted, and the similarity between each segment can be determined based on each AST.
[0140] For example, referring to Figure 11, a schematic diagram of a process for determining the similarity between segments based on AST provided in an embodiment of this application is shown. Figure 11 is illustrated using SQL as the scripting language of the first software script. The continuation SQL in Figure 11 can also be called completion SQL, corresponding to the reference segment in the embodiment of this application. Candidate SQL (1) to candidate SQL (3) are different candidate segments, including the first candidate segment and the second candidate segment. For example, candidate SQL (1) can be the first candidate segment, and candidate SQL (2) and candidate SQL (3) are both the second candidate segments. The candidate SQL and the continuation SQL are used as input to the AST parser to obtain the AST representation of all SQL. Candidate SQL (1) to candidate SQL (3) correspond to AST (1) to AST (3) respectively, and the continuation SQL corresponds to the continuation AST. The tree edit distance (TED) between all ASTs and the continuation AST is calculated. The TED between AST (1) to AST (3) and the continuation AST are TED1 to TED3 respectively, sorted in ascending order (the tree edit distance can better measure the closeness of two SQLs from the semantics of the SQL). The candidate SQLs with the smallest distance and that pass the syntax validation are selected in sequence to obtain the final recommended SQL for completion, which is also known as the recommended fragment. The number of recommended fragments can be one or more.
[0141] In one possible implementation, after determining the recommended segment based on the similarity between the reference segment and the first candidate segment and the second candidate segment, the method further includes: displaying the recommended segment, wherein the number of recommended segments is one or more; and, upon receiving a confirmation operation for any recommended segment, updating the first software script based on any recommended segment to obtain the second software script.
[0142] After displaying recommended snippets, developers can select the desired snippet based on their expected operation on the first parameter (e.g., transformation, clearing, aggregation, or join) by clicking or typing. The processing device updates the first software script based on the selected recommended snippets. If the first software script is incomplete, the processing device automatically completes the incomplete snippets related to the first parameter based on the recommended snippets; if the first software script is complete, the processing device replaces the original snippet belonging to the first parameter with the recommended snippets, thus updating the first software script.
[0143] Optionally, during the display of recommended segments, if multiple recommended segments need to be displayed, they can be displayed at once, allowing developers to select the desired segment from among them. Alternatively, one recommended segment can be displayed at a time, with the display order based on the ascending similarity between the recommended segments and the reference segment. That is, the higher the similarity between a recommended segment and the reference segment, the higher its display priority. If a developer does not confirm a displayed recommended segment (e.g., does not click "confirm" within the duration threshold, or enters a denial message), the next recommended segment is displayed in the order it was displayed. If a developer confirms a displayed recommended segment, no other recommended segments are displayed.
[0144] In one possible implementation, the method further includes: displaying source information for the recommended segments, where the source information of any recommended segment refers to the information on which the generation of any recommended segment is based. The information on which the generation of any recommended segment is based is determined based on the type of the recommended segment. If any recommended segment is a first candidate segment, then the information on which the recommended segment is based includes the context information of a first parameter and a second historical script; that is, the source of the recommended segment can be the context information of the first parameter and the second historical script. If any recommended segment is a second candidate segment, then the information on which the recommended segment is based includes business metadata, or can be specific to business metadata such as data standards, data metrics, or entity relationships. If any recommended segment has multiple sources, when displaying the source information, multiple sources can be displayed, or only one source can be displayed.
[0145] Referring to Figures 12 to 17, schematic diagrams of display interfaces provided in various embodiments of this application are shown. Each display interface displays a portion of the statements of the first software script, a first parameter selected by a dashed line, and a recommended segment and its source information within a solid line box surrounding the first parameter. For example, in Figure 12, the first parameter is "create time…", the recommended segment is "substr(replace(create time,``,``),1,6)as month", and the source information is historical high-frequency operations, which means that the recommended segment is the first candidate segment determined based on the end-to-end computation logic that appears most frequently in the end-to-end computation logic corresponding to the second historical script.
[0146] In Figure 13, the first parameter is "if…", and the recommended snippet is:
[0147] The source information is from historical high-frequency operations.
[0148] In Figure 14, the first parameter is LEFT JOIN…, and there are two recommended fragments. One recommended fragment is bsip_sdi.t_case_submit sON t.session_id=s.session_id. The source information of this recommended fragment is the trigger and commit of the entity relationship definition. That is, this recommended fragment comes from two candidate fragments obtained by transforming the relevant information of the trigger and commit of the entity relationship definition. The other recommended fragment is bsip_sdi.t_case_tools to ON t.tool_id=to.id. The source information of this recommended fragment is the trigger and triggering tool of the entity relationship definition. That is, this recommended fragment comes from two candidate fragments obtained by transforming the relevant information of the trigger and triggering tool of the entity relationship definition.
[0149] Referring to Figure 15, the first parameter includes two parameters. The first parameter is upsream_response_time…, and the recommended segment for the first parameter is sum(upstream_response_time)over(partition by region_id,dates,hour,minute)as sum_response_time. The source information of the recommended segment is the request latency per minute defined by the data metric. That is, the recommended segment comes from the second candidate segment obtained by transforming the relevant information based on the request latency per minute defined by the data metric. The second parameter is count(*)…, and the recommended segment for the second parameter is count(*)over(partition by region_id,dates,hour,minute)as counter. The source information of the recommended segment is the number of requests per minute defined by the data metric. This recommended segment comes from another second candidate segment obtained by transforming the relevant information based on the number of requests per minute defined by the data metric.
[0150] Referring to Figure 16, the first parameter is `where...`, and there are two recommended segments. The first recommended segment is `sourceid in(102','104,'106','107','108','109")`. The source information of this recommended segment is the range of source identifiers (id) defined by the data standard. That is, this recommended segment comes from the second candidate segment obtained by converting relevant information based on the source id range defined by the data standard. The second recommended segment is `productid like'A-%'`. The source information of this recommended segment is the product prefix defined by the data standard. That is, this recommended segment comes from another second candidate segment obtained by converting relevant information based on the product prefix defined by the data standard.
[0151] Referring to Figure 17, the first parameter is upstream response time..., and the recommended segment is sum(upstream_response_time)over(partition by region_id,dates,hour,minute)as sum_response time. The source information of the recommended segment is the request latency per minute defined by the data metric. That is, the recommended segment comes from the second candidate segment obtained by converting the relevant information based on the request latency per minute defined by the data metric.
[0152] In addition, the other codes involved in Figures 12 to 17 are context information of the first parameter in the software script. The content of the other codes is not affected by the effects illustrated in Figures 12 to 17, and will not be described in detail here.
[0153] Referring to Figure 18, a schematic diagram of a software script processing procedure provided in an embodiment of this application is shown. 1) The developer interacts with the editor on the processing device to write an SQL script, obtaining the SQL script under editing, i.e., the first software script. Through the RAG continuation module in the processing device, the current SQL context information (i.e., the context information of the first parameter), the second historical script, and the attribute information corresponding to the first parameter are used as prompts for RAG, requiring the large language model to perform the SQL continuation task, obtaining the SQL continuation result, i.e., the reference fragment. This is to use the large model to identify the developer's coding intent and predict the developer's possible continuation behavior. 2) Through the computational logic conversion module on the processing device, the deterministic business knowledge of the metadata center (such as one or more of the data standards, data indicators, or entity relationships bound to the first parameter) is converted into specific SQL computational logic or SQL fragments, obtaining SQL completion candidates, i.e., the second candidate fragment. 3) Through the conversion operation extraction module on the processing device, the historical ETL job scripts previously published by the data governance platform (i.e., the second historical script) are parsed, the end-to-end computational logic is extracted, and SQL completion candidates, i.e., the first candidate fragment, are obtained from historical high-frequency operations. 4) Since the SQL completion results from LLM are the SQL completion fragments that LLM considers to be possible in the current context, there is uncertainty (such as failing syntax validation, or the presence of variables in the SQL completion results that are not in the current context). Based on the SQL completion results from LLM and the SQL completion candidates obtained in steps 2) and 3), a similarity match is performed to finally recommend SQL completion suggestions for specific business processes.
[0154] The recommended fragments generated in this application can be used not only for software script completion but also for software script verification and updates. For example, in low-code (Nocode) dataflow orchestration scenarios, operator recommendations can be implemented by generating recommended fragments, enabling developers to verify or update corresponding fragments in the software script based on the recommended fragments. Alternatively, if a script fragment written by a developer is found to be strongly correlated with certain business metadata, the current script fragment can be rewritten into a recommended fragment that better conforms to the business metadata definition specifications, improving the relevance between script fragments and business metadata in the software script and further improving the quality of the software script.
[0155] In summary, recommended segments are determined based on the similarity between the reference segment and the first and second candidate segments. Since the reference segment is generated based on a first historical script with contextual information similar to the first parameter and the attribute information corresponding to the first parameter, the reference segment can represent the writing intent of the software script related to the first parameter. Because the first candidate segment corresponds to the end-to-end computation logic information of the second historical script, the first candidate segment satisfies the correct end-to-end computation logic and has high accuracy. The second candidate segment is obtained by transforming the business metadata corresponding to the first parameter and the first software script, so the second candidate segment matches the business requirements reflected by the business metadata. That is, the recommended segments generated in this application are determined by combining multiple factors such as the writing intent of the software script related to the first parameter, the end-to-end computation logic, and business requirements, making the recommended segments not only consistent with the writing intent and business requirements, but also improving accuracy and rationality. Furthermore, automatically generating recommended segments can reduce manually written script content and improve the efficiency of software script generation.
[0156] The above describes the software script processing method provided by the embodiments of this application. Corresponding to the above method, the embodiments of this application also provide a software script processing device. This device is used to execute the software script processing method executed by the processing device in FIG3 through the various modules shown in FIG19. As shown in FIG19, the software script processing device provided by the embodiments of this application includes the following modules.
[0157] The acquisition module 1901 is used to acquire a first software script; the generation module 1902 is used to generate a reference fragment based on the first historical script and the attribute information corresponding to the first parameter. The first historical script is a historical script whose similarity to the context information of the first parameter is not lower than a first similarity threshold, and the first parameter is any parameter in the first software script; the acquisition module 1901 is also used to acquire a first candidate fragment corresponding to the information of the end-to-end computation logic. The end-to-end computation logic indicates the computation process between the source table and the destination table of the second historical script. The second historical script refers to a historical script that references a data table related to the first parameter. The source table is the data table referenced by the second historical script, and the destination table is a data table generated based on the second historical script and the source table; the generation module 1902 is also used to perform conversion processing on the business metadata of the first parameter and the business to which the first software script belongs to obtain a second candidate fragment; the determination module 1903 is used to determine a recommended fragment according to the similarity between the reference fragment and the first candidate fragment and the second candidate fragment. The similarity between the recommended fragment and the reference fragment is not lower than a second similarity threshold, and the recommended fragment is one or more of the first candidate fragment or the second candidate fragment.
[0158] In one possible implementation, the number of second historical scripts is one or more. The acquisition module 1901 is used to determine one or more calculation methods for the data in the first parameter from the information of the end-to-end calculation logic corresponding to one or more second historical scripts. The information of the end-to-end calculation logic corresponding to any second historical script includes one or more calculation methods for the data in the source table referenced by any second historical script. The one or more calculation methods for any data refers to one or more calculation methods used between any data in the source table and the corresponding data in the destination table. A first candidate fragment is generated to describe one or more calculation methods for the data in the first parameter.
[0159] In one possible implementation, business metadata includes one or more of the following: metadata for describing data standards, metadata for describing data metrics, or metadata for describing entity relationships.
[0160] In one possible implementation, the business metadata includes metadata for describing the data standard, which defines one or more first transformation segments and constraints corresponding to multiple types of parameters. Each first transformation segment includes a first reference constraint. The generation module 1902 is used to convert the first reference constraint in any first transformation segment into a constraint of the first parameter for any first transformation segment, thereby obtaining a second candidate segment corresponding to any first transformation segment. The constraint of the first parameter corresponds to the type of the first parameter.
[0161] In one possible implementation, the business metadata includes metadata for describing data standards. The data standards define one or more second transformation segments and constraints corresponding to parameters of multiple types. Each second transformation segment includes a second reference constraint and descriptive information. The generation module 1902 is used to, for any second transformation segment, convert the second reference constraint in any second transformation segment into the constraint of the first parameter, and convert the descriptive information in any second transformation segment into attribute sub-information corresponding to the first parameter, thereby obtaining a second candidate segment corresponding to any second transformation segment. The constraint of the first parameter corresponds to the type of the first parameter, and the attribute sub-information corresponding to the first parameter is a subset of the attribute information corresponding to the first parameter.
[0162] In one possible implementation, the business metadata includes metadata describing data metrics, which define one or more third transformation fragments. Each third transformation fragment includes calculated attribute parameters and dimensional attribute parameters. The generation module 1902 is used to, for any third transformation fragment, convert the calculated attribute parameters in any third transformation fragment into calculated sub-information of a first parameter, and convert the dimensional attribute parameters in any third transformation fragment into dimensional sub-information of the first parameter, thereby obtaining a second candidate fragment corresponding to any third transformation fragment. The calculated sub-information of the first parameter is a subset of the attribute information corresponding to the first parameter that is related to calculation, and the dimensional sub-information of the first parameter is a subset of the attribute information corresponding to the first parameter that is related to dimension.
[0163] In one possible implementation, the business metadata includes metadata describing entity relationships, which define the connections between different data tables related to the business; the generation module 1902 is used to determine metadata describing a first entity relationship from the metadata describing entity relationships, which defines the connections between different data tables related to a first parameter; the metadata describing the first entity relationship is transformed to obtain a second candidate fragment, which includes a parameter describing the connections between different data tables related to the first parameter.
[0164] In one possible implementation, the determining module 1903 is further configured to determine the second historical script that has been transformed into the first historical script as the first historical script, wherein the similarity between the first vector and the second vector is not lower than a first similarity threshold, and the second vector is transformed based on the context information of the first parameter in the first software script.
[0165] In one possible implementation, the determining module 1903 is further configured to segment the context information of the first parameter in the first software script, perform vector transformation on the segmentation result of the context information to obtain a second vector related to the context information; segment the second historical script, perform vector transformation on the segmentation result of the second historical script to obtain multiple third vectors; and determine the first vector among the multiple third vectors whose similarity to the second vector is not lower than a first similarity threshold.
[0166] In one possible implementation, the generation module 1902 is used to input the first historical script and attribute information into the first model, and generate a reference fragment through the first model.
[0167] In one possible implementation, the device further includes a display module and an update module. The display module is used to display recommended segments, and the number of recommended segments is one or more. The update module is used to update the first software script based on any recommended segment to obtain a second software script upon receiving a confirmation operation for any recommended segment.
[0168] In one possible implementation, the display module is also used to display source information of the recommended segments, where the source information of any recommended segment refers to the information on which the generation of any recommended segment is based.
[0169] It should be understood that the beneficial effects of the device provided in Figure 19 when implementing its function are the same as those of the software script processing method provided in Figure 3, and will not be repeated here. Furthermore, the device provided in Figure 19 is only illustrated by the division of the above-mentioned functional modules. In practical applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above. In addition, the device and method embodiments provided in the above embodiments belong to the same concept, and their specific implementation process is detailed in the method embodiments, and will not be repeated here.
[0170] Referring to Figure 20, which shows a schematic diagram of the structure of an exemplary software script processing device 2000 of this application, the software script processing device 2000 includes at least one processor 2001, a memory 2003 and at least one network interface 2004.
[0171] The processor 2001 is, for example, a general-purpose central processing unit (CPU), a digital signal processor (DSP), a network processor (NP), a GPU, a neural-network processing unit (NPU), a data processing unit (DPU), a microprocessor, or one or more integrated circuits or application-specific integrated circuits (ASICs), programmable logic devices (PLDs), other general-purpose processors or other programmable logic devices, discrete gates, transistor logic devices, discrete hardware components, or any combination thereof used to implement the scheme of this application. A PLD is, for example, a complex programmable logic device (CPLD), a field-programmable gate array (FPGA), generic array logic (GAL), or any combination thereof. A general-purpose processor can be a microprocessor or any conventional processor. It is worth noting that the processor can be a processor supporting an advanced reduced instruction set machine (RISC) machine (ARM) architecture. It can implement or execute various logic blocks, modules, and circuits described in conjunction with the disclosure of this application. The processor can also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of a DSP and a microprocessor, etc.
[0172] Optionally, the software script processing device 2000 also includes a bus 2002. The bus 2002 is used to transfer information between the components of the software script processing device 2000. The bus 2002 can be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus, etc. The bus 2002 can be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one line is used in Figure 20, but this does not mean that there is only one bus or one type of bus.
[0173] The memory 2003 may be, for example, volatile memory or non-volatile memory, or may include both volatile and non-volatile memory. The non-volatile memory may be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. The volatile memory may be random access memory (RAM), which is used as an external cache.
[0174] By way of example, but not limitation, many forms of ROM and RAM are available. For example, ROM is a compact disc read-only memory (CD-ROM). RAM includes, but is not limited to, static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous linked dynamic random access memory (SLDRAM), and direct rambus RAM (DR RAM).
[0175] The memory 2003 can also be other types of storage devices capable of storing static information and instructions. Alternatively, it can be other types of dynamic storage devices capable of storing information and instructions. It can also be other optical disc storage, optical disk storage (including compressed optical discs, laser discs, optical discs, digital versatile optical discs, Blu-ray discs, etc.), magnetic disk storage media, or other magnetic storage devices, or any other medium capable of carrying or storing desired program code in the form of instructions or data structures that can be accessed by a computer, but is not limited thereto. The memory 2003 may exist independently and be connected to the processor 2001 via bus 2002. The memory 2003 may also be integrated with the processor 2001.
[0176] Network interface 2004 uses any transceiver-like device for communicating with other devices or communication networks, such as Ethernet, radio access network (RAN), or wireless local area network (WLAN). Network interface 2004 can include wired network interfaces and wireless network interfaces. Specifically, network interface 2004 can be an Ethernet interface, such as Fast Ethernet (FE), Gigabit Ethernet (GE), Asynchronous Transfer Mode (ATM), WLAN, cellular network, or combinations thereof. The Ethernet interface can be an optical interface, an electrical interface, or a combination thereof. In some embodiments of this application, network interface 2004 can be used by software script processing device 2000 to communicate with other devices.
[0177] In specific implementations, as some embodiments, processor 2001 may include one or more CPUs, such as CPU0 and CPU1 shown in FIG20. Each of these processors may be a single-core processor or a multi-core processor. Here, processor may refer to one or more devices, circuits, and / or processing cores for processing data (e.g., computer program instructions).
[0178] In specific implementations, as some embodiments, the software script processing device 2000 may include multiple processors, such as processor 2001 and processor 2005 shown in FIG20. Each of these processors may be a single-core processor or a multi-core processor. Here, a processor may refer to one or more devices, circuits, and / or processing cores for processing data (such as computer program instructions).
[0179] In some embodiments, the memory 2003 is used to store program instructions 2010 for executing the scheme of this application, and the processor 2001 can execute the program instructions 2010 stored in the memory 2003. That is, the software script processing device 2000 can implement the method provided in the method embodiment, i.e., the method of FIG. 3, through the processor 2001 and the program instructions 2010 in the memory 2003. The program instructions 2010 may include one or more software modules. Optionally, the processor 2001 itself may also store program instructions for executing the scheme of this application.
[0180] In specific implementation, the software script processing device 2000 of this application can correspond to the first network element device used to execute the above method. The processor 2001 in the software script processing device 2000 reads the instructions in the memory 2003, so that the software script processing device 2000 shown in FIG20 can execute all or part of the steps in the method embodiment.
[0181] The software script processing device 2000 can also correspond to the device shown in FIG19 above, where each functional module is implemented in software by the software script processing device 2000. In other words, the functional modules included in the device shown in FIG19 are generated by the processor 2001 of the software script processing device 2000 reading the program instructions 2010 stored in the memory 2003.
[0182] In the method shown in Figure 3, each step is completed through the integrated logic circuitry of the hardware or software instructions in the processor of the software script processing device 2000. The steps of the method embodiments disclosed in this application can be directly implemented by the hardware processor, or by a combination of hardware and software modules in the processor. The software modules can reside in random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, or other mature storage media in the art. Since the storage medium is located in memory, the processor reads information from the memory and, in conjunction with its hardware, completes the steps of the above method embodiments. To avoid repetition, these steps will not be described in detail here.
[0183] In an exemplary embodiment, a computer program (product) is provided, comprising: computer program code, which, when executed by a computer, causes the computer to perform the method in FIG3.
[0184] In an exemplary embodiment, a computer-readable storage medium is provided that stores a program or instructions, which, when run on a computer, enable the computer to perform the method described in FIG3.
[0185] In an exemplary embodiment, a chip is provided, including a processor for calling and executing instructions stored in a memory, such that a computer with the chip installed performs the method in FIG3.
[0186] In an exemplary embodiment, another chip is provided, including: an input interface, an output interface, a processor, and a memory. The input interface, the output interface, the processor, and the memory are connected through an internal connection path. The processor is used to execute code in the memory. When the code is executed, a computer with the chip installed performs the method in FIG3.
[0187] In the above embodiments, implementation can be achieved, in whole or in part, through software, hardware, firmware, or any combination thereof. When implemented in software, it can be implemented, in whole or in part, as 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, all or part of the processes or functions described in this application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium accessible to a computer or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid-state disk).
[0188] In this application, the terms "first," "second," etc., are used to distinguish identical or similar items with substantially the same function. It should be understood that there is no logical or temporal dependency between "first," "second," and "nth," nor does it limit the quantity or order of execution. It should also be understood that although the following description uses the terms "first," "second," etc., to describe various elements, these elements should not be limited by the terms. These terms are merely used to distinguish one element from another.
[0189] It should also be understood that, in the various embodiments of this application, the sequence number of each process does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.
[0190] In this application, the term "at least one" means one or more, and the term "multiple" means two or more. For example, multiple second devices means two or more second devices. The terms "system" and "network" are often used interchangeably herein.
[0191] It should be understood that the terminology used in the description of the various examples herein is for the purpose of describing particular examples only and is not intended to be limiting. As used in the description of the various examples and the appended claims, the singular forms “a” and “the” are intended to include the plural forms as well, unless the context clearly indicates otherwise.
[0192] It should also be understood that the term "and / or" as used herein refers to and covers any and all possible combinations of one or more of the associated listed items. The term "and / or" describes an association between related objects, indicating that three relationships can exist; for example, A and / or B can represent: A alone, A and B simultaneously, or B alone. Additionally, the character " / " in this application generally indicates that the preceding and following related objects are in an "or" relationship.
[0193] It should also be understood that the terms “if” and “if” can be interpreted as meaning “when” or “upon”, or “in response to determination” or “in response to detection”. Similarly, depending on the context, the phrases “if determination…” or “if detection [the stated condition or event]” can be interpreted as meaning “when determination…”, or “in response to determination…”, or “when detection [the stated condition or event]” or “in response to detection [the stated condition or event]”.
[0194] The above description is merely an embodiment of this application and is not intended to limit this application. Any modifications, equivalent substitutions, improvements, etc., made within the principles of this application should be included within the protection scope of this application.
Claims
1. A method for processing software scripts, characterized in that, The method includes: Obtain the first software script; Based on the attribute information corresponding to the first historical script and the first parameter, a reference fragment is generated. The first historical script is a historical script whose similarity to the context information of the first parameter is not less than a first similarity threshold. The first parameter is any parameter in the first software script. Obtain the first candidate segment corresponding to the information of the end-to-end computation logic, wherein the end-to-end computation logic indicates the computation process between the source table and the destination table of the second historical script, wherein the second historical script refers to the historical script that references the data table related to the first parameter, wherein the source table is the data table referenced by the second historical script, and the destination table is the data table generated based on the second historical script and the source table; The first parameter and the business metadata of the business to which the first software script belongs are transformed to obtain the second candidate fragment; Recommended segments are determined based on the similarity between the reference segment and the first candidate segment and the second candidate segment. The similarity between the recommended segment and the reference segment is not lower than a second similarity threshold. The recommended segment is one or more of the first candidate segment or the second candidate segment.
2. The method according to claim 1, characterized in that, The number of the second historical scripts is one or more, and the first candidate segment corresponding to the information of obtaining the end-to-end computing logic includes: In the information of the end-to-end computation logic corresponding to one or more second historical scripts, one or more computation methods for the data in the first parameter are determined. The information of the end-to-end computation logic corresponding to any second historical script includes one or more computation methods for the data in the source table referenced by the any second historical script. One or more computation methods for any data refers to one or more computation methods used between the data in the source table and the corresponding data in the destination table. Generate the first candidate fragment, which describes one or more computational methods for the data in the first parameter.
3. The method according to claim 1 or 2, characterized in that, The business metadata includes one or more of the following: metadata for describing data standards, metadata for describing data metrics, or metadata for describing entity relationships.
4. The method according to any one of claims 1-3, characterized in that, The business metadata includes metadata used to describe data standards, which are used to define constraints corresponding to one or more first transformation segments and multiple types of parameters. Each first transformation segment includes a first reference constraint. The process of converting the first parameter and the business metadata of the business to which the first software script belongs to obtain the second candidate fragment includes: For any first transformation segment, the first reference constraint in the first transformation segment is converted into the constraint of the first parameter to obtain the second candidate segment corresponding to the first transformation segment, wherein the constraint of the first parameter corresponds to the type of the first parameter.
5. The method according to any one of claims 1-3, characterized in that, The business metadata includes metadata used to describe data standards, which are used to define constraints corresponding to one or more second transformation segments and multiple types of parameters. Each second transformation segment includes second reference constraints and descriptive information. The process of converting the first parameter and the business metadata of the business to which the first software script belongs to obtain the second candidate fragment includes: For any second transformation segment, the second reference constraint in the second transformation segment is converted into the constraint of the first parameter, and the description information in the second transformation segment is converted into the attribute sub-information corresponding to the first parameter to obtain the second candidate segment corresponding to the second transformation segment. The constraint of the first parameter corresponds to the type of the first parameter, and the attribute sub-information corresponding to the first parameter is a subset of the attribute information corresponding to the first parameter.
6. The method according to any one of claims 1-3, characterized in that, The business metadata includes metadata used to describe data metrics, which define one or more third transformation fragments, each of which includes calculated attribute parameters and dimensional attribute parameters. The process of converting the first parameter and the business metadata of the business to which the first software script belongs to obtain the second candidate fragment includes: For any third transformation segment, the computational attribute parameters in the third transformation segment are converted into computational sub-information of the first parameter, and the dimensional attribute parameters in the third transformation segment are converted into dimensional sub-information of the first parameter to obtain the second candidate segment corresponding to the third transformation segment. The computational sub-information of the first parameter is a subset of the attribute information corresponding to the first parameter that is related to computation, and the dimensional sub-information of the first parameter is a subset of the attribute information corresponding to the first parameter that is related to dimension.
7. The method according to any one of claims 1-3, characterized in that, The business metadata includes metadata used to describe entity relationships, which are used to define the connections between different data tables related to the business. The process of converting the first parameter and the business metadata of the business to which the first software script belongs to obtain the second candidate fragment includes: Metadata describing a first entity relationship is determined from the metadata used to describe entity relationships, the first entity relationship being used to define the connection between different data tables related to the first parameter; The metadata used to describe the relationship of the first entity is transformed to obtain a second candidate fragment, which includes parameters for describing the relationship between different data tables related to the first parameter.
8. The method according to any one of claims 1-7, characterized in that, Before generating the reference fragment based on the first historical script and the attribute information corresponding to the first parameter, the process also includes: The second historical script that yields the first vector is determined as the first historical script. The similarity between the first vector and the second vector is not lower than the first similarity threshold. The second vector is obtained by transformation based on the context information of the first parameter in the first software script.
9. The method according to claim 8, characterized in that, Before determining the second historical script that yields the first historical script, the process further includes: The context information of the first parameter in the first software script is segmented, and the segmentation result of the context information is vectorized to obtain a second vector related to the context information; The second historical script is segmented, and the segmentation results of the second historical script are vectorized to obtain multiple third vectors; Among the plurality of third vectors, a first vector is determined whose similarity to the second vector is not lower than the first similarity threshold.
10. The method according to any one of claims 1-9, characterized in that, The generation of reference fragments based on the first historical script and the attribute information corresponding to the first parameter includes: The first historical script and the attribute information are input into the first model, and the reference fragment is generated through the first model.
11. The method according to any one of claims 1-10, characterized in that, After determining the recommended segment based on the similarity between the reference segment and the first candidate segment and the second candidate segment, the method further includes: The recommended segments are displayed, and the number of recommended segments is one or more. Upon receiving a confirmation operation for any recommended segment, the first software script is updated based on the recommended segment to obtain the second software script.
12. The method according to claim 11, characterized in that, The method further includes: The source information of the recommended segments is displayed. The source information of any recommended segment refers to the information on which the recommended segment is based.
13. A software script processing apparatus, characterized in that, The device includes: The acquisition module is used to acquire the first software script; The generation module is used to generate a reference fragment based on the attribute information corresponding to the first historical script and the first parameter. The first historical script is a historical script whose similarity to the context information of the first parameter is not lower than a first similarity threshold. The first parameter is any parameter in the first software script. The acquisition module is further configured to acquire the first candidate fragment corresponding to the information of the end-to-end computation logic, wherein the end-to-end computation logic indicates the computation process between the source table and the destination table of the second historical script, wherein the second historical script refers to a historical script that references a data table related to the first parameter, wherein the source table is the data table referenced by the second historical script, and the destination table is a data table generated based on the second historical script and the source table; The generation module is further configured to perform conversion processing on the first parameter and the business metadata of the business to which the first software script belongs, to obtain a second candidate fragment; The determining module is used to determine a recommended segment based on the similarity between the reference segment and the first candidate segment and the second candidate segment, wherein the similarity between the recommended segment and the reference segment is not lower than a second similarity threshold, and the recommended segment is one or more of the first candidate segment or the second candidate segment.
14. The apparatus according to claim 13, characterized in that, The number of second historical scripts is one or more. The acquisition module is used to determine one or more calculation methods for the data in the first parameter from the information of the end-to-end calculation logic corresponding to one or more second historical scripts. The information of the end-to-end calculation logic corresponding to any second historical script includes one or more calculation methods for the data in the source table referenced by the any second historical script. One or more calculation methods for any data refers to one or more calculation methods used between the data in the source table and the corresponding data in the destination table. Generate the first candidate fragment for describing one or more calculation methods for the data in the first parameter.
15. The apparatus according to claim 13 or 14, characterized in that, The business metadata includes one or more of the following: metadata for describing data standards, metadata for describing data metrics, or metadata for describing entity relationships.
16. The apparatus according to any one of claims 13-15, characterized in that, The business metadata includes metadata for describing data standards, which define constraints corresponding to one or more first transformation segments and multiple types of parameters. Each first transformation segment includes a first reference constraint. The generation module is used to convert the first reference constraint in any first transformation segment into the constraint of the first parameter for any first transformation segment, thereby obtaining a second candidate segment corresponding to the first transformation segment. The constraint of the first parameter corresponds to the type of the first parameter.
17. The apparatus according to any one of claims 13-15, characterized in that, The business metadata includes metadata for describing data standards, which define constraints corresponding to one or more second transformation segments and multiple types of parameters. Each second transformation segment includes a second reference constraint and descriptive information. The generation module is used to convert the second reference constraint in any second transformation segment into the constraint of the first parameter, and to convert the descriptive information in any second transformation segment into attribute sub-information corresponding to the first parameter, thereby obtaining a second candidate segment corresponding to the first transformation segment. The constraint of the first parameter corresponds to the type of the first parameter, and the attribute sub-information corresponding to the first parameter is a subset of the attribute information corresponding to the first parameter.
18. The apparatus according to any one of claims 13-15, characterized in that, The business metadata includes metadata for describing data metrics, which define one or more third transformation segments. Each third transformation segment includes calculated attribute parameters and dimensional attribute parameters. The generation module is used to, for any third transformation segment, convert the calculated attribute parameters in the third transformation segment into calculated sub-information of the first parameter, and convert the dimensional attribute parameters in the third transformation segment into dimensional sub-information of the first parameter, to obtain a second candidate segment corresponding to the third transformation segment. The calculated sub-information of the first parameter is a subset of the attribute information corresponding to the first parameter that is related to calculation, and the dimensional sub-information of the first parameter is a subset of the attribute information corresponding to the first parameter that is related to dimension.
19. The apparatus according to any one of claims 13-15, characterized in that, The business metadata includes metadata used to describe entity relationships, which are used to define the connections between different data tables related to the business. The generation module is configured to determine metadata describing a first entity relationship from the metadata describing entity relationships, the first entity relationship defining the connection between different data tables related to the first parameter; and to transform the metadata describing the first entity relationship to obtain a second candidate fragment, the second candidate fragment including a parameter describing the connection between different data tables related to the first parameter.
20. The apparatus according to any one of claims 13-19, characterized in that, The determining module is further configured to determine the second historical script that has been transformed into the first historical script as the first historical script, wherein the similarity between the first vector and the second vector is not lower than the first similarity threshold, and the second vector is transformed based on the context information of the first parameter in the first software script.
21. The apparatus according to claim 20, characterized in that, The determining module is further configured to segment the context information of the first parameter in the first software script, and perform vector transformation on the segmentation result of the context information to obtain a second vector related to the context information; The second historical script is segmented, and the segmentation results of the second historical script are vectorized to obtain multiple third vectors; among the multiple third vectors, a first vector with a similarity to the second vector not lower than the first similarity threshold is determined.
22. The apparatus according to any one of claims 13-21, characterized in that, The generation module is used to input the first historical script and the attribute information into the first model, and generate the reference fragment through the first model.
23. The apparatus according to any one of claims 13-22, characterized in that, The device further includes a display module and an update module. The display module is used to display the recommended segments, and the number of recommended segments is one or more. The update module is used to update the first software script based on any recommended segment to obtain a second software script upon receiving a confirmation operation for any recommended segment.
24. The apparatus according to claim 23, characterized in that, The display module is also used to display the source information of the recommended segments, where the source information of any recommended segment refers to the information on which the generation of any recommended segment is based.
25. A software script processing device, characterized in that, The device includes a processor coupled to a memory; the memory stores at least one instruction, which is loaded and executed by the processor to enable the software script processing device to implement the software script processing method according to any one of claims 1-12.
26. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores at least one instruction, which is loaded and executed by a processor to implement the software script processing method as described in any one of claims 1-12.
27. A computer program product, characterized in that, The computer program product includes a computer program / instruction that is executed by a processor to enable a computer to implement the software script processing method according to any one of claims 1-12.