Query statement generation method and device, electronic equipment and storage medium

By obtaining and processing target configuration items and selecting sequence identifiers, accurate query statements are generated, which solves the problem of complex dependencies between business forms and query statements in the prior art, resulting in reduced generation accuracy, and achieves a highly accurate query statement generate.

CN119474131APending Publication Date: 2025-02-18PING AN BANK CO LTD
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202411597045.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-08
Publication Date
2025-02-18

AI Technical Summary

Technical Problem

The prior art cannot effectively learn the complex dependencies between business forms and query statements, resulting in a decrease in the accuracy of query statement generation.

Method used

By obtaining the target configuration item and selection order identifier, creating a business form and converting it into a query structure, splicing and updating the initial query statement in the selection order, and generating the target query statement.

Benefits of technology

It improves the accuracy of query statement generation, ensures the logical order and syntax accuracy of query statements, and is suitable for form creation and data query in different business scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119474131A_ABST
    Figure CN119474131A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a query statement generation method and device, electronic equipment and a storage medium, and belongs to the technical field of artificial intelligence. The method comprises the following steps: acquiring a target configuration item and a selection sequence identifier of the target configuration item, creating a business form according to the target configuration item, performing form analysis on the business form to obtain a form object, converting the form object into query structural bodies, splicing the query structural bodies according to the selection sequence identifier to obtain an initial query statement, and storing the initial query statement in a database; the initial query statement is a character string, the initial query statement is subjected to statement updating, the target query statement is obtained, and the query statement generation accuracy can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of artificial intelligence technology, and is applicable to the field of financial technology technology, and in particular to a query statement generation method and device, an electronic device, and a storage medium. Background Art

[0002] When storing data, query statements can be used to improve data accessibility and ensure that data can be retrieved and used quickly and accurately. For example, in the FinTech scenario, insurance business involves data such as policy details and claims records. By converting this data from business forms into query statements, a structured database table is created to store this data and ensure data accessibility. However, there are large differences between business forms and query statements. The existing automatic conversion algorithm cannot learn the complex dependencies between business forms and query statements, resulting in reduced accuracy in query statement generation. Summary of the invention

[0003] The main purpose of the embodiments of the present application is to provide a query statement generation method and device, an electronic device and a storage medium, aiming to improve the accuracy of query statement generation.

[0004] To achieve the above object, a first aspect of an embodiment of the present application proposes a query statement generation method, the method comprising:

[0005] Obtaining target configuration items and selection order identifiers of the target configuration items;

[0006] Create a business form according to the target configuration item;

[0007] Parsing the business form to obtain a form object;

[0008] Convert the form object into a query structure;

[0009] The query structures are concatenated according to the selection sequence identifiers to obtain an initial query statement; wherein the initial query statement is a character string;

[0010] The initial query statement is updated to obtain a target query statement.

[0011] In some embodiments, obtaining the target configuration item includes:

[0012] Get historical configuration operations;

[0013] Performing configuration analysis on the historical configuration operations to obtain initial configuration items and item hit probabilities of the initial configuration items;

[0014] Combining the initial configuration items to obtain an initial template;

[0015] Determining a template hit probability of the initial template according to the item hit probability;

[0016] Performing template screening on the initial template according to the template hit probability to obtain a target template;

[0017] The initial configuration item is acquired according to the target template to obtain the target configuration item.

[0018] In some embodiments, updating the initial query statement to obtain a target query statement includes:

[0019] Performing intent recognition on the initial query statement to obtain the query intent;

[0020] Performing semantic analysis on the initial query statement to obtain a query semantic structure;

[0021] Generate a candidate query statement according to the query intent and the query semantic structure;

[0022] Performing grammar check on the candidate query statement to obtain the target query statement.

[0023] In some embodiments, performing syntax detection on the candidate query statement to obtain the target query statement includes:

[0024] Performing syntax analysis on the initial query statement by using a preset syntax analyzer to obtain a reference query statement;

[0025] Calculating similarity data between the reference query statement and the candidate query statement;

[0026] If the similarity data is greater than or equal to a preset similarity threshold, the candidate query statement is used as the target query statement.

[0027] In some embodiments, after the initial query statement is updated to obtain the target query statement, the following steps are included:

[0028] Obtaining a target execution strategy for the target query statement;

[0029] Predicting the execution period of the target execution strategy to obtain a target execution period;

[0030] During the target execution period, the target query statement is executed according to the target execution strategy.

[0031] In some embodiments, obtaining the target execution strategy of the target query statement includes:

[0032] Obtaining a statement execution strategy for the target query statement;

[0033] Performing cost prediction on the statement execution strategy to obtain cost prediction data;

[0034] The statement execution strategy is screened according to the cost prediction data to obtain the target execution strategy.

[0035] In some embodiments, performing cost prediction on the statement execution strategy to obtain cost prediction data includes:

[0036] Extracting features of the target query statement to obtain database access patterns and data query features;

[0037] Acquire a database index according to the database access mode and the data query characteristics;

[0038] Cost prediction is performed on the statement execution strategy according to the database index and the data query characteristics to obtain the cost prediction data.

[0039] To achieve the above-mentioned purpose, a second aspect of an embodiment of the present application provides a query statement generating device, the device comprising:

[0040] An acquisition module, used to acquire target configuration items and selection order identifiers of the target configuration items;

[0041] A creation module, used to create a business form according to the target configuration item;

[0042] A parsing module, used for parsing the business form to obtain a form object;

[0043] A conversion module, used for converting the form object into a query structure;

[0044] A concatenation module, used for concatenating the query structures according to the selected sequence identifiers to obtain an initial query statement; wherein the initial query statement is a character string;

[0045] The updating module is used to update the initial query statement to obtain a target query statement.

[0046] To achieve the above objectives, a third aspect of an embodiment of the present application proposes an electronic device, which includes a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the method described in the first aspect is implemented.

[0047] To achieve the above-mentioned purpose, the fourth aspect of an embodiment of the present application proposes a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method described in the first aspect is implemented.

[0048] The query statement generation method, query statement generation device, electronic device and storage medium proposed in the embodiment of the present application, by obtaining the target configuration item and the selection order identifier of the target configuration item, create a business form according to the target configuration item, can dynamically adjust the target configuration item according to business needs, quickly generate forms suitable for different business scenarios, and ensure the flexibility of business form creation. The business form is parsed to convert the business form into a programmable object model, and the physical structure of the business form is abstracted into a logical structure to obtain a form object. In order to convert the business form into a query statement, the form object is converted into a query structure to convert the form object into a format suitable for database query operations or data processing operations. The query statement has strict grammatical rules, and each element in the statement must appear in a specific order. In order to generate an accurate query statement, it is necessary to ensure the logical order of the query statement, and the query structure is spliced ​​according to the selection order identifier to obtain an initial query statement. In order to optimize the query performance of the initial query statement, the initial query statement is updated to optimize the initial query statement to obtain a target query statement, thereby improving the accuracy of query statement generation. BRIEF DESCRIPTION OF THE DRAWINGS

[0049] Figure 1 is a flowchart of a query statement generation method provided in an embodiment of the present application;

[0050] Figure 2 yes Figure 1 Flow chart of step S110 in FIG.

[0051] Figure 3 yes Figure 1 Flow chart of step S160 in FIG.

[0052] Figure 4 yes Figure 3 Flow chart of step S340 in FIG.

[0053] Figure 5 is another flow chart of the query statement generation method provided in an embodiment of the present application;

[0054] Figure 6 yes Figure 5 Flow chart of step S510 in FIG.

[0055] Figure 7 yes Figure 6 Flow chart of step S620 in FIG.

[0056] Figure 8 It is a structural diagram of a query statement generating device provided in an embodiment of the present application;

[0057] Fig. 9 It is a schematic diagram of the hardware structure of the electronic device provided in the embodiment of the present application. DETAILED DESCRIPTION

[0058] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0059] It should be noted that, although the functional modules are divided in the device schematic diagram and the logical order is shown in the flowchart, in some cases, the steps shown or described may be performed in a different order than the module division in the device or the order in the flowchart. The terms "first", "second", etc. in the specification, claims and the above drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence.

[0060] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of this application and are not intended to limit this application.

[0061] When storing data, query statements can be used to improve data accessibility and ensure that data can be retrieved and used quickly and accurately. For example, in the FinTech scenario, insurance business involves data such as policy details and claims records. By converting this data from business forms into query statements, a structured database table is created to store this data and ensure data accessibility. However, there are large differences between business forms and query statements. The existing automatic conversion algorithm cannot learn the complex dependencies between business forms and query statements, resulting in reduced accuracy in query statement generation.

[0062] Based on this, the embodiments of the present application provide a query statement generation method, a query statement generation device, an electronic device and a computer-readable storage medium, aiming to improve the accuracy of query statement generation.

[0063] The query statement generation method, query statement generation device, electronic device and computer-readable storage medium provided in the embodiments of the present application are specifically explained through the following embodiments. First, the query statement generation method in the embodiments of the present application is described.

[0064] The query statement generation method provided in the embodiment of the present application relates to the field of artificial intelligence technology. The query statement generation method provided in the embodiment of the present application can be applied to a terminal, can also be applied to a server side, and can also be software running in a terminal or a server side. In some embodiments, the terminal can be a smart phone, a tablet computer, a laptop computer, a desktop computer, etc.; the server side can be configured as an independent physical server, or a server cluster or distributed system composed of multiple physical servers, and can also be configured as a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms; the software can be an application that implements the query statement generation method, etc., but is not limited to the above forms.

[0065] The present application can be used in many general or special computer system environments or configurations. For example: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, distributed computing environments including any of the above systems or devices, etc. The present application can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. The present application can also be practiced in distributed computing environments, in which tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules can be located in local and remote computer storage media including storage devices.

[0066] It should be noted that in each specific implementation of the present application, when it comes to the need to perform relevant processing based on data related to user identity or characteristics such as user information, user behavior data, user historical data, and user location information, the user's permission or consent will be obtained first, and the collection, use, and processing of these data will comply with relevant laws, regulations, and standards. In addition, when the embodiment of the present application needs to obtain the user's sensitive personal information, the user's separate permission or consent will be obtained through a pop-up window or by jumping to a confirmation page. After clearly obtaining the user's separate permission or consent, the necessary user-related data for the normal operation of the embodiment of the present application will be obtained.

[0067] Figure 1 It is an optional flowchart of the query statement generation method provided in an embodiment of the present application. The query statement generation method may include but is not limited to steps S110 to S160.

[0068] Step S110, obtaining target configuration items and identification of the selection order of the target configuration items;

[0069] Step S120, creating a business form according to the target configuration item;

[0070] Step S130, parsing the business form to obtain a form object;

[0071] Step S140, converting the form object into a query structure;

[0072] Step S150, concatenating the query structure according to the selected sequence identifier to obtain an initial query statement; wherein the initial query statement is a character string;

[0073] Step S160: update the initial query statement to obtain a target query statement.

[0074] In steps S110 to S160 shown in the embodiment of the present application, the query structure is spliced ​​according to the selected order identifier, which can ensure the logical order and grammatical correctness of the query statement, obtain the initial query statement, and further improve the accuracy of query statement generation by updating the initial query statement.

[0075] The existing business system is relatively fixed in interface configuration and cannot meet the diverse analysis needs of users, such as business performance analysis, credit risk assessment, etc. In order to enhance the configuration flexibility and enable users to dynamically adjust the system interface configuration according to business needs, the embodiment of the present application provides more flexible and customizable configuration options. The target configuration item is a configuration option selected according to the current business scenario. Users can obtain the target configuration item through visual drag and drop, making the configuration process more intuitive and easy to use. The target configuration item includes template type, analysis template, configuration field, screening conditions, and aggregation method. Template type is a template category related to the business scenario, such as conversion migration class, customer group exploration class, solution exploration class, effect analysis class, etc. The analysis template can be automatically loaded according to the template type. The analysis template is a framework or structure for data analysis of business data. For example, the conversion migration class includes four analysis templates: observation customer group, initial dimension and observation indicator, measures and observation indicator, and subsequent observation dimension and indicator. The analysis template includes configuration fields, which are fields used for data analysis in the analysis template. If you click on the observation customer group analysis template, the line customer group list field will pop up, and you can select the customer group to be observed through the customer group list field. Click the beginning dimension and observation indicator analysis template, and the factor list field will pop up. You can select configuration fields such as observation dimensions and observation indicators through the factor list field. Each selected configuration field can be configured with filter conditions, which are used to limit the data range of the configuration field. For example, the fixed analysis time interval is between 20240101 and 20240131. The aggregation method can be determined according to the type of configuration field. The aggregation method is a method for summarizing and calculating business data. If the type of the configuration field is a number, the aggregation method can be sum, average, etc. If the type of the configuration field is text, the aggregation method is a classification indicator used to summarize business data, such as classifying customers according to the purchase amount. The configuration options allow users to adjust module types, analysis templates, configuration fields, filter conditions, and aggregation methods according to different business scenarios.

[0076] See also Figure 2 In some embodiments, step S110 may include but is not limited to steps S210 to S260:

[0077] Step S210, obtaining historical configuration operations;

[0078] Step S220, performing configuration analysis on historical configuration operations to obtain initial configuration items and item hit probabilities of the initial configuration items;

[0079] Step S230, combining the initial configuration items to obtain an initial template;

[0080] Step S240, determining the template hit probability of the initial template according to the item hit probability;

[0081] Step S250, screening the initial template according to the template hit probability to obtain a target template;

[0082] Step S260, obtaining initial configuration items according to the target template to obtain target configuration items.

[0083] In step S210 of some embodiments, the business system records the configuration operation log, obtains the configuration options selected by the user in the business system interface during the historical period from the configuration operation log, and obtains the historical configuration operation. The historical configuration operation may change with business needs. In the insurance claim scenario, the historical configuration operation may be a configuration option related to the claim business, such as the claim process, claim rules, loss details, etc. In the insurance product recommendation scenario, the historical configuration operation may be a configuration option related to the product recommendation business, such as a recommendation engine, recommendation rules, recommendation page display, etc.

[0084] In step S220 of some embodiments, configuration options are intelligently recommended to users based on historical configuration operations to improve user efficiency and satisfaction. In order to improve the accuracy of configuration option recommendations, a first recommendation model and a second recommendation model are obtained, and the first recommendation model and the second recommendation model are different models, such as the first recommendation model is a random forest and the second recommendation model is a Bayesian model. The historical configuration operations are input into the first recommendation model for configuration analysis to obtain the configuration item category and the first hit probability of the configuration item category. The historical configuration operations are input into the second recommendation model for configuration analysis to obtain the configuration item category and the second hit probability of the configuration item category. The first hit probability and the second hit probability are weighted averaged to obtain the weighted hit probability of the configuration item category, so as to combine the model advantages of different recommendation models and provide more comprehensive and personalized configuration options. The configuration item category is used as the initial configuration item, and the weighted hit probability of the configuration item category is used as the item hit probability. The item hit probability is the probability that the initial configuration item is selected.

[0085] Alternatively, obtain a test configuration data set, the test configuration data set includes historical configuration samples and recommended configuration labels, perform configuration analysis on the historical configuration samples through a first recommendation model, and obtain a first prediction configuration item and a first prediction hit probability of the first prediction configuration item. Sort the first prediction configuration items from large to small according to the first prediction hit probability, and select the first N first prediction configuration items to generate a first recommendation list. Select the number of first prediction configuration items in the first recommendation list that have the same recommended configuration label to obtain a first number. Divide the first number by the total number of first preset configuration items in the first recommendation list to obtain a first accuracy rate.

[0086] The second recommendation model is used to perform configuration analysis on the historical configuration samples to obtain the second predicted configuration item and the second predicted hit probability of the second predicted configuration item. The second predicted configuration items are sorted from large to small according to the second predicted hit probability, and the first N second predicted configuration items are selected to generate a second recommendation list. The number of second predicted configuration items with the same recommended configuration label in the second recommendation list is selected to obtain the second number. The second number is divided by the total number of second preset configuration items in the second recommendation list to obtain the second accuracy rate.

[0087] In order to obtain an accurate initial recommendation list, if the first accuracy is greater than or equal to the second accuracy, the first recommendation model is used as the basic model and the second recommendation model is used as the upper model. If the first accuracy is less than the second accuracy, the first recommendation model is used as the upper model and the second recommendation model is used as the basic model.

[0088] The basic model is used to perform configuration analysis on historical configuration operations to obtain an initial recommendation list. The upper-level model is used to perform configuration analysis on historical configuration operations and the initial recommendation list to filter the initial recommendation list, obtain initial configuration items and item hit probabilities of initial configuration items, and provide users with more accurate configuration item recommendation services.

[0089] In step S230 of some embodiments, the template is a set of configuration options used to perform the business task, and the template is composed of specific configuration options. For example, template A includes configuration options 1, configuration option 2, configuration option 3, and configuration option 5, and template B includes configuration option 2 and configuration option 4. The initial configuration items are combined according to the preset template combination rule to obtain the initial template.

[0090] In step S240 of some embodiments, the item hit probabilities of each initial configuration item in the initial template are added together to obtain the template hit probability. The template hit probability is the probability that the user selects the initial template. The greater the template hit probability, the greater the probability that the user uses the initial template.

[0091] In step S250 of some embodiments, the initial template with the highest template hit probability is selected as the target template. For example, if the template hit probability of template A is 100% and the template hit probability of template B is 50%, then template A is selected as the target template.

[0092] In step S260 of some embodiments, the initial configuration item in the target template is used as the target configuration item.

[0093] Through the above steps S210 to S260, intelligent recommendation of configuration options can be achieved to guide the user's configuration operation and improve the user's usage efficiency and satisfaction.

[0094] In step S120 of some embodiments, the target configuration item determines the structure and content of the business form. Create a form template, which defines the basic structure and style of the form. Call the template engine or form builder to create form components such as input boxes, selection controls, etc. according to the form template and the target configuration item to obtain a business form. The format of the business form can be json format. Through the target configuration item, forms can be dynamically created and managed without manually writing code for each form to adapt to different business scenarios.

[0095] In step S130 of some embodiments, the business form is preprocessed to remove irrelevant content in the business form, such as headers, footers, watermarks, etc., to ensure that the business form contains only form-related data. The format of the business form is obtained, and a parsing tool that can parse the format form is selected according to the format. If the format of the business form is html format, the business form can be parsed using python libraries, java libraries, etc. If the format of the business form is json format, the business form is parsed using a json parser. The form structure of the business form is parsed by a parsing tool, the form components of the business form are identified, and the field names and field attributes of the form components are extracted. The field attributes include data types, default values, validation rules, etc. A form object is created based on the field name and field attributes. The form object can be represented by a class or structure in a programming language. If the business form is an insurance claim form, the field name can be a claim number, claim amount, claim date, policyholder name, etc.

[0096] In step S140 of some embodiments, data validation is performed on the form object, such as checking required fields, data format and range, etc., to ensure the validity of the form object. In order to convert the business form into a query statement that complies with the Structured Query Language (SQL) coding standard, after the data validation is passed, the query builder can be used to map the field names in the form object to the actual fields in the database, generate a basic SQL structure based on the mapping result, generate a subquery based on the field attributes in the form object, and apply the subquery to the basic SQL structure to convert the form object into a data structure suitable for database query to obtain a query structure. Field attributes include screening conditions, aggregate functions, etc. The screening conditions are used to screen the business dimension items indicated by the field name. The business dimension items can be time dimension items, geographic dimension items, product dimension items, etc. The screening conditions can be flattened by business dimensions to obtain subqueries. The aggregate function is the aggregation method of the business dimension items indicated by the field name, and the aggregate function can be converted into a function to obtain a subquery.

[0097] For example, if the business form is an order query form, perform object parsing on the business form to obtain field names and field attributes. The field names can be orders and sales, the field attributes of orders can be order time range, and the field attributes of sales can be sales greater than 1000. Determine whether the object field exists in the database. If the judgment result is yes, map the field name to the actual field of the database. For example, map orders to the order table and map sales to total_sales. Generate a basic SQL structure based on the mapping results, flatten the business dimensions for order time range and sales greater than 1000, and generate subqueries for order time range and sales. Apply these two subqueries to the basic SQL structure to obtain the query structure.

[0098] In step S150 of some embodiments, the selection order identifier of the target configuration items can reflect the business logic order. In order to improve the readability of the query statement, the query structures are sequentially spliced ​​according to the selection order identifier to establish the dependency relationship between the target configuration items, and the spliced ​​query structures are converted into query statements to obtain the initial query statement, which can automatically generate queries without understanding the specific SQL syntax. The initial query statement is a string expressed using the SQL language.

[0099] Configuration items contain complex logic and dependencies, and there are significant differences between configuration items and SQL syntax. Using only the query structure cannot capture the user intent contained in the configuration items, resulting in the initial query statement not meeting user expectations. In order to improve the accuracy of SQL conversion, the initial query statement is updated to obtain the target query statement.

[0100] See also Figure 3 In some embodiments, step S160 may include but is not limited to steps S310 to S340:

[0101] Step S310, performing intent recognition on the initial query statement to obtain the query intent;

[0102] Step S320, semantically analyzing the initial query statement to obtain a query semantic structure;

[0103] Step S330, generating a candidate query statement according to the query intent and the query semantic structure;

[0104] Step S340: Perform syntax check on the candidate query statement to obtain a target query statement.

[0105] In step S310 of some embodiments, the business system provides a variety of services, such as loans, credit cards, investments, savings accounts, etc. Each service has specific rules and processes, which determine the settings of service configuration items. There are differences in the configuration items of each service, which increases the complexity of the business form, thereby increasing the complexity of the SQL statement. In order to generate accurate SQL statements, the embodiments of the present application introduce deep learning technology to enhance the flexibility and intelligence of SQL parsing and SQL generation, so as to accurately capture the complex dependencies between business forms and SQL statements and understand the user's query intent.

[0106] The initial query sentence is input into the convolutional neural network for feature extraction to obtain sentence features. Sentence features include positive emotions or negative emotions. Positive emotions are positive, optimistic, satisfied or positive emotions and attitudes, and negative emotions are negative, pessimistic or negative emotions and attitudes. The convolutional neural network includes an input layer, a convolution layer, a pooling layer, a fully connected layer and a softmax layer. The initial query sentence is vectorized through the input layer to obtain an initial query feature vector. The convolution layer includes three 2×2, 3×3 and 4×4 convolution kernels and an activation function. The activation function can be a ReLU function. The initial query feature vector is convolved by a 2×2 convolution kernel, a 3×3 convolution kernel and a 4×4 convolution kernel to obtain a first feature map, a second feature map and a third feature map. The first feature map, the second feature map and the third feature map are nonlinearly transformed by the activation function to obtain a first feature vector, a second feature vector and a third feature vector. The maximum values ​​of the first feature vector, the second feature vector, and the third feature vector are extracted through the pooling layer to obtain the first pooling feature, the second pooling feature, and the third pooling feature. The first pooling feature, the second pooling feature, and the third pooling feature are connected through the fully connected layer to obtain the target feature vector, and the target feature vector is classified through the softmax layer to obtain the sentence feature.

[0107] In order to avoid malicious queries from attacking the business system, if the sentence feature is positive sentiment, the intent recognition model is used to identify the intent of the initial query sentence to obtain the query intent. The query intent is used to indicate the intent category of various operations or queries that the user may express, such as querying account balances, redeeming investments, etc. The intent recognition model can be a recurrent neural network, a long short-term memory network, and a Transformer model. The intent recognition model can understand the semantics of the initial query sentence, capture the structure and context information of the initial query sentence, and thus understand the query intent more accurately. If the sentence feature is negative sentiment, a prompt message is generated. The prompt message is used to prompt the user that the query cannot be generated.

[0108] In step S320 of some embodiments, during the underwriting process, the insurance company needs to query medical data, industry insurance behavior data, credit score data, etc., which may involve multi-table queries, merge queries, etc., which may cause the business form to involve multiple tables, multi-condition screening and aggregation operations, etc., resulting in a complex structure of the business form. In order to correctly understand the complex structure of the business form and support complex queries, it is necessary to perform semantic analysis on the initial query statement. Specifically, the initial query statement is word segmented to obtain the query field. The query field is analyzed by a dependency syntax analysis tool to obtain a dependency syntax tree, which is used to indicate the dependency relationship between the query fields. According to the dependency syntax tree, the initial query statement is annotated with semantic roles to obtain semantic roles, which include entities and actions. The entity can be a table name, a column name, etc., and the action can be insert, delete, select or update, etc. An abstract syntax tree is constructed according to the dependency syntax tree and the semantic role to obtain a query semantic structure. The query semantic structure is used to indicate the logical structure of the query. In the query semantic structure, each node represents a query component, and the query component can be a SELECT clause, a FROM clause, etc.

[0109] In step S330 of some embodiments, the business system will face diverse query requests from users, such as credit card bill inquiries, insurance product recommendations, insurance claims applications, etc. In order to improve the response accuracy of diverse query requests, the query intent and query semantic structure are spliced ​​and input into a sequence-to-sequence model (Sequence-to-Sequence, Seq2Seq) based on deep learning. The sequence-to-sequence model is used to capture the key information in the query intent and query semantic structure and the dependencies between them, and learn the mapping relationship between the query intent and query semantic structure to the query statement, so that the business system can fully understand the user's diverse query intent, thereby accurately converting the business form into a query statement to obtain a candidate query statement. The Seq2Seq model usually includes an encoder and a decoder, the encoder is used to understand the input query intent and query semantic structure, and the decoder is used to generate a query statement. The sequence-to-sequence model is trained by a large amount of paired data of natural language queries and query statements, and the model can learn the mapping relationship from natural language to query statements.

[0110] In step S340 of some embodiments, in order to improve the accuracy of SQL statement generation and query efficiency, the candidate query statement is syntax checked to avoid syntax errors or logic errors in the SQL statement, and a target query statement is obtained. The target query statement is an SQL statement corresponding to the business form.

[0111] Through the above steps S310 to S340, the context information can be used to understand the implicit relationships and constraints in the query, so as to accurately understand the complex query intentions, accurately convert the business form into a query statement, and improve the accuracy of query statement conversion.

[0112] See also Figure 4 In some embodiments, step S340 may include but is not limited to steps S410 to S430:

[0113] Step S410, parsing the initial query statement using a preset parser to obtain a reference query statement;

[0114] Step S420, calculating similarity data between the reference query statement and the candidate query statement;

[0115] Step S430: If the similarity data is greater than or equal to a preset similarity threshold, the candidate query statement is used as a target query statement.

[0116] In step S410 of some embodiments, the initial query statement is input into a syntax parser, and the syntax parser performs syntax parsing on the initial query statement to obtain a reference query statement. The syntax parser is a Hive SQL syntax parser, and the reference query statement is an SQL statement corresponding to the business form.

[0117] In step S420 of some embodiments, the reference query statement is vectorized to obtain a first vector. The candidate query statement is vectorized to obtain a second vector. The Euclidean distance between the first vector and the second vector is calculated, and the reciprocal of the Euclidean distance is used as the similarity data. It should be noted that the larger the Euclidean distance, the smaller the similarity data, and the greater the degree of difference between the reference query statement and the candidate query statement.

[0118] In step S430 of some embodiments, if the similarity data is greater than or equal to a preset similarity threshold, it means that the reference query statement and the candidate query statement are relatively similar, and the candidate query statement is used as the target query statement. If the similarity data is less than the preset similarity threshold, the candidate query statement is regenerated, and the number of times the candidate query statement is regenerated is obtained. If the number of times the candidate query statement is regenerated reaches the upper limit, the candidate query statement generated last is used as the target query statement.

[0119] In addition, detailed error information and logging functions can be provided to help users quickly locate and solve problems. At the same time, debugging tools or interfaces are developed to allow users to view and modify automatically generated SQL statements for debugging and optimization.

[0120] Through the above steps S410 to S430, the candidate query statements can be syntax checked to ensure the accuracy of query statement generation.

[0121] When the form configuration is very complex or the amount of data is very large, SQL conversion may take a long time, and may even time out or fail, affecting the user experience and the efficiency of data analysis. In response to the needs of large-scale data processing and analysis, the embodiment of the present application adopts a distributed computing framework and parallel processing technology to improve the performance of SQL conversion. In addition, caching mechanisms, asynchronous processing and other technologies are introduced to reduce processing time and improve user experience. Specifically, when a user repeatedly analyzes a certain business scenario, that is, repeatedly converts the same business form into SQL, the target query statement corresponding to the business form and the data query result of executing the target query statement can be cached locally using the caching mechanism, and the data query result is directly taken out from the local cache and returned to the user, reducing the pressure on the system and the computing engine. The process of asynchronous processing is as follows: an offline batch job is created by using the synchronous interface as a parameter, and the scheduler of the batch platform pulls up an instance of the offline batch job. After the instance batch is completed, a dependent job is scheduled to transmit the data query result obtained by the instance batch to the application system, and the application system stores the data query result and displays it to the user for download.

[0122] See also Figure 5 In some embodiments, after step S160, the query statement generation method may include but is not limited to steps S510 to S530:

[0123] Step S510, obtaining a target execution strategy for a target query statement;

[0124] Step S520, predicting the execution period of the target execution strategy to obtain the target execution period;

[0125] Step S530: Execute the target query statement according to the target execution strategy during the target execution period.

[0126] In step S510 of some embodiments, in order to improve query efficiency and ensure that the target query statement can be executed efficiently and accurately so as to return the query results in time, a target execution strategy for the target query statement is obtained. The target execution strategy is the detailed steps and operation sequence for the database management system to execute the target query statement, which can be generated by the query optimizer. The execution strategy is the execution plan, including full table scan, index scan, view merge, etc.

[0127] In step S520 of some embodiments, different business services have different requirements for response time. For example, services such as insurance policy inquiry and claims processing require quick responses to user query requests, while system upgrade services, data storage services, etc. do not require quick responses to query requests. In order to ensure that the response time of different query requests is within a time range acceptable to users, execution period prediction is required to provide a smooth customer experience. Specifically, the target execution strategy is input into the execution period prediction model for execution period prediction to capture the relationship between factors such as query complexity, query data volume, system load, and the execution period, and obtain the target execution period of the target execution strategy. The target execution period is the time period over which the target execution strategy is executed. The execution period prediction model can be a time series prediction model, a random forest, a long short-term memory network, or the like.

[0128] In step S530 of some embodiments, during the target execution period, the target query statement is executed according to the target execution strategy to obtain a data query result corresponding to the target query statement.

[0129] Through the above steps S510 to S530, an effective execution strategy can be selected to execute query statements in a suitable execution period, so that query statements with higher timeliness requirements can be executed first, thereby improving the efficiency of query statement execution.

[0130] See also Figure 6 In some embodiments, step S510 may include but is not limited to steps S610 to S630:

[0131] Step S610, obtaining a statement execution strategy of a target query statement;

[0132] Step S620, performing cost prediction on the statement execution strategy to obtain cost prediction data;

[0133] Step S630, screening the statement execution strategy according to the cost prediction data to obtain the target execution strategy.

[0134] In step S610 of some embodiments, the query optimizer of the database management system generates multiple possible execution strategies for a given query statement, and the query optimizer generates an execution strategy for the target query statement to obtain a statement execution strategy.

[0135] In step S620 of some embodiments, a good execution strategy can significantly reduce query time and improve resource utilization. During business peak hours, the business volume of claims services, policy services, etc. increases rapidly. In order to adapt to business peak demands, it is necessary to optimize the statement execution strategy. The embodiment of the present application uses a cost prediction model to perform cost prediction on the statement execution strategy to evaluate the execution cost of different statement execution strategies and obtain cost prediction data. The cost prediction model can be a recursive long short-term memory network, a BERT model, etc. The cost prediction data is used to reflect the execution performance of the statement execution strategy, which can be the execution time of executing the target query statement using the statement execution strategy, the storage space capacity occupied, etc.

[0136] In step S630 of some embodiments, in order to select the most effective execution strategy and optimize query performance, it is necessary to screen the statement execution strategies, and the statement execution strategy with the smallest cost prediction data, such as the shortest execution time, can be selected as the target execution strategy.

[0137] Through the above steps S610 to S630, the optimal execution strategy can be obtained to efficiently execute the target query statement and improve the query efficiency. For business services with high timeliness requirements such as insurance policy services, the query results can be fed back to users in a timely manner, thereby improving the quality of business services.

[0138] See also Figure 7 In some embodiments, step S620 may include but is not limited to steps S710 to S730:

[0139] Step S710, extracting features from the target query statement to obtain database access patterns and data query features;

[0140] Step S720, obtaining a database index according to a database access mode and data query characteristics;

[0141] Step S730, performing cost prediction on the statement execution strategy according to the database index and data query characteristics to obtain cost prediction data.

[0142] In step S710 of some embodiments, the target query statement is parsed, and the target query statement is converted into a structured syntax tree form to obtain a query syntax tree. Statistical features are extracted from the query syntax tree to obtain statistical features, and the statistical features include the frequency of keywords such as SELECT, function, table name and column name appearing in the target query statement. Structural features are extracted from the query syntax tree to obtain structural features, and the structural features are used to indicate the query structure of the target query statement, such as nested queries, JOIN types, subqueries, etc. The statistical features and structural features are used as database access modes. Semantic features are extracted from the query syntax tree through a word embedding model such as Word2Vec to obtain data query features. The database access mode is the tables, fields and the relationships between them involved in the target query statement. Data query features include filter conditions, aggregate functions, sorting requirements, etc. used in the query.

[0143] In step S720 of some embodiments, index is the key to improving query performance, but the selection and management of index requires professional knowledge. In order to realize automatic index management, the database access mode and data query characteristics are input into the index recommendation model to predict the table name, column name and index type, and the database index is created according to the index type, table name and column name. The execution cost of the execution strategy is reduced through the database index. Index types include single column index, composite index, covering index, unique index, etc. The index recommendation model can be a long short-term memory network.

[0144] In step S730 of some embodiments, the database index and the data query feature are spliced ​​and input into the cost prediction model to perform cost prediction to obtain cost prediction data. Alternatively, the database access mode and the data query feature are spliced ​​and input into the cost prediction model to perform cost prediction to obtain cost prediction data.

[0145] The above steps S710 to S730 can obtain cost prediction data, so as to select the best execution strategy by using the cost prediction data to optimize the query performance.

[0146] See also Figure 8 The embodiment of the present application further provides a query statement generating device, which can implement the above query statement generating method, and the query statement generating device includes:

[0147] An acquisition module 810 is used to acquire a target configuration item and a selection order identifier of the target configuration item;

[0148] A creation module 820, configured to create a business form according to the target configuration item;

[0149] The parsing module 830 is used to parse the business form to obtain a form object;

[0150] A conversion module 840, used to convert the form object into a query structure;

[0151] A concatenation module 850 is used to concatenate the query structure according to the selected sequence identifier to obtain an initial query statement; wherein the initial query statement is a character string;

[0152] The updating module 860 is used to update the initial query statement to obtain a target query statement. The specific implementation of the query statement generating device is basically the same as the specific implementation of the query statement generating method described above, and will not be described in detail here.

[0153] The embodiment of the present application also provides an electronic device, the electronic device includes a memory and a processor, the memory stores a computer program, and the processor implements the above query statement generation method when executing the computer program. The electronic device can be any intelligent terminal including a tablet computer, a car computer, etc.

[0154] See also Fig. 9 , Fig. 9 The hardware structure of an electronic device of another embodiment is illustrated, and the electronic device includes:

[0155] The processor 910 may be implemented by a general-purpose central processing unit (CPU), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of the present application;

[0156] The memory 920 can be implemented in the form of a read-only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM). The memory 920 can store an operating system and other application programs. When the technical solution provided in the embodiment of this specification is implemented by software or firmware, the relevant program code is stored in the memory 920, and the processor 910 calls and executes the query statement generation method of the embodiment of this application;

[0157] Input / output interface 930, used to implement information input and output;

[0158] Communication interface 940, used to realize communication interaction between the device and other devices, which can be realized through wired mode (such as USB, network cable, etc.) or wireless mode (such as mobile network, WIFI, Bluetooth, etc.);

[0159] bus 950 , which transmits information between the various components of the device (e.g., processor 910 , memory 920 , input / output interface 930 , and communication interface 940 );

[0160] The processor 910 , the memory 920 , the input / output interface 930 , and the communication interface 940 are connected to each other in communication within the device via a bus 950 .

[0161] An embodiment of the present application further provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the above-mentioned query statement generation method is implemented.

[0162] The memory, as a non-transient computer-readable storage medium, can be used to store non-transient software programs and non-transient computer executable programs. In addition, the memory may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some embodiments, the memory may optionally include a memory remotely disposed relative to the processor, and these remote memories may be connected to the processor via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0163] The query statement generation method, query statement generation device, electronic device and computer storage medium provided in the embodiments of the present application can ensure the logical order and grammatical correctness of the query statement by splicing the query structure according to the selection order identifier, obtain the initial query statement, and further improve the accuracy of query statement generation by updating the initial query statement.

[0164] The embodiments described in the embodiments of the present application are intended to more clearly illustrate the technical solutions of the embodiments of the present application and do not constitute a limitation on the technical solutions provided in the embodiments of the present application. Those skilled in the art will appreciate that with the evolution of technology and the emergence of new application scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.

[0165] Those skilled in the art will appreciate that the technical solutions shown in the figures do not constitute a limitation on the embodiments of the present application, and may include more or fewer steps than shown in the figures, or a combination of certain steps, or different steps.

[0166] The device embodiments described above are merely illustrative, and the units described as separate components may or may not be physically separated, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0167] Those skilled in the art will appreciate that all or some of the steps in the methods disclosed above, and the functional modules / units in the systems and devices may be implemented as software, firmware, hardware, or a suitable combination thereof.

[0168] The terms "first", "second", "third", "fourth", etc. (if any) in the specification of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0169] It should be understood that in the present application, "at least one (item)" means one or more, and "plurality" means two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the objects associated before and after are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.

[0170] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the above units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0171] The units described above as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0172] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0173] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including multiple instructions to enable a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, referred to as ROM), random access memory (Random Access Memory, referred to as RAM), disk or optical disk and other media that can store programs.

[0174] The preferred embodiments of the present invention are described above with reference to the accompanying drawings, but the scope of the rights of the present invention is not limited thereto. Any modification, equivalent substitution and improvement made by a person skilled in the art without departing from the scope and essence of the present invention should be within the scope of the rights of the present invention.

Claims

1. A query statement generation method, characterized in that: The method comprises: Obtaining target configuration items and selection order identifiers of the target configuration items; Create a business form according to the target configuration item; Parsing the business form to obtain a form object; Convert the form object into a query structure; The query structures are concatenated according to the selection sequence identifiers to obtain an initial query statement; wherein the initial query statement is a character string; The initial query statement is updated to obtain a target query statement.

2. The method according to claim 1, characterized in that The obtaining of the target configuration item includes: Get historical configuration operations; Performing configuration analysis on the historical configuration operations to obtain initial configuration items and item hit probabilities of the initial configuration items; Combining the initial configuration items to obtain an initial template; Determining a template hit probability of the initial template according to the item hit probability; Performing template screening on the initial template according to the template hit probability to obtain a target template; The initial configuration item is acquired according to the target template to obtain the target configuration item.

3. The method according to claim 1, characterized in that The updating of the initial query statement to obtain a target query statement includes: Performing intent recognition on the initial query statement to obtain the query intent; Performing semantic analysis on the initial query statement to obtain a query semantic structure; Generate a candidate query statement according to the query intent and the query semantic structure; Performing grammar check on the candidate query statement to obtain the target query statement.

4. The method according to claim 2, characterized in that: The performing grammar detection on the candidate query statement to obtain the target query statement includes: Performing syntax analysis on the initial query statement by using a preset syntax analyzer to obtain a reference query statement; Calculating similarity data between the reference query statement and the candidate query statement; If the similarity data is greater than or equal to a preset similarity threshold, the candidate query statement is used as the target query statement.

5. The method according to any one of claims 1 to 4, characterized in that: After the initial query statement is updated to obtain the target query statement, the method includes: Obtaining a target execution strategy for the target query statement; Predicting the execution period of the target execution strategy to obtain a target execution period; During the target execution period, the target query statement is executed according to the target execution strategy.

6. The method according to claim 5, characterized in that The step of obtaining the target execution strategy of the target query statement includes: Obtaining a statement execution strategy for the target query statement; Performing cost prediction on the statement execution strategy to obtain cost prediction data; The statement execution strategy is screened according to the cost prediction data to obtain the target execution strategy.

7. The method according to claim 6, characterized in that The performing cost prediction on the statement execution strategy to obtain cost prediction data includes: Extracting features of the target query statement to obtain database access patterns and data query features; Acquire a database index according to the database access mode and the data query characteristics; Cost prediction is performed on the statement execution strategy according to the database index and the data query characteristics to obtain the cost prediction data.

8. A query statement generating device, characterized in that: The device comprises: An acquisition module, used to acquire target configuration items and selection order identifiers of the target configuration items; A creation module, used to create a business form according to the target configuration item; A parsing module, used for parsing the business form to obtain a form object; A conversion module, used for converting the form object into a query structure; A concatenation module, used for concatenating the query structures according to the selected sequence identifiers to obtain an initial query statement; wherein the initial query statement is a character string; The updating module is used to update the initial query statement to obtain a target query statement.

9. An electronic device, characterized in that: The electronic device comprises a memory and a processor, the memory stores a computer program, and the processor implements the method according to any one of claims 1 to 7 when executing the computer program.

10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.

Citation Information

Cited By

  • Database index recommendation method and device based on query intention recognition and medium

    CN120929464A

  • SQL (Structured Query Language) statement similarity detection method, model training method and electronic equipment

    CN121387928A