SQL model automatic execution method, related device and computer storage medium
By automating the generation and optimization of SQL queries, the problem of business personnel having to write SQL code has been solved, achieving efficient SQL model development and version compatibility.
Patent Information
- Application Number
- CN202511724264.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-23
- Publication Date
- 2026-02-17
Smart Images

Figure CN121542283A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of database technology, and in particular to a method for automating the execution of SQL models, related devices, and computer storage media. Background Technology
[0002] In fields such as data analysis and auditing, the Structured Query Language (SQL) model is widely used due to its powerful data processing capabilities.
[0003] However, in the current process of developing SQL models, business personnel need to master both technical logic and SQL programming. The high technical threshold leads to low efficiency when business personnel are building SQL models. Furthermore, the need for repeated coding in similar business scenarios further reduces the efficiency of building SQL models. Summary of the Invention
[0004] In view of this, the present invention provides an automated SQL model execution method, related apparatus and computer storage medium to solve the problem of low efficiency in SQL model modeling.
[0005] The first aspect of this invention provides a method for automating the execution of an SQL model, comprising:
[0006] Receive model selection information and display the parameters required for configuring the target model to the user; wherein, the target model is the model selected by the user in the model selection information;
[0007] Receive configuration parameters of the target model input by the user;
[0008] An abstract syntax tree is generated based on the configuration parameters and model type of the target model.
[0009] Based on the abstract syntax tree, the SQL query is optimized to obtain the optimized SQL statement;
[0010] The target model is executed based on the optimized SQL statement to generate SQL query results.
[0011] Optionally, generating an abstract syntax tree based on the configuration parameters and model type of the target model includes:
[0012] Load the pre-compiled SQL template corresponding to the model type into the model library; wherein, each SQL model in the model library is encapsulated as a JSON description file, and a pre-compiled SQL template is generated based on the JSON description file;
[0013] An abstract syntax tree is generated based on the pre-compiled SQL template corresponding to the model type and the configuration parameters of the target model.
[0014] Optionally, after receiving the configuration parameters of the target model input by the user, the method further includes:
[0015] The configuration parameters are verified to obtain the configuration parameter verification results;
[0016] If the configuration parameter verification results indicate that there are missing items in the current configuration parameters, then Bayesian network inference is used to complete the missing items.
[0017] Optionally, after executing the target model based on the optimized SQL statement and generating the SQL query result, the process further includes:
[0018] A JSON description list is generated based on the SQL query results.
[0019] A second aspect of the present invention provides an automated SQL model execution device, comprising:
[0020] The first receiving unit is used to receive model selection information;
[0021] The display unit is used to show the user the parameters required for configuring the target model; wherein the target model is the model selected by the user from the model selection information;
[0022] The second receiving unit is used to receive the configuration parameters of the target model input by the user;
[0023] Abstract syntax tree generation unit, used to generate an abstract syntax tree based on the configuration parameters of the target model and the model type of the target model;
[0024] The optimization unit is used to optimize the SQL query based on the abstract syntax tree to obtain the optimized SQL statement;
[0025] The model execution unit is used to execute the target model based on the optimized SQL statement and generate SQL query results.
[0026] Optionally, the abstract syntax tree generation unit includes:
[0027] A loading unit is used to load a pre-compiled SQL template corresponding to the model type from the model library; wherein each SQL model in the model library is encapsulated as a JSON description file, and a pre-compiled SQL template is generated based on the JSON description file;
[0028] Abstract syntax tree generation subunit is used to generate an abstract syntax tree based on the pre-compiled SQL template corresponding to the model type and the configuration parameters of the target model.
[0029] Optionally, the SQL model automated execution device further includes:
[0030] The verification unit is used to verify the configuration parameters and obtain the configuration parameter verification result;
[0031] The completion unit is used to perform Bayesian network inference to complete the missing items if the configuration parameter verification results show that there are missing items in the current configuration parameters.
[0032] Optionally, the SQL model automated execution device further includes:
[0033] The JSON description generation unit is used to generate a list of JSON descriptions based on the SQL query results.
[0034] A third aspect of the present invention provides an electronic device, comprising:
[0035] One or more processors;
[0036] A storage device on which one or more programs are stored;
[0037] When the one or more programs are executed by the one or more processors, the one or more processors implement the SQL model automated execution method as described in any one of the first aspects.
[0038] A fourth aspect of the present invention provides a computer storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the SQL model automated execution method as described in any one of the first aspects.
[0039] As can be seen from the above solutions, this invention provides an automated SQL model execution method, related apparatus, and computer storage medium. It generates an abstract syntax tree based on the user-selected model type and input configuration parameters, optimizes the SQL query based on the abstract syntax tree, and obtains an optimized SQL statement. Finally, it executes the target model based on the optimized SQL statement to generate the SQL query result. This allows business personnel to complete modeling without writing SQL code, effectively improving their modeling efficiency. Attached Figure Description
[0040] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.
[0041] Figure 1 A detailed flowchart of an automated SQL model execution method provided in an embodiment of the present invention;
[0042] Figure 2 A schematic diagram of an automated SQL model execution device provided in another embodiment of the present invention;
[0043] Figure 3 This is a schematic diagram of an electronic device for implementing an automated SQL model execution method, as provided in another embodiment of the present invention. Detailed Implementation
[0044] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0045] The term "comprising" and its variations as used herein are open-ended inclusions, meaning "including but not limited to". The term "based on" means "at least partially based on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". Definitions of other terms will be given in the description below.
[0046] It should be noted that the information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this invention are all information and data authorized by the user or fully authorized by all parties.
[0047] It should be noted that the concepts of "first" and "second" mentioned in this invention are only used to distinguish different devices, modules or units, and are not used to limit the order of functions performed by these devices, modules or units or their interdependencies.
[0048] It should be noted that the terms "a" and "a plurality of" used in this invention are illustrative rather than restrictive. Those skilled in the art should understand that, unless otherwise expressly indicated in the context, they should be understood as "one or more".
[0049] This invention provides a method for automating the execution of SQL models, such as... Figure 1 As shown, the specific steps include:
[0050] S101. Receive model selection information and display the parameters required for the target model configuration to the user.
[0051] The target model is the model selected by the user in the model selection information, such as `recommend_v3`.
[0052] In the actual application of this invention, users can submit the parameters required by the model through web pages, application programming interfaces (APIs), etc. The format of the parameters can be, but is not limited to, JSON format, and is not limited here.
[0053] The parameters required for model configuration include, but are not limited to, account list ID, product category, risk threshold coefficient, etc., which are not specified here.
[0054] It should be noted that the risk threshold coefficient is optional. It is calculated by the system based on historical data by default, or it can be filled in by the user. There is no restriction here.
[0055] S102, Receive the configuration parameters of the target model input by the user.
[0056] Optionally, in another embodiment of the present invention, after receiving the configuration parameters of the target model input by the user, the method further includes:
[0057] The configuration parameters are verified to obtain the verification results. If the verification results show that there are missing items in the current configuration parameters, Bayesian network inference is used to complete the missing items.
[0058] In the actual application of this invention, the methods for verifying configuration parameters include, but are not limited to, type checking, constraint verification, security policy detection, parameter missing checking, etc., and are not limited here.
[0059] Among them, type checking can be a mandatory validation of parameter types based on model definition; constraint validation can be a validation of complex constraints (such as date format, array length, etc.) using a regular expression engine; security policy checking can be implemented by validating user permissions through data anonymization rules and access control lists; parameter missing checking can be performed by inferring missing items and completing them through Bayesian networks, which is not limited here.
[0060] It's important to note that a Bayesian network is a probabilistic graphical model that represents dependencies between variables using a directed acyclic graph (DAG) and employs Bayes' theorem for probabilistic inference. When missing values exist in the data, a Bayesian network can construct a probabilistic model of the relationship between other variables and the missing variable, thereby predicting the missing values. For example, it can estimate missing values using known variables. Furthermore, a Bayesian network can iteratively optimize the estimation of missing values through multiple rounds, generating multiple possible complete datasets. Finally, pooling is used to obtain the summarized statistical results, but this is not limited here.
[0061] S103. Generate an abstract syntax tree based on the configuration parameters and model type of the target model.
[0062] In the Abstract Syntax Tree (AST), each node corresponds to a syntax element in an SQL statement, such as a SELECT clause, FROM clause, or WHERE condition. Nodes are connected by edges to form a tree structure that reflects the query hierarchy and dependencies. This tree structure presents the various components of the query in a logically clear and hierarchical manner.
[0063] Optionally, in another embodiment of the present invention, one implementation of step S103 specifically includes:
[0064] Load the pre-compiled SQL template corresponding to the model type from the model library; generate an abstract syntax tree based on the pre-compiled SQL template corresponding to the model type and the configuration parameters of the target model.
[0065] Each SQL model in the model library is encapsulated as a JSON description file, and a pre-compiled SQL template is generated based on the JSON description file.
[0066] Specifically, first, the SQL model (such as the database table structure) is encapsulated into a JSON description file for easy management and transmission. Then, based on this JSON description file, a template engine (such as Jinja2) can dynamically generate specific SQL templates, which are then populated with parameters and executed.
[0067] In the practical application of this invention, the dependencies between models can be stored by, but are not limited to, using a graph database. Edge attributes include metadata such as data flow direction (full / incremental) and version compatibility, which are not limited here.
[0068] Specifically, functional encapsulation technology is used to abstract the SQL model into a triple of <input parameters, business logic, output specifications>, to establish a model lineage graph and realize the visual traceability of dependencies between models.
[0069] In the practical application of this invention, the SHA-256 hash value can also be calculated using the model to verify the integrity of the template to prevent tampering, which is not limited here.
[0070] In the practical application of this invention, the way to generate an abstract syntax tree based on the pre-compiled SQL template corresponding to the model type and the configuration parameters of the target model can be to build a parameter mapping table and dynamically generate the AST. Specifically, the visitor pattern is used to traverse the AST and replace the parameter placeholders.
[0071] S104. Optimize the SQL query based on the abstract syntax tree to obtain the optimized SQL statement.
[0072] In the specific implementation of this invention, the methods for optimizing SQL include, but are not limited to, predicate pushdown, constant folding, column pruning, and automatic index recommendation, etc., and are not limited here.
[0073] Specifically, predicate pushdown can push filtering conditions (such as the `WHERE` clause) down to the data source (such as the table scan stage) as far as possible, reducing the amount of data processed subsequently. For example, filtering invalid data before a JOIN operation can reduce the number of rows involved in the calculation by 60%-80%.
[0074] Constant folding involves calculating constant expressions (such as `2+3*5`) at compile time, avoiding repeated calculations at runtime and reducing CPU overhead.
[0075] Column pruning reduces I / O and memory usage by reading only the columns actually needed for the query. For example, if a table has 100 columns but the query only needs 5, the amount of data read can be reduced by 95%.
[0076] Automatic index recommendation automatically selects the optimal index (such as B-Tree, Bitmap) based on the query pattern, converting full table scans into index scans and reducing query latency by 30%-90%.
[0077] In the practical application of this invention, dialect adaptation can also be performed on the SQL statements to ensure that the generated SQL statements are compatible with the syntactic differences of different database systems.
[0078] Specifically, the ANTLR multi-dialect parser can be used to generate SQL that is compatible with different databases, but this is not limited to that.
[0079] S105. Based on the optimized SQL statement, execute the target model and generate SQL query results.
[0080] In the practical application of this invention, the target model can be executed in a distributed manner based on the optimized SQL statement, which is not limited here.
[0081] Specifically, intelligent sharding strategies can be used to rationally divide the dataset into cluster nodes to maximize parallel efficiency. Intelligent sharding strategies include sharding key selection and dynamic sharding adjustment, etc., which are not limited here.
[0082] The sharding key can be selected based on column cardinality and data distribution. For example, time-series data can be sharded using the time field, and user data can be sharded using the `user_id` hash.
[0083] Dynamic sharding adjustment allows for real-time adjustment of the number of shards based on the number of cluster nodes, avoiding small file issues. For example, when the cluster expands from 10 nodes to 20 nodes, the number of shards automatically increases from 200 to 400.
[0084] In the practical application of this invention, the execution plan can also be dynamically adjusted, that is, the task scheduling can be optimized according to the runtime state, which is not limited here.
[0085] The dynamic execution plan adjustment includes, but is not limited to, resource-aware scheduling, data localization, and fault-tolerant retries, etc., which are not limited here.
[0086] Resource-aware scheduling prioritizes allocating tasks to idle nodes by monitoring node CPU / memory utilization. Data localization aims to start computing tasks on nodes where data is stored as much as possible to reduce network transmission. Fault-tolerant retry adopts an exponential backoff strategy for failed tasks (such as retrying at intervals of 1s, 2s, and 4s).
[0087] For example, if a network latency of more than 200ms is detected on a certain node, the task will be automatically migrated to another node.
[0088] Optionally, in another embodiment of the present invention, in order to eliminate the format differences of the results returned by different databases and data sources and improve data compatibility, a JSON description list can also be generated based on the SQL query results after the SQL query results are generated.
[0089] Specifically, methods such as database built-in functions and application-layer transformations can be used to generate a JSON description list based on SQL query results; no specific limitations are specified here.
[0090] In the actual application of this invention, the JSON description list can be presented in the form of a table or graphics on the front end, and there is no limitation here.
[0091] In the practical application of this invention, a cache key generation algorithm can also be used to generate a unique cache key, avoid conflicts between different query results, exclude volatile parameters, and ensure that the same logical queries can reuse the cache.
[0092] In the practical application of this invention, isolation of the model's runtime environment can be achieved through, but is not limited to, Docker containers; no limitation is made here.
[0093] In the practical application of this invention, runtime indicators can also be collected; when data distribution offset is detected (e.g., KS test p<0.01), and the result quality is lower than the threshold (e.g., <0.8) for three consecutive times, the conditions for model retraining are automatically triggered, thereby realizing the effect feedback loop.
[0094] Of course, this invention is also equipped with corresponding exception handling mechanisms. For parameter type errors, it can return an error code (such as 4001) along with a type conversion suggestion; for parameter constraint violations, it can generate a visual constraint conflict report; for execution failures, it can set an automatic rollback mechanism (such as retaining the 10 most recent successful checkpoints); for resource overruns, it can dynamically apply for cloud resource expansion, which is not limited here.
[0095] In terms of security protection, AST pattern matching can be used to identify suspicious structures during SQL injection, and data leakage protection can also be achieved through dynamic desensitization of result sets (applying different strategies according to roles). There are no limitations here.
[0096] Among them, dynamic result set desensitization is a security technology that performs real-time desensitization processing on the returned sensitive information during the data query process. Its core principle is: when a user accesses the production database, the system will intercept the query request and process the sensitive fields according to the preset desensitization rules (such as replacement, masking, encryption, etc.) before the data is returned, to ensure that the returned result set does not contain the original plaintext data.
[0097] In the practical application of this invention, a three-tier architecture design can be used, but is not limited to, to implement the automated execution method of the SQL model:
[0098] 1. Declarative configuration layer: Provides a visual interface and API access points to receive user model selections and parameter inputs;
[0099] 2. Model Assembly Engine: Includes AST generator, parameter derivation module, and optimizer core components;
[0100] 3. Distributed Execution Layer: Supports intelligent execution environments that adapt to multiple engines (Spark / Flink / Prestro).
[0101] This invention provides an automated SQL model execution method. It generates an abstract syntax tree (AST) based on the user-selected model type and input configuration parameters, optimizes the SQL query based on the AST, and obtains an optimized SQL statement. Finally, it executes the target model based on the optimized SQL statement to generate the SQL query result. This allows business personnel to complete modeling without writing SQL code, effectively improving their modeling efficiency. Furthermore, the system remains compatible during model version upgrades, achieving a 98.7% compatibility rate.
[0102] Another embodiment of the present invention provides an automated SQL model execution device, such as... Figure 2 As shown, it specifically includes:
[0103] The first receiving unit 201 is used to receive model selection information.
[0104] Display unit 202 is used to display the parameters required for configuring the target model to the user.
[0105] The target model is the model selected by the user in the model selection information.
[0106] The second receiving unit 203 is used to receive the configuration parameters of the target model input by the user.
[0107] Abstract syntax tree generation unit 204 is used to generate an abstract syntax tree based on the configuration parameters of the target model and the model type of the target model.
[0108] In the Abstract Syntax Tree (AST), each node corresponds to a syntax element in an SQL statement, such as a SELECT clause, FROM clause, or WHERE condition. Nodes are connected by edges to form a tree structure that reflects the query hierarchy and dependencies. This tree structure presents the various components of the query in a logically clear and hierarchical manner.
[0109] Optionally, in another embodiment of the present invention, one implementation of the abstract syntax tree generation unit 204 includes:
[0110] The loading unit is used to load the pre-compiled SQL template corresponding to the model type from the model library.
[0111] Each SQL model in the model library is encapsulated as a JSON description file, and a pre-compiled SQL template is generated based on the JSON description file.
[0112] The abstract syntax tree generation sub-unit is used to generate an abstract syntax tree based on the pre-compiled SQL template corresponding to the model type and the configuration parameters of the target model.
[0113] The specific working process of the units disclosed in the above embodiments of the present invention can be found in the corresponding method embodiments, and will not be repeated here.
[0114] Optimization unit 205 is used to optimize SQL queries based on abstract syntax trees to obtain optimized SQL statements.
[0115] The model execution unit 206 is used to execute the target model based on the optimized SQL statement and generate SQL query results.
[0116] For details on the specific operation of the units disclosed in the above embodiments of the present invention, please refer to the corresponding method embodiments, such as... Figure 1 As shown, it will not be elaborated further here.
[0117] Optionally, in another embodiment of the present invention, one implementation of the SQL model automated execution device further includes:
[0118] The verification unit is used to verify the configuration parameters and obtain the verification results.
[0119] The completion unit is used to perform Bayesian network inference to complete the missing items if the configuration parameter verification results show that there are missing items in the current configuration parameters.
[0120] Bayesian networks are probabilistic graphical models that represent dependencies between variables using a directed acyclic graph (DAG) and employ Bayes' theorem for probabilistic inference. When missing values exist in the data, Bayesian networks can construct probabilistic relationship models between other variables and the missing variable, thereby predicting the missing values. For example, they can estimate missing values using known variables. Bayesian networks can also iteratively optimize the estimation of missing values through multiple rounds, generating multiple possible complete datasets. Finally, pooling is used to obtain the summarized statistical results, which are not limited here.
[0121] The specific working process of the units disclosed in the above embodiments of the present invention can be found in the corresponding method embodiments, and will not be repeated here.
[0122] Optionally, in another embodiment of the present invention, one implementation of the SQL model automated execution device further includes:
[0123] The JSON description generation unit is used to generate a list of JSON descriptions based on the results of an SQL query.
[0124] The specific working process of the units disclosed in the above embodiments of the present invention can be found in the corresponding method embodiments, and will not be repeated here.
[0125] This invention provides an automated SQL model execution device. It generates an abstract syntax tree (AST) based on the user-selected model type and input configuration parameters, optimizes the SQL query based on the AST, and obtains an optimized SQL statement. Finally, it executes the target model based on the optimized SQL statement to generate the SQL query result. This allows business personnel to complete modeling without writing SQL code, effectively improving their modeling efficiency. Furthermore, the system remains compatible during model version upgrades, achieving a 98.7% compatibility rate.
[0126] The functions described above in this document can be performed at least in part by one or more hardware logic components. For example, exemplary types of hardware logic components that can be used, without limitation, include: field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), system-on-a-chip (SoCs), complex programmable logic devices (CPLDs), and so on.
[0127] Another embodiment of the present invention provides an electronic device, such as... Figure 3 As shown, it includes:
[0128] One or more processors 301.
[0129] Storage device 302, on which one or more programs are stored.
[0130] When the one or more programs are executed by the one or more processors 301, the one or more processors 301 implement the SQL model automated execution method as described in the above embodiments.
[0131] Another embodiment of the present invention provides a computer storage medium storing a computer program thereon, wherein the computer program, when executed by a processor, implements the SQL model automated execution method as described in the above embodiments.
[0132] In the context of this invention, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. Machine-readable media can include, but are not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0133] It should be noted that the computer-readable medium described above in this invention can be a computer-readable signal medium, a computer-readable storage medium, or any combination thereof. A computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this invention, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In this invention, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium can be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to: wires, optical fibers, RF (radio frequency), etc., or any suitable combination thereof.
[0134] The aforementioned computer-readable medium may be included in the aforementioned electronic device; or it may exist independently and not assembled into the electronic device.
[0135] Another embodiment of the present invention provides a computer program product, which, when executed, is used to perform the above-described automated SQL model execution method.
[0136] In particular, according to embodiments of the present invention, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of the present invention include a computer program product comprising a computer program carried on a non-transitory computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device, or installed from a storage device, or installed from a ROM. When the computer program is executed by a processing device, it performs the functions defined in the methods of the embodiments of the present invention.
[0137] Although the subject matter has been described using language specific to structural features and / or methodological logic, it should be understood that the subject matter defined in this invention is not necessarily limited to the specific features or actions described above. Rather, the specific features and actions described above are merely exemplary forms for implementing the invention.
[0138] While several specific implementation details are included in the foregoing discussion, these should not be construed as limiting the scope of the invention. Certain features described in the context of individual embodiments may also be implemented in combination in a single embodiment. Conversely, various features described in the context of a single embodiment may also be implemented individually or in any suitable sub-combination in multiple embodiments.
[0139] The above description is merely a preferred embodiment of the present invention and an explanation of the technical principles employed. Those skilled in the art should understand that the scope of the invention is not limited to the specific combination of the above-described technical features, but also includes other technical solutions formed by arbitrary combinations of the above-described technical features or their equivalents without departing from the inventive concept. For example, technical solutions formed by substituting the above-described features with technical features of the present invention (but not limited to) that have similar functions.
Claims
1. A method for automated execution of SQL models, characterized in that, The method comprises the following steps: receiving model selection information and showing the user required parameters for configuring a target model; wherein the target model is a model selected by the user in the model selection information; receiving configuration parameters of the target model input by the user; generating an abstract syntax tree according to the configuration parameters of the target model and the model type of the target model; optimizing a SQL query based on the abstract syntax tree to obtain an optimized SQL statement; executing the target model based on the optimized SQL statement to generate a SQL query result.
2. The method of claim 1, wherein, The step of generating an abstract syntax tree according to the configuration parameters of the target model and the model type of the target model comprises the following steps: loading a precompiled SQL template corresponding to the model type in a model library; wherein each SQL model in the model library is encapsulated as a JSON description file, and a precompiled SQL template is generated based on the JSON description file; generating an abstract syntax tree according to the precompiled SQL template corresponding to the model type and the configuration parameters of the target model.
3. The method of claim 1, wherein, After the step of receiving the configuration parameters of the target model input by the user, the method further comprises the following steps: verifying the configuration parameters to obtain a configuration parameter verification result; if the configuration parameter verification result indicates that there are missing items in the current configuration parameters, performing Bayesian network inference to complete the missing items.
4. The method of claim 1, wherein, After the step of executing the target model based on the optimized SQL statement to generate a SQL query result, the method further comprises the following step: generating a JSON description list based on the SQL query result.
5. A SQL model automated execution apparatus characterized by comprising: The method comprises the following steps: a first receiving unit configured to receive model selection information; a display unit configured to show the user required parameters for configuring a target model; wherein the target model is a model selected by the user in the model selection information; a second receiving unit configured to receive configuration parameters of the target model input by the user; an abstract syntax tree generation unit configured to generate an abstract syntax tree according to the configuration parameters of the target model and the model type of the target model; an optimization unit configured to optimize a SQL query based on the abstract syntax tree to obtain an optimized SQL statement; a model execution unit configured to execute the target model based on the optimized SQL statement to generate a SQL query result.
6. The SQL model automated execution apparatus according to claim 5, wherein The abstract syntax tree generation unit comprises the following units: a loading unit configured to load a precompiled SQL template corresponding to the model type in a model library; wherein each SQL model in the model library is encapsulated as a JSON description file, and a precompiled SQL template is generated based on the JSON description file; an abstract syntax tree generation subunit configured to generate an abstract syntax tree according to the precompiled SQL template corresponding to the model type and the configuration parameters of the target model.
7. The SQL model automated execution apparatus according to claim 5, wherein The method further comprises the following steps: a verification unit configured to verify the configuration parameters to obtain a configuration parameter verification result; a completion unit configured to perform Bayesian network inference to complete missing items if the configuration parameter verification result indicates that there are missing items in the current configuration parameters.
8. The SQL model automated execution apparatus according to claim 5, wherein, The method further comprises the following step: a JSON description generation unit configured to generate a JSON description list based on the SQL query result.
9. An electronic device, comprising: The method comprises the following steps: one or more processors; a storage device having stored thereon one or more programs; the one or more programs, when executed by the one or more processors, cause the one or more processors to carry out the method of automatically executing a SQL model according to any one of claims 1 to 4.
10. A computer storage medium, characterized in that, a computer program product, comprising a computer readable medium having stored thereon the computer program, wherein the computer program is executable by a processor to cause the processor to carry out the method of automatically executing a SQL model according to any one of claims 1 to 4.