Code generation method and device, computer equipment and readable storage medium

By retrieving task templates and determining target algorithm templates from the data warehouse, task code can be automatically generated, solving the problem of low efficiency in traditional methods and improving the efficiency and readability of code generation.

CN120929085APending Publication Date: 2025-11-11BEIJING PACTERA JINXIN TECH LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202510914278.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-07-02
Publication Date
2025-11-11

AI Technical Summary

Technical Problem

Traditional data warehouse code generation methods are inefficient, require manual coding, are time-consuming, and prone to errors.

Method used

By obtaining the task template, the target algorithm template is determined based on the attribute feature information of the target task, and the calling variables of the task data are mapped to the algorithm template to automatically generate task code.

Benefits of technology

It achieves automated generation of task code, improves code generation efficiency, ensures consistency and readability of statement segments, and is suitable for various business needs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120929085A_ABST
    Figure CN120929085A_ABST
Patent Text Reader

Abstract

The invention relates to a code generation method and device, computer equipment and a readable storage medium. The method comprises the steps of obtaining a task template in response to a task code generation request of a target task; based on the attribute feature information of the target task, determining a target algorithm template matched with the processing logic of the target task in the task template; according to the task requirement of the target task, calling variables associated with task data of the target task are obtained, all the calling variables are mapped into the target algorithm template, and a task code of the target task is generated. By adopting the method, the code generation efficiency can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of application technology, and in particular to a code generation method, apparatus, computer device, computer-readable storage medium, and computer program product. Background Technology

[0002] As application data volumes increase, more and more enterprises are using data warehouses to store and manage this data. A data warehouse provides an optimized environment for complex queries and analysis, enabling users to perform advanced data analytics. However, while performing data analysis, it's also necessary to maintain the code within the data warehouse to ensure the accuracy of the results.

[0003] In traditional technologies, data warehouse data code generation typically requires managers to write task code based on the task requirements and their experience. Then, the data warehouse scheduling system executes the task based on this task code to maintain the data in the data warehouse.

[0004] However, in traditional technologies, writing code manually is very time-consuming. Therefore, current code generation methods are inefficient. Summary of the Invention

[0005] Therefore, it is necessary to provide a code generation method, apparatus, computer device, computer-readable storage medium, and computer program product to address the aforementioned technical problems.

[0006] Firstly, this application provides a code generation method, including:

[0007] In response to the task code generation request for the target task, obtain the task template;

[0008] Based on the attribute feature information of the target task, a target algorithm template that matches the processing logic of the target task is determined in the task template;

[0009] Based on the task requirements of the target task, the call variables associated with the task data of the target task are obtained, and each of the call variables is mapped to the target algorithm template to generate the task code of the target task.

[0010] In one embodiment, before obtaining the task template in response to the task code generation request for the target task, the method further includes:

[0011] In response to an algorithm template generation request, an algorithm generation template is obtained; the algorithm generation template includes an initial algorithm name, an initial algorithm type, and a statement segment template;

[0012] The algorithm name is determined based on the initial algorithm name, and the algorithm type is determined based on the initial algorithm type;

[0013] A statement segment is generated based on the statement segment template, and an algorithm template is constructed based on the algorithm name, the algorithm type, and the statement segment; the algorithm template is used to determine the target algorithm template.

[0014] In one embodiment, the statement segment template includes a statement segment type, an initial statement segment, an initial source table, an initial target table, initial deduplication options, and initial end-of-segment processing statements; generating a statement segment based on the statement segment template includes:

[0015] In response to a trigger action of a statement segment type, display the full statement segment type;

[0016] In response to the determination of the target statement segment type in the full statement segment type, obtain each initial statement segment under the target statement segment type;

[0017] Statement segments are generated based on the initial statement segments, the initial source table, the initial target table, the initial deduplication options, and the initial segment end-processing statements.

[0018] In one embodiment, determining a target algorithm template that matches the processing logic of the target task from the task template based on the attribute feature information of the target task includes:

[0019] Based on the attribute features and processing logic of the target task, the target keywords and target algorithm type are determined;

[0020] Construct a query request based on the target keywords and the target algorithm type;

[0021] Based on the query request, a target algorithm template that matches the processing logic of the target task is determined from among the algorithm templates of the task template.

[0022] In one embodiment, the target algorithm template includes target statement segments, and the step of obtaining the call variables associated with the task data of the target task according to the task requirements of the target task includes:

[0023] For each target statement segment, obtain the statement segment template of the target statement segment according to the statement segment type of the target statement segment;

[0024] Based on the task requirements of the target task and the templates of each statement segment, obtain the call variables associated with the task data of the target task.

[0025] In one embodiment, obtaining the statement segment template of the target statement segment based on the statement segment type of the target statement segment includes:

[0026] If the statement segment type of the target statement segment is a table creation type, obtain the table creation statement segment template and determine the table creation statement segment template as the statement segment template of the target statement segment;

[0027] If the statement segment type of the target statement segment is a data mapping type, obtain the data mapping statement segment template and determine the data mapping statement segment template as the statement segment template of the target statement segment.

[0028] In one embodiment, the statement segment template is a table creation statement segment template, which includes a source table. The step of obtaining the call variables associated with the task data of the target task based on the task requirements of the target task and the statement segment template includes:

[0029] Obtain the data structure of all fields in the source table, and determine the data structure of the first target field in the data structure of each field according to the task data of the target task;

[0030] Based on the fields in the table creation statement template, a template and the task data of the target task are created to generate the data structure of the second target field;

[0031] Obtain the name of the temporary table, and determine the data structure of the first target field, the data structure of the second target field, and the name of the temporary table as the calling variables of the target task.

[0032] In one embodiment, the statement segment template is a data mapping statement segment template, which includes a mapping target table and a mapping source table. The step of obtaining the call variables associated with the task data of the target task based on the task requirements of the target task and the statement segment template includes:

[0033] Obtain all source fields of the mapping source table and all fields to be mapped of the mapping target table;

[0034] Based on the task data of the target task, each target source field is determined in each of the source fields, and a target mapping field matching each target source field is determined in each of the fields to be mapped;

[0035] Based on the task data of the target task, determine the data conversion rules between the target mapping field and the target source field, and construct the target mapping rules based on the data conversion rules, the target mapping field, and the target source field;

[0036] Each of the target mapping rules is determined as a calling variable associated with the task data of the target task.

[0037] Secondly, this application also provides a code generation apparatus, comprising:

[0038] The retrieval module is used to retrieve the task template in response to the task code generation request of the target task;

[0039] The determination module is used to determine a target algorithm template that matches the processing logic of the target task from the task template based on the attribute feature information of the target task.

[0040] The generation module is used to obtain the calling variables associated with the task data of the target task according to the task requirements of the target task, and map each of the calling variables to the target algorithm template to generate the task code of the target task.

[0041] Thirdly, this application also provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to perform the following steps:

[0042] In response to the task code generation request for the target task, obtain the task template;

[0043] Based on the attribute feature information of the target task, a target algorithm template that matches the processing logic of the target task is determined in the task template;

[0044] Based on the task requirements of the target task, the call variables associated with the task data of the target task are obtained, and each of the call variables is mapped to the target algorithm template to generate the task code of the target task.

[0045] Fourthly, this application also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, performs the following steps:

[0046] In response to the task code generation request for the target task, obtain the task template;

[0047] Based on the attribute feature information of the target task, a target algorithm template that matches the processing logic of the target task is determined in the task template;

[0048] Based on the task requirements of the target task, the call variables associated with the task data of the target task are obtained, and each of the call variables is mapped to the target algorithm template to generate the task code of the target task.

[0049] Fifthly, this application also provides a computer program product, including a computer program that, when executed by a processor, performs the following steps:

[0050] In response to the task code generation request for the target task, obtain the task template;

[0051] Based on the attribute feature information of the target task, a target algorithm template that matches the processing logic of the target task is determined in the task template;

[0052] Based on the task requirements of the target task, the call variables associated with the task data of the target task are obtained, and each of the call variables is mapped to the target algorithm template to generate the task code of the target task.

[0053] The aforementioned code generation method, apparatus, computer equipment, computer-readable storage medium, and computer program product, in response to a task code generation request for a target task, acquire a task template; based on the attribute feature information of the target task, determine a target algorithm template matching the processing logic of the target task from the task template; according to the task requirements of the target task, acquire the call variables associated with the task data of the target task, and map each of the call variables to the target algorithm template to generate the task code of the target task. By using this method, by determining a target algorithm template matching the processing logic of the target task and mapping the call variables associated with the task data of the target task to the target algorithm template, automated task code generation based on the target algorithm template is achieved, avoiding human intervention and improving the efficiency of the code generation method. Furthermore, by determining the target statement segment type and generating statement segments according to each initial statement segment under the target statement segment type, standardized generation of statement segments is achieved, ensuring the consistency of the statement segment code, making the generated statement segments conform to business standards, improving the readability, maintainability, and reusability of the code, and providing a reliable technical foundation for subsequent data processing. In addition, by using the initial source table, initial target table, initial deduplication options, and initial end-of-segment processing statements in the statement segment template, custom statement segments can be generated. These statement segments can be used to handle special business requirements, thus expanding the applicability of the code generation method. Attached Figure Description

[0054] To more clearly illustrate the technical solutions in the embodiments of this application or related technologies, the drawings used in the description of the embodiments of this application or related technologies will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.

[0055] Figure 1This is a flowchart illustrating a code generation method in one embodiment;

[0056] Figure 2 This is a flowchart illustrating the process of generating an algorithm template in one embodiment;

[0057] Figure 3 This is a flowchart illustrating the process of generating a statement segment in one embodiment;

[0058] Figure 4 This is a flowchart illustrating the process of determining the target algorithm template in one embodiment;

[0059] Figure 5 This is a flowchart illustrating the process of obtaining call variables in one embodiment;

[0060] Figure 6 This is a schematic diagram of the table structure and field information collected in an exemplary embodiment;

[0061] Figure 7 This is a flowchart illustrating the process of determining a statement segment template in one embodiment;

[0062] Figure 8 This is a flowchart illustrating the process of obtaining call variables based on a table creation statement template in one embodiment.

[0063] Figure 9 This is a flowchart illustrating the steps of obtaining the call variable based on the data mapping statement segment template in one embodiment;

[0064] Figure 10 This is a schematic diagram showing the data mapping statement segment template in one embodiment;

[0065] Figure 11 A flowchart of a code generation method in another exemplary embodiment;

[0066] Figure 12 This is a structural block diagram of a code generation device in one embodiment;

[0067] Figure 13 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation

[0068] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.

[0069] As application data volumes increase, more and more enterprises are using data warehouses to store and analyze this data. A data warehouse provides an optimized environment for complex queries and analysis, enabling users to perform advanced data analytics. However, while performing data analysis, it's also necessary to maintain the code within the data warehouse to ensure the accuracy of the results.

[0070] In traditional methods, data warehouse data dimension code generation typically requires managers to write task code based on the task requirements and their experience. Then, managers execute the task based on this task code to maintain the data in the data warehouse.

[0071] However, in traditional technologies, manually writing code is extremely time-consuming. Furthermore, as the volume and complexity of data increase, manual coding is prone to errors. Therefore, current code generation methods are both inefficient and inaccurate.

[0072] In one embodiment, such as Figure 1 As shown, a code generation method is provided. This application embodiment uses the application of this method to a computer device as an example for illustration. This application embodiment does not limit the execution device of the code generation method, and includes the following steps 102 to 106:

[0073] Step 102: In response to the task code generation request of the target task, obtain the task template.

[0074] In implementation, during the operation of the data warehouse, task code is needed to maintain the data in the data warehouse. When a target user needs to maintain the data warehouse through a target task, the target user sends a code generation request for the target task to the computer device. The computer device responds to the task generation request, retrieves a task template from the database, and displays the task template.

[0075] Specifically, a data warehouse has four layers: the first layer is the near-source layer, the second layer is the integration layer, the third layer is the summary layer, and the fourth layer is the data mart layer. The near-source layer retrieves data from the business system at preset time intervals. The integration layer retrieves and cleans data from the near-source layer. Then, the integration layer combines cleaned data on the same theme to obtain integrated data tables for each theme. Simultaneously, the integration layer also preserves the history of data changes. The summary layer summarizes and integrates data from the data tables according to data summary requirements to obtain new processed tables. The data mart layer retrieves data from the summary layer or the integration layer and processes the retrieved data according to the business system's requirements to obtain tables for the data mart layer. The data processing process at each layer of the data warehouse constitutes the data maintenance process within the data warehouse. Computer devices maintain the data in the data warehouse by executing task codes for each task. The target user generates a task code generation request for the target task through the computer device. Then, the target user sends the task code generation request to the computer device. The computer device responds to the code generation request by retrieving a task template from the database.

[0076] In one exemplary embodiment, the task template includes an initial task name, an initial task subsystem, an initial task description, an initial primary key field, and various algorithm templates. The computer device, in response to a task code generation request for the target task, obtains the task template. The computer device determines the task name of the target task based on the initial task name and determines the subsystems of the target task based on the initial subsystem. Then, the computer device determines the target table of the target task in the various tables of the database and determines the task description of the target task based on the initial task. The computer device determines the primary key field of the target task based on the initial primary key field. The computer device determines the attribute feature information of the target task based on the task description, task name, and task subsystem.

[0077] In an optional embodiment, the computer device, in response to a task code generation request, obtains a task template. In response to a trigger operation on a target table, the computer device retrieves all data tables from a database and data warehouse. Then, the target user identifies and submits the target data table in each data table. In response to the submission operation of the target data table, the computer device identifies the target data table as the target table. The target table is a table generated or updated by the computer device. The computer device obtains and displays each initial subsystem. The target user identifies a subsystem in each initial subsystem. In response to the identification operation of a subsystem, the computer device identifies that subsystem as the subsystem of the target task. The computer device obtains a target box based on the initial task name, obtains the task name entered by the target user, and obtains the task description entered by the target user based on the target box of the initial task description. Then, the computer device obtains and displays each initial primary key field. Then, the target user identifies the primary key field in each initial primary key field. In response to the identification operation of the primary key field, the computer device identifies the primary key field as the primary key field of the target task. The computer device determines the attribute characteristics of the target task based on the task name and task description, and determines the processing logic of the target task.

[0078] Step 104: Based on the attribute feature information of the target task, determine the target algorithm template that matches the processing logic of the target task in the task template.

[0079] The task template contains various algorithm templates. The algorithm templates are pre-generated based on the algorithm generation template.

[0080] In implementation, the computer device constructs a query request based on the attribute characteristics and processing logic of the target task, and then searches for a target algorithm template that matches the processing logic of the target task in each algorithm template according to the query request.

[0081] Specifically, the computer device determines the target keywords and target algorithm type based on the attribute characteristics and processing logic of the target task. Then, the computer device constructs a query request based on the target keywords and target algorithm type, and searches the database for target algorithm templates that match the processing logic of the target task based on the query request.

[0082] In an optional embodiment, the computer device, in response to a triggering operation of an algorithm template, retrieves all algorithm templates from a database. Then, the computer device displays each algorithm template. The target user, based on the attribute features and processing logic of the target task, determines an algorithm template from among the various algorithm templates. In response to the determination operation of an algorithm template, the computer device identifies that algorithm template as the target algorithm template for the target task. For example, in response to the determination operation of a standard zipper algorithm template, the computer device identifies the standard zipper algorithm template as the target algorithm template for the target task.

[0083] Step 106: Based on the task requirements of the target task, obtain the calling variables associated with the task data of the target task, map each calling variable to the target algorithm template, and generate the task code of the target task.

[0084] The target algorithm template contains masks for each calling variable.

[0085] In implementation, the computer equipment obtains the calling variables associated with the task data of the target task based on the task requirements and the target algorithm template. According to the mapping relationship between each calling variable and its mask, the computer equipment maps each calling variable to the target algorithm template, generating the task code for the target task.

[0086] Specifically, the computer device is pre-configured with a Java (a computer language) template engine. The target algorithm template contains various target statement segments. For each target statement segment, the computer device obtains its statement segment template based on the segment type. Then, based on the statement segment type of the target task, the computer device obtains its statement segment template. Next, based on the task requirements of the target task and the statement segment templates, the computer device obtains the call variables associated with the task data of the target task. Finally, through the mapping relationship between the Java engine templates and the call variables and their masks, the computer device maps the call variables to the statement segment templates, thus obtaining the task code for the target task.

[0087] In an exemplary embodiment, the call variable is the value of the call variable mask. Taking a table creation statement template as an example, the call variable masks contained in the table creation statement template are the target table, the source table, and the table creation data format. The call masks corresponding to the table creation statement template are the name of the target table, the name of the source table, the data structure of the first target field, and the data structure of the second target field. The computer device maps the name of the target table to the target table and the name of the source table to the source table. Then, the computer device maps the data structure of the first target field and the data structure of the second target field to the table creation data format.

[0088] For example, the statement template is

[0089] CREATE TEMPORARY TABLE {{ targetTable}}

[0090] AS SELECT * FROM {{ parent.targetSchema}}.{{ parent.targetTable}}

[0091] WHERE 1=2

[0092] This statement template represents the creation of a temporary table. Here, `{{ targetTable}}` and `{{parent.targetSchema}}.{{ parent.targetTable}}` are the call variable masks in this initial SQL. `{{ targetTable}}` is the target table, and `{{ parent.targetSchema}}.{{ parent.targetTable}}` is the source table. The computer device updates `{{ targetTable}}` according to the name of the target table and updates `{{ parent.targetSchema}}.{{ parent.targetTable}}` according to the name of the source table. Then, the computer device builds the target table based on the data structure of the first target field and the data structure of the second target field.

[0093] In one exemplary embodiment, taking a data mapping statement segment template as an example, the data mapping statement segment template contains call variable masks for target tables and mapping lists. The call masks corresponding to the data mapping statement segment template are the names of the target tables and the target mapping rules. The computer device maps the names of the target tables to the target tables and the target mapping rules to the mapping lists.

[0094] The statement template is INSERT INTO VT_NEW_{{ parent.id}} (

[0095] {%- for mappiongDto in stmtMappingList %}

[0096] {%if not loop.first%,{%else%}{%endif%}{{rpad(mappiongDto.targetColumn,65,'')}} / * {{ mappiongDto.targetColumnCnName}} * /

[0097] {%-endfor%} )

[0099] SELECT

[0100] {%-for mappiongDto in stmtMappingList%}

[0101] {%if not loop.first%},{%else%}

[0102] This statement template represents inserting data from one or more tables into another table. `{{parent.id}}` and `stmtMappingList` are the call variable masks in this initial SQL. `{{targetTable}}` is the target table, and `stmtMappingList` is the list of mapping rules. The computer updates `{{targetTable}}` based on the name of the target table and updates `stmtMappingList` according to the mapping rules.

[0103] In an optional embodiment, after generating the task code for the target task, the computer device displays the task code. The target user verifies the displayed task code to ensure logical correctness and may choose to publish it to the database for execution or make further adjustments.

[0104] In the above code generation method, by determining the target algorithm template that matches the processing logic of the target task, and mapping the call variables associated with the task data of the target task to the target algorithm template, the automatic generation of task code based on the target algorithm template is realized, avoiding human intervention and improving the efficiency of the code generation method.

[0105] In one exemplary embodiment, before obtaining the task template, it is necessary to first generate the algorithm templates within the task template. For example... Figure 2 As shown, before step 102 is executed, the specific processing procedure of this code generation method further includes steps 202 to 206. Wherein:

[0106] Step 202: In response to the algorithm template generation request, obtain the algorithm generation template.

[0107] The algorithm generation template includes the initial algorithm name, the initial algorithm type, and the statement segment template.

[0108] In practice, when a target user needs to generate a new algorithm template, the target user initiates an algorithm template generation request to the computer device. The computer device responds to the algorithm template generation request by retrieving the algorithm template from the database.

[0109] Specifically, if there is no matching target algorithm template for the target task in the database, or if the database is empty, the computer device needs to generate a new algorithm template using an algorithm generation template. The target user triggers a new template control displayed on the computer device. In response to the triggering operation of the new template control, the computer device generates an algorithm template generation request. In response to the algorithm template generation request, the computer device retrieves the algorithm generation template from the database. This algorithm generation template contains the initial algorithm name, various initial algorithm types, and statement segment templates.

[0110] In an optional embodiment, the new template control can be set on the query page for querying algorithm templates, or on the display page for displaying various algorithm templates. Specifically, the target user, based on the attribute feature information of the target task, queries the task templates for a target algorithm template that matches the target query processing logic, and obtains the query results. The computer device displays the query results through the query page. The query page has a new template control. If the query results indicate that no target algorithm template exists, the target user triggers the new template control. In response to the triggering operation of the new template control, the computer device generates an algorithm template generation request. In response to the algorithm template generation request, the computer device retrieves an algorithm generation template from the database.

[0111] The target user operates the computer device to display various algorithm templates on the device. This display page includes a "Create Template" control. When a new algorithm template needs to be generated, the target user triggers the "Create Template" control. In response to the triggering of the "Create Template" control, the computer device generates an algorithm template generation request. In response to the algorithm template generation request, the computer device retrieves the algorithm template from the database.

[0112] Step 204: Determine the algorithm name based on the initial algorithm name, and determine the algorithm type based on the initial algorithm type.

[0113] In implementation, the computer device determines the algorithm name of the algorithm template based on the initial algorithm name. Then, the computer device determines the algorithm type from among the initial algorithm types.

[0114] Specifically, the algorithm type characterizes the scope of application of the algorithm template. A data warehouse contains a near-source layer, an integration layer, a summary layer, and a data mart layer. The computer device determines the target layer used (involved in) by the algorithm template within each layer of the data warehouse, thus obtaining the algorithm type of the algorithm template. Optionally, the computer device combines the layers of the data warehouse to obtain a data layer combination. The computer device determines the algorithm types of the algorithm template within the data layer combination and each layer.

[0115] In one exemplary implementation, a computer device displays an algorithm generation template. This template includes input boxes corresponding to initial algorithm names and various initial algorithm types. Each initial algorithm type represents a data layer and a layer within a data warehouse. A target user inputs an algorithm name through the input box corresponding to the initial algorithm name. The computer device retrieves the algorithm name. Then, the target user triggers the algorithm type of the algorithm template within each initial algorithm type. In response to the triggering operation of the algorithm type, the computer device retrieves the algorithm type of the algorithm template. For example, the algorithm template is applied from the near-source layer to the integration layer. The target user determines the combination of the data layers of the near-source layer and the integration layer as the algorithm type of the algorithm template within each initial algorithm type and triggers that algorithm type. In response to the triggering operation of the algorithm type, the computer device determines the combination of the data layers of the near-source layer and the integration layer as the algorithm type of the algorithm template.

[0116] Step 206: Generate statement segments based on the statement segment template, and construct an algorithm template based on the algorithm name, algorithm type, and statement segments.

[0117] The algorithm template is used to determine the target algorithm template. The statement segment template contains the types of each statement segment.

[0118] In implementation, the computer device determines the target statement segment type from among various statement segment types, and generates initial statement segments under the target statement segment type. Based on each initial statement segment, the initial source table, the initial target table, the initial deduplication options, and the initial end-of-segment processing statements, the computer device generates statement segments. Then, the computer device combines the algorithm name, algorithm type, and statement segments to obtain a new algorithm template.

[0119] In an optional embodiment, the computer device determines the number of statement segments based on the algorithm template construction requirements. Then, the computer device copies the statement segment templates for the specified number of statement segments and generates one statement segment based on each template. The computer device combines the algorithm name, algorithm type, and each statement segment to obtain a new algorithm template.

[0120] In this embodiment, the statement segment template in the algorithm is used to generate each statement segment, thereby achieving automated generation of statement segments, avoiding manual writing of statement segments, improving the generation efficiency of statement segments, and thus improving the generation efficiency of the algorithm template.

[0121] In one exemplary embodiment, the statement segment template includes a statement segment type, an initial statement segment, a source table, a target table, deduplication options, and end-of-segment processing statements; such as Figure 3 As shown, the specific processing steps for generating statement segments based on the statement segment template in step 206 include steps 302 to 306. Wherein:

[0122] Step 302: In response to the triggering operation of the statement segment type, display the full statement segment type.

[0123] In implementation, the target user triggers the statement segment type in the statement segment template. The computer device, in response to the statement segment type triggering operation, retrieves the full statement segment types from the database and displays them.

[0124] Specifically, statement segment types include table creation type, data mapping type, and custom SQL (Structured Query Language) type. When a target user needs to generate a statement segment, they must first select the statement segment type. Therefore, the target user triggers the statement segment type in the statement segment template. In response to the triggering operation of the statement segment type, the computing device displays the table creation type, data mapping type, and custom SQL type. The table creation type is used to create new tables. The data mapping type is used to map data from the source table to the target table. The custom SQL type is used for updating and deleting data in the data warehouse.

[0125] Step 304: In response to the determination operation of the target statement segment type in the full statement segment type, obtain each initial statement segment under the target statement segment type.

[0126] During implementation, the target user determines the target statement segment type from among the various statement segment types based on business requirements. In response to the determination of the target statement segment type, the computer device retrieves the initial statement segments under the target statement segment type from the database.

[0127] Specifically, the statement segment types are table creation type, data mapping type, and custom SQL type. The target user determines the target statement segment type from among these based on business needs. If the target statement segment type is a table creation type, the computer device responds to the table creation type determination operation by retrieving the initial statement segments under that table creation type from the database. Each initial statement segment is used to create a new table, but the conditions for creation differ.

[0128] If the target statement segment type is a data mapping type, the computer device, in response to the data mapping type determination operation, retrieves the initial statement segments under the data mapping type from the database. Each initial statement segment is used to map data from the source table to the target table, but the mapping conditions differ.

[0129] In an optional embodiment, if the target statement type is a custom SQL type, the computer device displays a statement input box in response to the confirmation operation of the custom SQL type. The target user enters a custom statement through the statement input box and submits it. In response to the submission operation of the custom statement, the computer device obtains the custom statement entered by the target user. For example, the target user enters and submits custom SQL through the statement input box. In response to the submission operation of the custom SQL, the computer device obtains the custom SQL entered by the target user.

[0130] Step 306: Generate statement segments based on each initial statement segment, initial source table, initial target table, initial deduplication options, and initial segment end processing statement.

[0131] In implementation, the computer equipment determines the pending statement segments within each initial statement segment. Then, it determines the source table based on the initial source table and the target table based on the initial target table. The initial deduplication options include deduplication and non-deduplication options. Based on business requirements, the computer equipment determines the deduplication option from the initial deduplication options and generates the corresponding SQL statement. The computer equipment determines the end-of-segment processing statement based on the initial segment-end processing statement and generates the sequence number of the initial statement segment. The computer equipment concatenates the pending statement segments, the SQL statements corresponding to the deduplication options, the segment-end processing statement, and the sequence number to obtain the concatenated statement segment. The computer equipment maps the names of the source table and the target table to the concatenated statement segment to obtain the statement segment.

[0132] Specifically, the computer device displays each initial statement segment. The target user selects and confirms a pending statement segment from each initial statement segment according to business needs. In response to the confirmation of the pending statement segment, the computer device retrieves the pending statement segment. Based on the input box corresponding to the initial source table, the computer device retrieves the source table name entered by the target user. Simultaneously, based on the input box corresponding to the initial target table, the computer device retrieves the target table name entered by the target user. The initial deduplication options include deduplication and non-deduplication. The target user selects and confirms a deduplication option from the initial deduplication options according to business needs. In response to the confirmation of the deduplication option, the computer device retrieves the deduplication option selected by the target user. If the deduplication option is deduplication, the computer device generates an SQL statement to delete duplicate data records. If the deduplication option is non-deduplication, the computer device does not perform any processing. Based on the input box corresponding to the initial end-processing statement segment, the computer device retrieves the end-processing statement segment entered by the target user. The end-processing statement segment supplements the initial statement segments and is generally the execution condition of the SQL statement. Then, the computer device generates the statement segment sequence number. This sequence number indicates the execution order of the statement segments within the algorithm template. The computer device concatenates the defined statement segment, the SQL statement corresponding to the deduplication option, the segment end processing statement, and the sequence number to obtain the concatenated statement segment. The computer device maps the names of the source table and the target table to the concatenated statement segment to obtain the statement segment.

[0133] In one exemplary embodiment, the target statement segment type is a table creation type. In response to a table creation type determination operation, the computer device retrieves the initial SQL statements under the table creation type from the database. The computer device displays the initial SQL statements. For example, one of the initial SQL statements is:

[0134] CREATE TEMPORARY TABLE {{ targetTable}}

[0135] AS SELECT * FROM {{ parent.targetSchema}}.{{ parent.targetTable}}

[0136] WHERE 1=2

[0137] The initial SQL above represents the creation of a temporary table. Here, `{{ targetTable}}` and `{{parent.targetSchema}}.{{ parent.targetTable}}` are the call variable masks in this initial SQL. `{{ targetTable}}` is the name of the newly created temporary table, while `{{ parent.targetSchema}}.{{parent.targetTable}}` is the source table that serves as the data structure and data source for the temporary table. The target user selects and confirms this initial SQL. In response to the triggering operation of this initial SQL, the computer device identifies it as a pending statement segment. The target user does not input the target table name, the source table name, or the end-of-segment processing statement segment. Therefore, the target table, source table, and end-of-segment processing statement segment obtained by the computer device are empty. The computer device generates the statement segment sequence number. The computer device concatenates the pending statement segment and the sequence number to obtain the concatenated statement segment.

[0138] Optionally, the source and target tables can be empty, and the source and target tables will be updated later by calling variables. The target user can also omit the end-of-segment processing statement segment, i.e., the end-of-segment processing statement segment is empty. The generation of the statement segment requires at least an initial statement segment and a sequence number. This application embodiment does not limit the content of the generated statement segment.

[0139] In this embodiment, by determining the target statement segment type and generating statement segments based on each initial statement segment under the target statement segment type, standardized statement segment generation is achieved. This ensures the consistency of the statement segment code, making the generated statement segments conform to business standards, improving code readability, maintainability, and reusability, and providing a reliable technical foundation for subsequent data processing. Furthermore, by using the initial source table, initial target table, initial deduplication options, and initial segment end processing statements, custom-generated statement segments can be created. These statement segments can be used to handle special business requirements, expanding the applicability of the code generation method.

[0140] In one exemplary embodiment, such as Figure 4 As shown, the specific processing procedure of step 104 includes steps 402 to 406. Wherein:

[0141] Step 402: Based on the attribute feature information and processing logic of the target task, determine the target keywords and target algorithm type.

[0142] The processing logic includes the actions to be taken to process the target task. The attribute task feature information includes the purpose of the target task.

[0143] In implementation, the computer device obtains the attribute characteristics and processing logic of the target task based on the task template. Then, the computer device extracts the target keywords and target algorithm type from the attribute characteristics and processing logic of the target task.

[0144] Specifically, the computer device obtains the task name and task description based on the task template. The task name contains the objective of the target task, and the task description contains the processing object and processing logic of the target task. The processing object is the table to be processed. Based on the model design of the table to be processed, the computer device extracts the objective of the target task from the task name and determines the objective as the target keyword. At the same time, the computer device determines the target algorithm type based on the overall model and the various processing actions in the processing logic.

[0145] In an exemplary embodiment, the task template includes a target box for an initial task name and a target box for an initial task description. The computer device obtains the task name of the target task based on the target box of the initial task name, and obtains the task description of the target task based on the target box of the initial task description. The task name is "Daily Maintenance Data." The task description is "Retrieving updated data from the database at preset times and updating the data to each layer." The task description includes the processing object and processing logic of the target task. The processing object is the table to be processed. Based on the model design of the table to be processed, the computer device extracts the task purpose of the target task from the task name and determines the task purpose as the target keyword. The target keyword is "Zipper Algorithm." The target algorithm type is "Near-Source Layer" and "Integration Layer."

[0146] In an optional embodiment, the computer device extracts target keywords and target algorithm types from the attribute feature information and processing logic of the target task using a large model.

[0147] Step 404: Construct a query request based on the target keywords and the target algorithm type.

[0148] In implementation, the computer device constructs fuzzy search criteria based on the target keywords and filter criteria based on the target algorithm type. Then, the computer device constructs a query request based on the fuzzy search criteria and filter criteria.

[0149] Specifically, the computer device generates a fuzzy query statement based on the target keywords and a type filtering statement based on the target algorithm type. Then, the computer device combines the fuzzy query statement and the filtering statement to obtain a query statement, and constructs a query request based on the query statement.

[0150] Step 406: Based on the query request, determine the target algorithm template that matches the processing logic of the target task from among the algorithm templates of the task template.

[0151] The query request includes filtering statements and fuzzy query statements.

[0152] In implementation, the computer device uses a filtering statement to select initial target algorithm templates of the target algorithm type from among the algorithm templates in the task template. Then, the computer device uses a fuzzy query statement to select target algorithm templates from among the initial target algorithm templates that match the target task processing logic.

[0153] In an optional embodiment, the computer device filters multiple target algorithm templates from each initial target algorithm template based on a fuzzy query, obtaining target algorithm templates whose processing logic matches that of the target task. The computer device displays multiple target algorithm templates. The target user selects and confirms a target algorithm template from among the target algorithm templates according to business requirements. In response to the confirmation operation of the target algorithm template, the computer device obtains the target algorithm template and confirms it as the target algorithm template corresponding to the target task.

[0154] In one exemplary embodiment, the target user determines target keywords from the attribute features and processing logic of the target task. These target keywords characterize the task's objective. Simultaneously, the target user determines the target algorithm type based on the target task's processing logic. The target user inputs the target algorithm type and target keywords into the computer device. The computer device constructs a query request based on the target algorithm type and target keywords, and determines the target algorithm template that matches the processing logic of the target task from among the algorithm templates in the task templates according to the query request.

[0155] Optionally, the target algorithm template may be, but is not limited to, a full delete and full insert template, an append template, a zipper, or other ETL (Extract-Transform-Load) logic template, which is determined based on the attribute characteristics and processing logic of the target task. This application embodiment does not limit the target algorithm template.

[0156] In this embodiment, by using the target task attribute feature information and processing logic, the target algorithm template that matches the processing logic of the target task is queried in each algorithm template. In this way, the task code can be automatically generated through the target algorithm template, avoiding human intervention and improving the efficiency of the code generation method.

[0157] In one exemplary embodiment, the target algorithm template includes target statement segments, such as... Figure 5 As shown, the specific processing steps in step 106 for obtaining the calling variables associated with the task data of the target task according to the task requirements of the target task include steps 502 to 504. Wherein:

[0158] Step 502: For each target statement segment, obtain the statement segment template of the target statement segment according to the statement segment type of the target statement segment.

[0159] The statement segment types include table creation types, data mapping types, and custom SQL types.

[0160] In implementation, since the target algorithm template is composed of target statement segments, and each target statement segment contains a mask for each call variable, the computer device needs to obtain the call variables corresponding to each call variable mask in each target statement segment. Therefore, for each target statement segment, the computer device queries the database for the statement segment template corresponding to that statement segment type, based on the statement segment type of the target statement segment.

[0161] Specifically, for each target statement segment, if the statement segment type of the target statement segment is a table creation type, the computer device obtains the table creation statement segment template as the statement segment template of the target statement segment. If the statement segment type of the target statement segment is a data mapping type, the computer device obtains the data mapping statement segment template from the database as the statement segment template of the target statement segment.

[0162] In an optional embodiment, if the target statement segment is of a custom SQL type, the computer device parses the target statement segment to obtain the call variable masks in the target statement segment. Based on the call variable masks, the computer device obtains the call variables related to the task elements of the target task.

[0163] Step 504: Based on the task requirements of the target task and the templates of each statement segment, obtain the call variables associated with the task data of the target task.

[0164] The task requirements of the target task include the object to be processed and the processing requirements.

[0165] In implementation, computer equipment connects to databases and data warehouses via interfaces to retrieve metadata from the data tables. For each statement segment template, the computer equipment filters the data in each data table to find the relevant call variables based on the task requirements of the target task.

[0166] In one exemplary embodiment, a computer device connects to the business system's database via JDBC (Java Database Connectivity, an application programming interface in Java that specifies how client programs access databases) or API (Application Programming Interface), and automatically collects table structure and field information as basic development data. By connecting the database and data warehouse, full metadata in both databases and data warehouses can be synchronized, ensuring the accuracy and real-time nature of the data structure. Figure 6 This is a schematic diagram illustrating the table structure and field information collected in an exemplary embodiment. For each statement segment template, the computer device filters the data in each data table for call variables associated with the task data, based on the task requirements of the target task.

[0167] In this embodiment, by using statement segment templates of each statement segment type and the task requirements of the target task, call variables related to the task data are obtained, thereby realizing the automated acquisition of relevant data of the target task, which facilitates the subsequent generation of task code for the target task.

[0168] In one exemplary embodiment, such as Figure 7 As shown, the specific processing steps for obtaining the statement segment template of the target statement segment based on its statement segment type in step 502 include steps 702 to 704. Wherein:

[0169] Step 702: If the statement segment type of the target statement segment is a table creation type, obtain the table creation statement segment template and determine the table creation statement segment template as the statement segment template of the target statement segment.

[0170] In implementation, if the target statement segment's statement segment type is a table creation type, the computer device retrieves the table creation statement segment template corresponding to the table creation type from the database. Then, the computer device uses this table creation statement segment template as the statement segment template for the target statement segment. This table creation statement segment template is used to retrieve the various call variables corresponding to the target statement segment.

[0171] Specifically, if the target statement segment is of type table creation, then the call variable mask within that target statement segment contains the source table, the target table, and the table creation data format. The table creation data format includes field names, Chinese field names, and field types. The computer device retrieves the call variables of the target statement segment based on this table creation statement segment template. The call variables are the values ​​of the call variable mask.

[0172] Step 704: If the statement segment type of the target statement segment is a data mapping type, obtain the data mapping statement segment template and determine the data mapping statement segment template as the statement segment template of the target statement segment.

[0173] In implementation, if the target statement segment's statement segment type is a data mapping type, the computer device retrieves the data mapping statement segment template corresponding to the data mapping type from the database. Then, the computer device determines the data mapping statement segment template as the statement segment template for the target statement segment. This data mapping statement segment template is used to retrieve the various call variables corresponding to the target statement segment.

[0174] Specifically, if the target statement segment is of the data mapping type, then the mask for the call variables in that target statement segment is the source table and the mapping format. The mapping format includes the source fields in the source table, the fields to be mapped in the target table, and the data conversion rules. The computer device obtains the call variables of the target statement segment based on this data mapping statement segment template.

[0175] In this embodiment, the statement segment template corresponding to the target statement segment is obtained based on the statement segment type. This facilitates the subsequent generation of statement segments based on the statement segment template, reducing the workload of manually writing code and shortening the development cycle. Furthermore, by using the statement segment template, developers can focus more on implementing business logic, lowering the barrier to entry for writing SQL code.

[0176] In an exemplary embodiment, the statement segment template is a table creation statement segment template, which contains a source table. Based on the task requirements of the target task and the statement segment template, such as... Figure 8 As shown, the specific processing procedure of step 504 includes steps 802 to 806. Wherein:

[0177] Step 802: Obtain the data structure of all fields in the source table, and determine the data structure of the first target field in the data structure of each field according to the task data of the target task.

[0178] During implementation, the computer equipment acquires the data structure of all fields in the source table. Based on the task data and requirements of the target task, the computer equipment selects the data structure of the first target field from the data structures of each field.

[0179] In an exemplary embodiment, the task data of the target task includes the processing object of the target task. The computer device obtains the data structure of all fields in the source table. The source table is the table that provides the data structure of the fields for the target table. The task data and task requirements of the target task include table creation requirements. The table creation requirements include the field requirements for each newly created field in the newly created table. For each newly created field requirement, the computer device determines whether a data structure exists in the source table that satisfies the field requirements of the newly created field. If a data structure exists that satisfies the field requirements of the newly created field, the computer device identifies that field as the first target field and caches the data structure of the first target field.

[0180] In an optional embodiment, the computer device obtains the data structure of all fields in the source table based on the source table name. Then, the computer device displays the data structure of each field. The target user selects and confirms a field based on the task requirements and data of the target task. In response to a triggering operation on that field, the computer device identifies that field as the first target field and caches the data structure of the first target field. The data structure includes the value of the field name, the value of the Chinese name of the field, and the value of the field type. The triggering operation for the field includes, but is not limited to, clicking and dragging operations.

[0181] Optionally, the table creation statement template includes a data frame for the source table. The computer device obtains the source table input by the target user based on the input box of the source table. The source table can be pre-selected in the target algorithm template, or it can be the name of the source table input by the target user. This application embodiment does not limit the source of the source table.

[0182] Step 804: Create the template and the task data of the target task based on the fields in the table creation statement template, and generate the data structure of the second target field.

[0183] The table creation statement template includes a field creation template. This field creation template is used to create data structures for new fields.

[0184] In implementation, if the source table does not have a data structure that meets the task data and task requirements of the target task, the computer device will create a template and the task data of the target task based on the fields, and generate a data structure for the second target field.

[0185] In an exemplary embodiment, the task data and task requirements of the target task include table creation requirements. These table creation requirements include the field requirements for each newly created field in the new table. For each newly created field's field requirements, the computer device determines whether a data structure exists in the source table that satisfies the field requirements. If no data structure exists in the source table that satisfies the field requirements, the computer device generates the field name, Chinese name, and field type of the second target field based on the field requirements and the field creation template, and constructs the data structure of the second target field based on its field name, Chinese name, and field type.

[0186] In an optional embodiment, the field creation template includes an input box for the field name, an input box for the Chinese name of the field, and a radio button for the field type. The radio button for the field type contains the full initial field type. The computer device obtains the field name of the second target field entered by the user through the field name input box, and obtains the Chinese name of the field entered by the target user based on the Chinese name input box. In response to the field type triggering operation, the computer device displays the full initial field type. The target user determines the initial field type from among the initial field types according to the field requirements. In response to the field type determination operation, the computer device obtains the initial field type determined by the user and determines the initial field type as the target type of the second target field. The computer device constructs the data structure of the second target field based on the field name, Chinese name, and field type of the second target field.

[0187] Step 806: Obtain the name of the temporary table, and determine the data structure of the first target field, the data structure of the second target field, and the name of the temporary table as the calling variables of the target task.

[0188] The statement segment template includes an input box for a temporary table.

[0189] In implementation, the computer device obtains the name of the temporary table entered by the target user through the input box of the temporary table. This temporary table name is also the name of the target table. The computer device combines the temporary table name, the data structure of the first target field, and the data structure of the second target field to obtain the calling variables of the target task.

[0190] In this embodiment, the calling variables of the target task are quickly filtered through the table creation statement segment template, which facilitates the subsequent generation of table creation statement segments based on the table creation statement segment template and calling variables, reducing the workload of manually writing code and shortening the development cycle.

[0191] In an exemplary embodiment, the statement segment template is a data mapping statement segment template, which includes a mapping target table and a mapping source table. Based on the task requirements of the target task and the statement segment template, such as... Figure 9As shown, the specific processing procedure of step 504 includes steps 902 to 908. Wherein:

[0192] Step 902: Obtain all source fields of the mapping source table and all fields to be mapped of the mapping target table.

[0193] In implementation, the computer device obtains all fields of the source table and identifies these fields as the source fields. Then, the computer device obtains the Chinese names and data types of each source field. Finally, the computer device retrieves all fields to be mapped from the target table in the database or data warehouse.

[0194] In an optional embodiment, the data mapping statement segment template includes input boxes for a target table and a source table. The computer device obtains the name of the target table through the target table input box and the name of the source table through the source table input box. The computer device obtains all fields of the target table through its name and identifies these fields as the total fields to be mapped. Simultaneously, the computer device obtains all fields of the source table from a database or data warehouse through its source table name and identifies these fields as the total source fields. Then, the computer device obtains the Chinese names and field types of the total source fields. The computer device displays the total source fields, their Chinese names, and field types, and also displays the total fields to be mapped from the target table.

[0195] Step 904: Based on the task data of the target task, determine each target source field in each source field, and determine the target mapping field that matches each target source field in each field to be mapped.

[0196] The task data for the target task includes various mapping requirements.

[0197] In implementation, the computer device determines each target source field in each source field according to each mapping requirement. Then, for each target source field, the computer device determines the target mapping field that matches the target source field in each field to be mapped, according to each mapping requirement.

[0198] In one exemplary embodiment, Figure 10 This is a schematic diagram showing a data mapping statement segment template in one embodiment. For example... Figure 10As shown, this data mapping statement template is divided into three parts. The first part includes the task name, loading algorithm, target table, source table, and DISTINCT (duplicate removal) option. The task name section displays the task name, and the loading algorithm section displays the name of the target algorithm template. The target table section retrieves the name of the target table and obtains all fields to be mapped from it. The source table section retrieves the name of the source table and obtains all source fields from it. The deduplication option determines whether to remove duplicate data. The second part is the field mapping configuration section. The field mapping section includes the mapping method, target source field, and other parameters. Figure 10 Target field in the target mapping field ( Figure 10 The mapping rules in the target source field, the Chinese name of the target source field, the field type of the target source field, and the data conversion rules ( Figure 10 The data transformation in the source table (including field order mapping and field name mapping) is part three, which is used to map the source fields of the source table.

[0199] The target user selects and determines a source field from among the source fields according to the mapping requirements. In response to the determination of the source field, the computer device designates the determined source field as the target source field and displays the name, Chinese name, and field type of the target source field in the second part. Then, for each target source field, the target user determines the field to be mapped from among the fields to be mapped, based on the mapping requirements. In response to the determination of the field to be mapped, the computer device designates that field as the target mapping field.

[0200] Step 906: Based on the task data of the target task, determine the data transformation rules between the target mapping field and the target source field, and construct the target mapping rules based on the data transformation rules, the target mapping field, and the target source field.

[0201] In implementation, the computer equipment determines the data transformation rules between each target mapping field and the target source field based on the mapping requirements. Then, the computer equipment combines each target source field, the target mapping field corresponding to the target source field, the target source field, and the data transformation rules between the target mapping fields to obtain the target mapping rules.

[0202] In one exemplary embodiment, since the data in different data tables may be stored in different ways, the computer device needs to set data conversion rules to convert the field format of the target source field into the field format of the target mapping field. The target user inputs the data conversion rules according to the mapping requirements, the field format of the target source field, and the field format of the target mapping field. The computer device obtains the data conversion rules input by the target user. Then, for each target source field, the computer device combines the target source field, the corresponding target mapping field, and the data conversion rules between the target source field and the target mapping field to obtain the target mapping rule.

[0203] Optionally, but not limited to, mapping can be developed through drag-and-drop, field order mapping, or automatic field name mapping.

[0204] Step 908: Determine the target mapping rules as the calling variables associated with the task data of the target task.

[0205] In implementation, the computer equipment determines the calling variables associated with the task data of each target task by defining the target mapping rules.

[0206] In this embodiment, by mapping the target source field in the mapping source table and the target mapping field in the mapping target table, and defining the conversion rules and business logic between the fields, the mapping relationship configuration can be completed quickly, thus improving development efficiency.

[0207] In one exemplary embodiment, Figure 11 A flowchart of a code generation method in another exemplary embodiment. (e.g.) Figure 11 As shown, the specific processing steps of this code generation method include:

[0208] Step 1101: Configure the algorithm template.

[0209] Step 1102: Read all data tables from the data warehouse and database.

[0210] Step 1103: Obtain each called variable from the full data table.

[0211] Step 1104: Map each calling variable to the algorithm template to generate the script for the target task.

[0212] In one exemplary embodiment, an online ETL script generation platform system and device are provided, which are used to execute the code generation method of this application. This online ETL script generation platform system and device supports remote configuration of the task metadata of the target task (ETL task) via a web interface. The task metadata includes the task requirements and attribute characteristics of the target task. Furthermore, this online ETL script generation platform system and device supports the selection of target algorithm templates and the assembly of code segments, thereby automatically generating SQL or ETL scripts compatible with different databases. The databases include, but are not limited to, DWS (Data Warehouse Service), Gbase, and Hive. This online ETL script generation platform system and device can assemble templates at the statement segment level, making ETL scripts more flexible, pluggable, and easy to maintain. That is, this online ETL script generation platform system and device can achieve ETL script generation for fine-grained code segments. Moreover, this online ETL script generation platform system and device supports the generation of complex business logic scripts at the aggregation layer, realizing multi-source aggregation, dynamic summarization, etc. That is, the online ETL script generation platform system and equipment can obtain call variables from different sources and map the call variables from each source to a target algorithm template to generate an ETL script or SQL script.

[0213] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.

[0214] Based on the same inventive concept, this application also provides a code generation apparatus for implementing the code generation method described above. The solution provided by this apparatus is similar to the implementation scheme described in the above method; therefore, the specific limitations in one or more code generation apparatus embodiments provided below can be found in the limitations of the code generation method described above, and will not be repeated here.

[0215] In one exemplary embodiment, such as Figure 12As shown, a code generation apparatus 1200 is provided, including: an acquisition module 1201, a determination module 1202, and a generation module 1203, wherein:

[0216] The acquisition module 1201 is used to obtain the task template in response to the task code generation request of the target task.

[0217] The determination module 1202 is used to determine the target algorithm template that matches the processing logic of the target task in the task template based on the attribute feature information of the target task.

[0218] The generation module 1203 is used to obtain the calling variables associated with the task data of the target task according to the task requirements of the target task, and map each calling variable to the target algorithm template to generate the task code of the target task.

[0219] In one exemplary embodiment, the code generation apparatus 1200 further includes:

[0220] The second acquisition module is used to acquire the algorithm generation template in response to the algorithm template generation request; the algorithm generation template includes the initial algorithm name, the initial algorithm type, and the statement segment template.

[0221] The second determining module is used to determine the algorithm name based on the initial algorithm name and the algorithm type based on the initial algorithm type.

[0222] The second generation module is used to generate statement segments based on the statement segment template, and to construct an algorithm template based on the algorithm name, algorithm type and statement segment; the algorithm template is used to determine the target algorithm template.

[0223] In one exemplary embodiment, the statement segment template includes a statement segment type, an initial statement segment, an initial source table, an initial target table, initial deduplication options, and an initial segment end processing statement; the second generation module includes a first generation submodule and a first construction submodule. The first generation submodule includes:

[0224] The first display submodule is used to display the full range of statement segments in response to trigger operations of statement segment types.

[0225] The first acquisition submodule is used to acquire each initial statement segment under the target statement segment type in response to the determination operation of the target statement segment type in the full statement segment type.

[0226] The second generation submodule is used to generate statement segments based on each initial statement segment, initial source table, initial target table, initial deduplication options, and initial segment end processing statement.

[0227] In one exemplary embodiment, the determining module 1202 includes:

[0228] The first determination submodule is used to determine the target keywords and target algorithm type based on the attribute feature information and processing logic of the target task.

[0229] The second construction submodule is used to construct query requests based on target keywords and target algorithm type.

[0230] The second determination submodule is used to determine the target algorithm template that matches the processing logic of the target task from among the algorithm templates of the task template based on the query request.

[0231] In one exemplary embodiment, the target algorithm template includes target statement segments, and the generation module 1203 includes a second acquisition submodule and a third generation submodule. The second acquisition submodule includes:

[0232] The fourth submodule is used to obtain the statement template of each target statement segment based on its statement segment type.

[0233] The fifth submodule is used to obtain the call variables associated with the task data of the target task based on the task requirements of the target task and the template of each statement segment.

[0234] In one exemplary embodiment, the fourth acquisition submodule includes:

[0235] The sixth submodule is used to obtain the table creation statement template if the statement type of the target statement segment is table creation, and to determine the table creation statement template as the statement template of the target statement segment.

[0236] The seventh submodule is used to obtain the data mapping statement segment template if the statement segment type of the target statement segment is data mapping type, and to determine the data mapping statement segment template as the statement segment template of the target statement segment.

[0237] In an exemplary embodiment, the statement segment template is a table creation statement segment template, which contains a source table. The fifth acquisition module includes:

[0238] The eighth acquisition submodule is used to acquire the data structure of all fields in the source table, and determine the data structure of the first target field in the data structure of each field according to the task data of the target task.

[0239] The fourth generation submodule is used to create templates and target task data based on the fields in the table creation statement template, and generate the data structure of the second target field.

[0240] The third determination submodule is used to obtain the temporary table name and determine the data structure of the first target field, the data structure of the second target field, and the temporary table name as the calling variables of the target task.

[0241] In an exemplary embodiment, the statement segment template is a data mapping statement segment template, which includes a mapping target table and a mapping source table. The fifth acquisition submodule includes:

[0242] The ninth submodule is used to obtain all source fields of the mapping source table and all fields to be mapped of the mapping target table.

[0243] The fourth determination submodule is used to determine each target source field in each source field based on the task data of the target task, and to determine the target mapping field that matches each target source field in each field to be mapped.

[0244] The fifth determination submodule is used to determine the data conversion rules between the target mapping field and the target source field based on the task data of the target task, and to construct the target mapping rules based on the data conversion rules, the target mapping field and the target source field.

[0245] The sixth determination submodule is used to determine the calling variables associated with the task data of each target mapping rule.

[0246] Each module in the aforementioned code generation device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the memory of a computer device as software, so that the processor can call and execute the operations corresponding to each module.

[0247] In one exemplary embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as follows: Figure 13As shown, the computer device includes a processor, memory, input / output interfaces, a communication interface, a display unit, and an input device. The processor, memory, and input / output interfaces are connected via a system bus, and the communication interface, display unit, and input device are also connected to the system bus via the input / output interfaces. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The input / output interfaces are used for exchanging information between the processor and external devices. The communication interface is used for wired or wireless communication with external terminals; wireless communication can be achieved through Wi-Fi, mobile cellular networks, Near Field Communication (NFC), or other technologies. When the computer program is executed by the processor, it implements a code generation method. The display unit is used to form a visually visible image and can be a display screen, a projection device, or a virtual reality imaging device. The display screen can be an LCD screen or an e-ink screen. The input device of the computer device can be a touch layer covering the display screen, or buttons, trackballs, or touchpads set on the casing of the computer device, or external keyboards, touchpads, or mice, etc.

[0248] Those skilled in the art will understand that Figure 13 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.

[0249] In one embodiment, a computer device is also provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in the above method embodiments.

[0250] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon that, when executed by a processor, implements the steps in the above method embodiments.

[0251] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps in the above method embodiments.

[0252] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, artificial intelligence (AI) processors, etc., and are not limited to these.

[0253] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.

[0254] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.

Claims

1. A code generation method, characterized in that, The method includes: In response to the task code generation request for the target task, obtain the task template; Based on the attribute feature information of the target task, a target algorithm template that matches the processing logic of the target task is determined in the task template; Based on the task requirements of the target task, the call variables associated with the task data of the target task are obtained, and each of the call variables is mapped to the target algorithm template to generate the task code of the target task.

2. The method according to claim 1, characterized in that, Before obtaining the task template in response to the task code generation request for the target task, the method further includes: In response to an algorithm template generation request, an algorithm generation template is obtained; the algorithm generation template includes an initial algorithm name, an initial algorithm type, and a statement segment template; The algorithm name is determined based on the initial algorithm name, and the algorithm type is determined based on the initial algorithm type; A statement segment is generated based on the statement segment template, and an algorithm template is constructed based on the algorithm name, the algorithm type, and the statement segment; the algorithm template is used to determine the target algorithm template.

3. The method according to claim 2, characterized in that, The statement segment template includes a statement segment type, an initial statement segment, an initial source table, an initial target table, initial deduplication options, and initial end-of-segment processing statements; generating a statement segment based on the statement segment template includes: In response to a trigger action of a statement segment type, display the full statement segment type; In response to the determination of the target statement segment type in the full statement segment type, obtain each initial statement segment under the target statement segment type; Statement segments are generated based on the initial statement segments, the initial source table, the initial target table, the initial deduplication options, and the initial segment end-processing statements.

4. The method according to claim 1, characterized in that, The step of determining a target algorithm template that matches the processing logic of the target task from the task template based on the attribute feature information of the target task includes: Based on the attribute features and processing logic of the target task, the target keywords and target algorithm type are determined; Construct a query request based on the target keywords and the target algorithm type; Based on the query request, a target algorithm template that matches the processing logic of the target task is determined from among the algorithm templates of the task template.

5. The method according to claim 1, characterized in that, The target algorithm template contains various target statement segments. The step of obtaining the call variables associated with the task data of the target task according to the task requirements of the target task includes: For each target statement segment, obtain the statement segment template of the target statement segment according to the statement segment type of the target statement segment; Based on the task requirements of the target task and the templates of each statement segment, obtain the call variables associated with the task data of the target task.

6. The method according to claim 5, characterized in that, The step of obtaining the statement segment template of the target statement segment based on the statement segment type of the target statement segment includes: If the statement segment type of the target statement segment is a table creation type, obtain the table creation statement segment template and determine the table creation statement segment template as the statement segment template of the target statement segment; If the statement segment type of the target statement segment is a data mapping type, obtain the data mapping statement segment template and determine the data mapping statement segment template as the statement segment template of the target statement segment.

7. The method according to claim 5, characterized in that, The statement segment template is a table creation statement segment template, which contains a source table. The step of obtaining the call variables associated with the task data of the target task based on the task requirements of the target task and the statement segment template includes: Obtain the data structure of all fields in the source table, and determine the data structure of the first target field in the data structure of each field according to the task data of the target task; Based on the fields in the table creation statement template, a template and the task data of the target task are created to generate the data structure of the second target field; Obtain the name of the temporary table, and determine the data structure of the first target field, the data structure of the second target field, and the name of the temporary table as the calling variables of the target task.

8. The method according to claim 5, characterized in that, The statement segment template is a data mapping statement segment template, which includes a mapping target table and a mapping source table. The step of obtaining the call variables associated with the task data of the target task based on the task requirements of the target task and the statement segment template includes: Obtain all source fields of the mapping source table and all fields to be mapped of the mapping target table; Based on the task data of the target task, each target source field is determined in each of the source fields, and a target mapping field matching each target source field is determined in each of the fields to be mapped; Based on the task data of the target task, determine the data conversion rules between the target mapping field and the target source field, and construct the target mapping rules based on the data conversion rules, the target mapping field, and the target source field; Each of the target mapping rules is determined as a calling variable associated with the task data of the target task.

9. A code generation device, characterized in that, The device includes: The retrieval module is used to retrieve the task template in response to the task code generation request of the target task; The determination module is used to determine a target algorithm template that matches the processing logic of the target task from the task template based on the attribute feature information of the target task. The generation module is used to obtain the calling variables associated with the task data of the target task according to the task requirements of the target task, and map each of the calling variables to the target algorithm template to generate the task code of the target task.

10. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 8.

Citation Information

Patent Citations

  • Data processing code generation method and device

    CN115390904A

  • Code generation method and system for batch processing tasks, electronic equipment and storage medium

    CN116466927A

  • Method and device for automatically generating script code, electronic equipment and medium

    CN119415102A

  • Methods and systems for template driven data mining task editing

    US8370386B1