Query language generation method and system, and electronic device and storage medium
By utilizing an indicator library and processing engine to generate SQL data, the accuracy and security issues of large models when generating SQL data are resolved, achieving highly accurate data analysis and database security assurance.
Patent Information
- Application Number
- PCT/CN2025/095842
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2024-06-04
- Filing Date
- 2025-05-19
- Publication Date
- 2025-12-11
AI Technical Summary
When large models generate structured query language (SQL) data, the natural language input by users is complex and variable, making it difficult to guarantee accuracy. At the same time, there is a risk of leakage of database metadata, which reduces the security of the database stored data.
By obtaining the names of multiple preset analysis indicators from a pre-generated indicator library, a large model is used to identify the target analysis indicators in natural language data, and a processing engine is used to generate SQL data based on the calculation logic of the indicator library, thus avoiding the direct acquisition of database metadata.
It improves the accuracy of SQL data generation, ensures the reliability of data analysis results, mitigates the risk of database metadata leakage, and enhances data storage security.
Smart Images

Figure CN2025095842_11122025_PF_FP_ABST
Abstract
Description
Query language generation method and system, electronic device and storage medium
[0001] The present application claims priority to the Chinese patent application No. 202410718435.3, filed on June 4, 2024, and entitled "Query language generation method and system, electronic device and storage medium", the content of which is incorporated herein by reference in its entirety. TECHNICAL FIELD
[0002] The present application relates to the technical field of computer, and in particular to a query language generation method and system, an electronic device and a storage medium. BACKGROUND
[0003] With the development of technology, large models have emerged. A large model refers to a machine learning model with large-scale parameters and complex computing structure. Generally, when data analysis is performed using a large model, the large model can obtain meta information of a related database, generate structured query language (SQL) data according to natural language input by a user and the meta information of the database, but the natural language input by the user is complex and variable, making it difficult to guarantee the accuracy of the SQL data generated by the large model. In addition, providing the meta information of the database to the large model poses a risk of leakage of key information of the database, reducing the security of the data stored in the database. SUMMARY
[0004] The embodiments of the present disclosure provide a query language generation method and system, an electronic device and a storage medium, which can improve the accuracy of generated SQL data.
[0005] In a first aspect, the embodiments of the present disclosure provide an electronic device, comprising a processor, a memory and a bus, the memory stores machine readable instructions executable by the processor, when the electronic device is running, the processor and the memory communicate through the bus, the machine readable instructions are executed by the processor to execute a query language generation process, the query language generation process comprises:
[0006] obtaining natural language data input by a user to a large model, and obtaining index names of a plurality of preset analysis indexes in a pre-generated index library; wherein the index library is generated based on an original database;
[0007] using the large model to identify the natural language data based on the index names of the plurality of preset analysis indexes, and determining at least one target analysis index included in the natural language data;
[0008] The processing engine generates structured query language (SQL) data corresponding to the natural language data according to a calculation logic of the target analysis indicator included in the indicator library, where the SQL data is used to query data from the original database.
[0009] In a possible implementation, in the query language generation process performed by the processor, before the large model is used to identify the natural language data based on the indicator names of the plurality of preset analysis indicators, the process further includes:
[0010] The matching degree between the preset analysis indicators and the natural language data is determined by using at least one matching algorithm.
[0011] The candidate analysis indicators are selected from the plurality of preset analysis indicators according to the matching degrees between the respective preset analysis indicators and the natural language data.
[0012] The large model is used to identify the natural language data based on the indicator names of the candidate analysis indicators, to determine at least one target analysis indicator included in the natural language data.
[0013] The large model is used to identify the natural language data based on the indicator names of the candidate analysis indicators, to determine at least one target analysis indicator included in the natural language data.
[0014] In a possible implementation, in the query language generation process performed by the processor, the process further includes:
[0015] The large model extracts a structure parameter from the natural language data, where the structure parameter includes at least one of a dimension parameter, a filtering condition parameter, and a sorting parameter.
[0016] The processing engine generates SQL data corresponding to the natural language data according to a calculation logic of the target analysis indicator included in the indicator library and the structure parameter.
[0017] The processing engine generates SQL data corresponding to the natural language data according to a calculation logic of the target analysis indicator included in the indicator library and the structure parameter.
[0018] In a possible implementation, in the query language generation process performed by the processor, when the structure parameter includes a dimension parameter, a filtering condition parameter, and a sorting parameter, the processing engine generates SQL data corresponding to the natural language data according to a calculation logic of the target analysis indicator included in the indicator library and the structure parameter.
[0019] generate, by using the processing engine, a virtual table of the target analysis indicator according to a calculation logic of the target analysis indicator;
[0020] generate, by using the processing engine, a virtual table of the dimension parameter;
[0021] generate, by using the virtual table of the at least one target analysis indicator, the virtual table of the dimension parameter, the filtering condition parameter and the sorting parameter, SQL data corresponding to the natural language data.
[0022] In a possible implementation, in the query language generation process performed by the processor, when the structure parameter comprises a dimension parameter, the process further comprises:
[0023] verify, by using the processing engine, the at least one target analysis indicator and the dimension parameter based on a list of indicators and a list of dimensions included in the indicator library, to obtain a verification result;
[0024] The generating, by using the processing engine, the SQL data corresponding to the natural language data according to the calculation logic of the target analysis indicator included in the indicator library and the structure parameter comprises:
[0025] When the verification result indicates that the indicator and the dimension exist, generating, by using the processing engine, the SQL data corresponding to the natural language data according to the calculation logic of the target analysis indicator included in the indicator library and the structure parameter.
[0026] In a possible implementation, in the query language generation process performed by the processor, the process further comprises:
[0027] adjusting the structure parameter based on a preset structure form to generate an adjusted structure parameter, wherein the adjusted structure parameter is used to generate the SQL data.
[0028] In a possible implementation, in the query language generation process performed by the processor, the process further comprises:
[0029] adjusting the SQL data corresponding to the natural language data to obtain adjusted SQL data, wherein the adjusting process comprises at least one of the following:
[0030] adding a limit statement;
[0031] merging the same subquery;
[0032] adjusting the filtering condition into a query of a virtual table;
[0033] merging the same filtering condition;
[0034] The formatting process is performed according to a preset reference format.
[0035] In a possible implementation, in the query language generation process performed by the processor, the process further includes:
[0036] In response to the triggered index management operation, an index management interface is displayed.
[0037] Index data of an updated analysis index input in the index management interface is received, and the index data of the updated analysis index is stored in an index library, where the index data includes an index name and calculation logic.
[0038] In a possible implementation, in the query language generation process performed by the processor, the process further includes:
[0039] Various index types suitable for various business scenarios are determined.
[0040] At least one preset analysis index under each index type is determined according to the various index types and data types stored in the original database.
[0041] The index library is generated based on the preset analysis index under each index type.
[0042] In a second aspect, the present disclosure provides a query language generation method, including:
[0043] Natural language data input by a user to a large model is obtained, and index names of a plurality of preset analysis indexes in a pre-generated index library are obtained; the index library is generated based on an original database;
[0044] The large model is used to identify the natural language data based on the index names of the plurality of preset analysis indexes, to determine at least one target analysis index included in the natural language data.
[0045] A processing engine is used to generate structured query language (SQL) data corresponding to the natural language data according to calculation logic of the target analysis index included in the index library, where the SQL data is used to query data from the original database.
[0046] In a possible implementation, before the large model is used to identify the natural language data based on the index names of the plurality of preset analysis indexes, the process further includes:
[0047] At least one matching algorithm is used to determine a matching degree between the preset analysis index and the natural language data.
[0048] According to matching degrees between each preset analysis indicator and the natural language data, a candidate analysis indicator is selected from the plurality of preset analysis indicators;
[0049] The using the large model to identify the natural language data based on an indicator name of the plurality of preset analysis indicators to determine at least one target analysis indicator included in the natural language data includes:
[0050] The using the large model to identify the natural language data based on an indicator name of the candidate analysis indicator to determine at least one target analysis indicator included in the natural language data.
[0051] In a possible implementation, the method further includes:
[0052] The using the large model to extract a structure parameter from the natural language data, the structure parameter including at least one of a dimension parameter, a filtering condition parameter, and a sorting parameter;
[0053] The using the processing engine to generate structured query language (SQL) data corresponding to the natural language data according to the calculation logic of the target analysis indicator included in the indicator library includes:
[0054] The using the processing engine to generate SQL data corresponding to the natural language data according to the calculation logic of the target analysis indicator included in the indicator library and the structure parameter.
[0055] In a possible implementation, when the structure parameter includes a dimension parameter, a filtering condition parameter, and a sorting parameter, the using the processing engine to generate SQL data corresponding to the natural language data according to the calculation logic of the target analysis indicator included in the indicator library and the structure parameter includes:
[0056] The using the processing engine to generate an indicator virtual table corresponding to the target analysis indicator according to the calculation logic of the target analysis indicator;
[0057] The using the processing engine to generate a dimension virtual table according to the dimension parameter;
[0058] The using the at least one target analysis indicator includes the using the indicator virtual table, the dimension virtual table, the filtering condition parameter, and the sorting parameter to generate SQL data corresponding to the natural language data.
[0059] In a possible implementation, when the structure parameter includes a dimension parameter, the method further includes:
[0060] The processing engine is used to check the at least one target analysis index and the dimension parameter based on a list of indexes and a list of dimensions included in the index library, to obtain a checking result;
[0061] The processing engine is used to generate SQL data corresponding to the natural language data according to the calculation logic of the target analysis index included in the index library and the structure parameter.
[0062] When the checking result indicates that there are indexes and dimensions, the processing engine is used to generate SQL data corresponding to the natural language data according to the calculation logic of the target analysis index included in the index library and the structure parameter.
[0063] In a possible implementation, the method further includes:
[0064] The structure parameter is adjusted based on a preset structure form to generate an adjusted structure parameter, and the adjusted structure parameter is used to generate the SQL data.
[0065] In a possible implementation, the method further includes:
[0066] The SQL data corresponding to the natural language data is adjusted to obtain adjusted SQL data, and the adjustment process includes at least one of the following:
[0067] A limit statement is added;
[0068] Same subqueries are combined;
[0069] Filter conditions are adjusted into queries of virtual tables;
[0070] Same filter conditions are combined;
[0071] The SQL data is formatted according to a preset reference format.
[0072] In a possible implementation, the method further includes:
[0073] In response to a triggered index management operation, an index management interface is displayed;
[0074] Index data of an updated analysis index input in the index management interface is received, and the index data of the updated analysis index is stored into the index library, where the index data includes an index name and calculation logic.
[0075] In a possible implementation, the method further includes:
[0076] Various index types suitable for various business scenarios are determined;
[0077] According to the various index types and the types of data stored in the original database, at least one preset analysis index under each index type is determined;
[0078] Based on the preset analysis index under each index type, the index library is generated.
[0079] In a third aspect, the disclosure provides a query language generation system, comprising:
[0080] An index library is configured to store index data of a plurality of preset analysis indexes generated in advance, the index data comprising an index name; wherein the index library is generated based on an original database;
[0081] A large model is configured to obtain natural language data input by a user, and obtain index names of a plurality of preset analysis indexes in a pre-generated index library; and based on the index names of the plurality of preset analysis indexes, identify the natural language data to determine at least one target analysis index included in the natural language data;
[0082] A processing engine is configured to generate structured query language (SQL) data corresponding to the natural language data according to the calculation logic of the target analysis index included in the index library, wherein the SQL data is used to query data from the original database.
[0083] In a possible implementation, before identifying the natural language data based on the index names of the plurality of preset analysis indexes, the large model is further configured to:
[0084] Determine a matching degree between the preset analysis index and the natural language data by using at least one matching algorithm;
[0085] Select a candidate analysis index from the plurality of preset analysis indexes according to the matching degree between each preset analysis index and the natural language data;
[0086] When identifying the natural language data based on the index names of the plurality of preset analysis indexes to determine at least one target analysis index included in the natural language data, the large model is configured to:
[0087] Identify the natural language data based on the index name of the candidate analysis index to determine at least one target analysis index included in the natural language data.
[0088] In a possible implementation, the large model is further configured to:
[0089] Extract a structure parameter from the natural language data, the structure parameter comprising at least one of a dimension parameter, a filtering condition parameter, and a sorting parameter;
[0090] the processing engine, in generating the structured query language (SQL) data corresponding to the natural language data according to the calculation logic of the target analysis indicator included in the indicator library and the structure parameter, is configured to:
[0091] generate the SQL data corresponding to the natural language data according to the calculation logic of the target analysis indicator included in the indicator library and the structure parameter.
[0092] In a possible implementation, when the structure parameter includes a dimension parameter, a filter condition parameter and a sorting parameter, the processing engine, in generating the SQL data corresponding to the natural language data according to the calculation logic of the target analysis indicator included in the indicator library and the structure parameter, is configured to:
[0093] generate an indicator virtual table corresponding to the target analysis indicator according to the calculation logic of the target analysis indicator;
[0094] generate a dimension virtual table according to the dimension parameter;
[0095] generate the SQL data corresponding to the natural language data by using the indicator virtual table of the at least one target analysis indicator, the dimension virtual table, the filter condition parameter and the sorting parameter.
[0096] In a possible implementation, when the structure parameter includes a dimension parameter, the processing engine is further configured to:
[0097] verify the at least one target analysis indicator and the dimension parameter based on an indicator list and a dimension list included in the indicator library, to obtain a verification result;
[0098] the processing engine, in generating the SQL data corresponding to the natural language data according to the calculation logic of the target analysis indicator included in the indicator library and the structure parameter, is configured to:
[0099] generate the SQL data corresponding to the natural language data according to the calculation logic of the target analysis indicator included in the indicator library and the structure parameter, when the verification result indicates that the indicator and the dimension exist.
[0100] In a possible implementation, the processing engine is further configured to:
[0101] adjust the structure parameter based on a preset structure form, to generate an adjusted structure parameter, where the adjusted structure parameter is used to generate the SQL data.
[0102] In a possible implementation, the processing engine is further configured to:
[0103] adjusting the SQL data corresponding to the natural language data to obtain adjusted SQL data, wherein the adjusting process comprises at least one of the following:
[0104] adding a limit statement;
[0105] merging the same subquery;
[0106] adjusting the filter condition into the query of the virtual table;
[0107] merging the same filter condition;
[0108] formatting according to a preset reference format.
[0109] In a possible implementation, the system further comprises an adjusting module configured to:
[0110] in response to the triggered index management operation, displaying an index management interface;
[0111] receiving index data of the updated analysis index input in the index management interface, and storing the index data of the updated analysis index to an index library, wherein the index data comprises an index name and a calculation logic.
[0112] In a possible implementation, the index library is generated according to the following steps:
[0113] determining various index types suitable for various business scenarios;
[0114] determining at least one preset analysis index under each index type according to the various index types and data types stored in the original database;
[0115] generating the index library based on the preset analysis index under each index type.
[0116] In a fourth aspect, the present disclosure provides a computer readable storage medium, and the computer readable storage medium stores a computer program. When the computer program is run by a processor, the computer program performs the steps of the query language generation method according to the second aspect or any one of the embodiments.
[0117] This application provides a query language generation method. After obtaining natural language data input by the user into a large model, it can obtain the names of multiple preset analysis indicators from a pre-generated indicator library. Based on the indicator names of the multiple preset analysis indicators, the large model identifies the natural language data and determines at least one target analysis indicator included in the natural language data. This realizes the extraction and identification of target analysis indicators in natural language data. Then, using a processing engine based on the calculation logic of the target analysis indicators included in the indicator library, it can accurately generate SQL data corresponding to the natural language data, thereby ensuring the accuracy and reliability of data analysis results.
[0118] Meanwhile, this application generates an indicator library based on the original database, so that the large model can identify indicators according to the indicator names of the preset analysis indicators in the indicator library, and the processing engine can generate SQL according to the calculation logic of the target analysis indicators in the indicator library without obtaining the database's metadata, thus mitigating the risk of database metadata leakage and ensuring the security of the data stored in the database.
[0119] To make the above-mentioned objects, features and advantages of this disclosure more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings. Attached Figure Description
[0120] To more clearly illustrate the technical solutions of the embodiments of this disclosure, the accompanying drawings used in the embodiments will be briefly described below. These drawings are incorporated in and constitute a part of this specification. They illustrate embodiments conforming to this disclosure and, together with the specification, serve to explain the technical solutions of this disclosure. It should be understood that the following drawings only show some embodiments of this disclosure and should not be considered as limiting the scope. Those skilled in the art can obtain other related drawings based on these drawings without creative effort.
[0121] Figure 1 illustrates a schematic diagram of generating SQL data in a related technique;
[0122] Figure 2 shows a flowchart of a query language generation method provided in an embodiment of this disclosure;
[0123] Figure 3 shows a flowchart illustrating another query language generation method provided in an embodiment of this disclosure;
[0124] Figure 4 illustrates a flowchart of generating SQL data according to an embodiment of this disclosure;
[0125] Figure 5 shows a schematic diagram of the architecture of a query language generation system provided in an embodiment of this disclosure;
[0126] FIG. 6 shows a structural schematic diagram of an electronic device provided by an embodiment of the present disclosure. DETAILED DESCRIPTION
[0127] To make the objects, technical solutions, and advantages of the embodiments of the present disclosure clearer, the following will be combined with the accompanying drawings for the embodiments of the present disclosure to clearly and completely describe the technical solutions of the embodiments of the present disclosure. Obviously, the described embodiments are only a part of the embodiments of the present disclosure and are not all the embodiments. The components of the embodiments of the present disclosure generally described and shown in the accompanying drawings can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present disclosure provided in the accompanying drawings is not intended to limit the scope of the claimed present disclosure, but only represents selected embodiments of the present disclosure. Based on the embodiments of the present disclosure, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present disclosure.
[0128] Referring to FIG. 1, when data analysis is performed by using a large model, the large model can obtain meta information of a related database, generate structured query language (SQL) data according to natural language input by a user and the meta information of the database, but the natural language input by the user is complex and diverse, so that the accuracy of the SQL data generated by the large model is difficult to guarantee, and thus the accuracy of data analysis is low; and the meta information of the database is provided to the large model, which has a risk of leaking key information of the database, and reduces the security of the data stored in the database.
[0129] To alleviate the above problems, the embodiments of the present disclosure provide a query language generation method. After obtaining natural language data input by a user to a large model, the method can obtain index names of a plurality of preset analysis indexes in a pre-generated index library; and the large model can identify the natural language data based on the index names of the plurality of preset analysis indexes, so as to accurately determine at least one target analysis index included in the natural language data, thereby realizing extraction and identification of the target analysis index in the natural language data. Then, a processing engine can accurately generate SQL data corresponding to the natural language data according to the calculation logic of the target analysis index included in the index library, so as to guarantee the accuracy and reliability of the data analysis result.
[0130] Meanwhile, the embodiments of the present disclosure generate an index library based on an original database, so that the large model can identify indexes according to index names of preset analysis indexes in the index library, and the processing engine can generate SQL according to the calculation logic of the target analysis index in the index library, without obtaining meta information of the database, thereby alleviating the risk of leaking the meta information of the database and guaranteeing the security of the data stored in the database.
[0131] It should be noted that like reference numerals and characters refer to like items throughout the attached drawings and alternative embodiments thereof, noting that when a term in a drawing is defined, it need not be further defined and explained in subsequent drawings.
[0132] It can be understood that, before using the technical solutions disclosed in the embodiments of the present disclosure, the type of personal information involved in the present disclosure, the use range, the use scenario, etc. should be informed to the user and the authorization of the user should be obtained through appropriate means according to relevant laws and regulations.
[0133] In order to facilitate the understanding of the embodiments of the present disclosure, first, a query language generation method disclosed by the embodiments of the present disclosure is introduced in detail. The execution subject of the query language generation method provided by the embodiments of the present disclosure is generally a computer device with certain computing power, which includes, for example: terminal equipment or server or other processing equipment, and the terminal equipment can be user equipment (User Equipment, UE), mobile equipment, user terminal, personal digital assistant (Personal Digital Assistant, PDA), handheld device, computing device, vehicle-mounted device, wearable device, etc. In some possible implementation manners, the query language generation method can be realized by a processor calling computer readable instructions stored in a memory.
[0134] Referring to FIG. 2, a flowchart of a query language generation method provided by the embodiments of the present disclosure is shown, and the method includes S201 to S203, wherein:
[0135] S201, obtaining natural language data input by a user to a large model, and obtaining index names of a plurality of preset analysis indexes in a pre-generated index library; wherein the index library is generated based on an original database.
[0136] S202, using the large model to identify the natural language data based on the index names of the plurality of preset analysis indexes, and determining at least one target analysis index included in the natural language data.
[0137] S203, using a processing engine to generate structured query language (SQL) data corresponding to the natural language data according to a calculation logic of the target analysis index included in the index library, wherein the SQL data is used to query data from the original database.
[0138] The following will be described in detail.
[0139] For S201:
[0140] The large model is a pre-trained deep learning model that can perform data analysis. A user can input natural language data on an interaction interface of the large model. The natural language data can include data content expressing a data analysis request, such as natural language data being "calculate the growth rate of total sales last year compared with this year", or natural language data being "query online store sales in the last three months", and the like.
[0141] In addition, an index list can be obtained from a pre-generated index library, the index list including index names of a plurality of pre-generated preset analysis indexes, and can also include index description information of the preset analysis indexes, the index description information can be used to reflect physical meaning and other information of the preset analysis indexes. The index library is generated based on an original database, for example, the original database stores sales data of online stores and offline stores, and the preset analysis indexes can include, for example, revenue, cost, sales, sales growth rate, and the like, wherein the preset analysis indexes in the index library can be set as needed. The index library can be managed and maintained, for example, the preset analysis indexes in the index library can be modified, deleted, added, and the like, so that the index library meets the diversity requirements of users, thereby meeting the data analysis requirements of users and improving user experience.
[0142] In an optional implementation, the method further includes: determining various index types suitable for a plurality of business scenarios; determining at least one preset analysis index under each index type according to the various index types and data types stored in the original database; and generating the index library based on the preset analysis indexes under the various index types.
[0143] The business scenarios can be, for example, bank business scenarios, mall business scenarios, e-commerce business scenarios, enterprise business scenarios, and the like, wherein the business scenarios can be determined as needed. The various index types can include, for example, atomic index types, derived index types, composite index types, proportion index types, difference index types, list index types, and ranking index types.
[0144] Further, for each index type, at least one preset analysis index under each index type can be determined according to the data type stored in the original database. The preset analysis index can be determined according to the actual application scenario, which is not limited in the present application. For example, if the data type stored in the original database is the sales data, cost data, order data, etc. of online and offline stores, the atomic index type can be the basic analysis index, such as the income, expenditure, etc. analysis index. The derived index type can include analysis indexes obtained by combining atomic indexes with filtering conditions, such as annual income, quarterly income, etc. analysis index. The composite index type can include analysis indexes obtained by operating (such as addition, subtraction, multiplication, and division) multiple indexes, such as profit, etc. analysis index. The ranking index type such as income ranking, sales ranking, etc. analysis index. The difference index type such as income growth, expenditure reduction, etc. analysis index. The proportion index type such as operating profit, small and micro merchant proportion, etc. analysis index. The list index type such as various costs, various expenditures, etc. analysis index, and the cost types included in the various costs can be set according to the demand.
[0145] Further, the index library is generated based on the preset analysis indexes under various index types, that is, the index library includes the preset analysis indexes under various index types.
[0146] By determining various index types, at least one preset analysis index under each index type can be determined according to various index types and the data type stored in the original database, so that the preset analysis index is more comprehensive, so that the preset analysis index in the index library can meet the user demand and improve the user experience.
[0147] In an optional implementation, the method further includes: in response to the triggered index management operation, displaying an index management interface; receiving the index data of the updated analysis index input in the index management interface, and storing the index data of the updated analysis index to the index library, wherein the index data includes the index name and the calculation logic.
[0148] The plurality of preset analysis indexes included in the index library can be displayed, for example, at least part of the preset analysis indexes included in the index library can be directly displayed on the interactive interface of the large model, or the user can trigger the index display button on the interactive interface to display the preset analysis indexes included in the index library.
[0149] The interactive interface can also be provided with a management button of the index library, so that after the user clicks the management button, the index management operation is triggered, and an index management interface is displayed. The management button can include, for example, an add button, a delete button, a modify button, and the like. In implementation, the user can update the existing preset analysis index in the index management interface, such as updating the index data of the preset analysis index, which includes the index name, the index description information, the calculation logic, and the like. The updated index data of the preset analysis index input in the index management interface is received, and the updated index data of the analysis index is stored to the index library. Alternatively, the user can add an analysis index in the index management interface and input the index data of the added analysis index, and store the index data of the added analysis index to the index library. Alternatively, the user can also trigger a deletion operation on the preset analysis index on the index management interface, and delete the index data of the preset analysis index from the index library.
[0150] For S202:
[0151] The large model is used to identify the natural language data based on the index names of the plurality of preset analysis indexes, to determine at least one target analysis index included in the natural language data. For example, the natural language data is "calculate the growth rate of total sales last year compared with this year", and the target analysis index can include the growth rate and the total sales.
[0152] To improve the efficiency of the large model in identifying the natural language data, a candidate analysis index matching the natural language data can also be determined from the plurality of preset analysis indexes included in the database, so as to subsequently identify the natural language data based on the candidate analysis index. For example, if "sales" is included in the natural language data, an analysis index including "sales" can be determined as a candidate analysis index from the preset analysis indexes.
[0153] In an optional implementation, before the large model is used to identify the natural language data based on the index names of the plurality of preset analysis indexes, at least one matching algorithm is used to determine the matching degree between the preset analysis indexes and the natural language data, and the candidate analysis index is selected from the plurality of preset analysis indexes according to the matching degree between each preset analysis index and the natural language data.
[0154] Further, the large model can be used to identify the natural language data based on the index name of the candidate analysis index, to determine at least one target analysis index included in the natural language data.
[0155] The matching algorithm can include, but is not limited to, a longest common subsequence (LCS) algorithm, a vector approximate degree matching algorithm, and the like. When there are multiple matching algorithms, each matching algorithm can be used to determine the matching degree between the preset analysis indicators and the natural language data; candidate analysis indicators can be selected from the multiple preset analysis indicators according to the matching degree between each preset analysis indicator and the natural language data, for example, a preset analysis indicator with a matching degree greater than a matching degree threshold can be selected as a candidate analysis indicator, and / or a preset number of preset analysis indicators can be selected as candidate analysis indicators in descending order of matching degree, and the like. The candidate analysis indicators selected by the multiple matching algorithms are taken as a union set to obtain candidate analysis indicators matched with the natural language data.
[0156] The present application selects candidate analysis indicators according to matching degrees to identify natural language data using the candidate analysis indicators, which can accurately and efficiently determine target analysis indicators included in the natural language data.
[0157] For S203:
[0158] The large model can send the determined target analysis indicators to the processing engine, and the processing engine can generate SQL data corresponding to the natural language data according to the calculation logic of the target analysis indicators included in the indicator library, where the SQL data is used to query data from the original database to analyze the data according to the queried data and determine the interaction result corresponding to the natural language data input by the user.
[0159] For example, an indicator virtual table can be generated according to the target analysis indicators, and then the SQL data can be generated according to the indicator virtual table. For example, a query code segment can be generated according to the syntax rules of SQL, the indicator virtual table can be added to the query code segment, and the SQL data can be generated.
[0160] In specific implementation, the large model can also generate an indicator code segment containing the target analysis indicators according to at least one target analysis indicator, and send the indicator code segment to the processing engine. The processing engine can determine whether the target analysis indicators exist in the indicator library according to the indicator code segment, and / or determine whether the format of the indicator code segment is standard, and if the format is standard and the target analysis indicators exist, the SQL data can be generated according to the indicator code segment.
[0161] In an optional implementation, the method further includes extracting a structure parameter from the natural language data using the large model, where the structure parameter includes at least one of a dimension parameter, a filtering condition parameter, and a sorting parameter.
[0162] The dimensions parameter is used to measure attributes of the analysis index, such as time, geographical position, etc. The filter condition parameter is used to select data from the original database. The sorting parameter is used to sort data, and the sorting parameter can include, for example, ascending order, descending order, etc.
[0163] The processing engine generates the structured query language (SQL) data corresponding to the natural language data according to the calculation logic of the target analysis index included in the index library and the structure parameter.
[0164] For example, a query code segment is generated according to the syntax rule of SQL and the structure parameter, the index virtual table is added to the query code segment, and the SQL data is generated.
[0165] Optionally, when the structure parameter includes the dimensions parameter, the filter condition parameter, and the sorting parameter, the processing engine generates the SQL data corresponding to the natural language data according to the calculation logic of the target analysis index included in the index library and the structure parameter, including: generating, by the processing engine, an index virtual table corresponding to the target analysis index according to the calculation logic of the target analysis index; generating, by the processing engine, a dimensions virtual table according to the dimensions parameter; and generating, by the processing engine, the SQL data corresponding to the natural language data by using the index virtual table of the at least one target analysis index, the dimensions virtual table, the filter condition parameter, and the sorting parameter.
[0166] In implementation, the processing engine generates an index virtual table corresponding to a target analysis index according to the syntax rule of SQL and the calculation logic of the target analysis index, and each target analysis index corresponds to an index virtual table; and the processing engine generates a dimensions virtual table according to the dimensions parameter.
[0167] The SQL data corresponding to the natural language data is generated according to the filter condition parameter and the sorting parameter, the dimensions virtual table and the index virtual table corresponding to each target analysis index are added to the basic query code, and the SQL data corresponding to the natural language data is generated.
[0168] The application generates the SQL data in the above manner, and can realize arbitrary combination query of multiple target analysis indexes, and improves the flexibility of data query.
[0169] In an optional implementation, when the structure parameter includes the dimensions parameter, the method further includes: verifying, by the processing engine, the at least one target analysis index and the dimensions parameter based on an index list and a dimensions list included in the index library, to obtain a verification result.
[0170] In implementation, the index library can be pre-configured with an index list and a dimension list, where the dimension list includes a plurality of preset dimensions, and the index list includes a plurality of preset analysis indexes. The preset dimensions and the preset analysis indexes are generated based on the original database.
[0171] In consideration of the possibility of errors in the index parameters (i.e., target analysis indexes) and dimension parameters extracted by the large model, which in turn reduces the accuracy of the subsequently generated SQL, the processing engine can obtain the index list and the dimension list from the index library, and check at least one target analysis index and dimension parameter according to the index list and the dimension list, to determine whether the target analysis index exists in the index list and whether the dimension parameter exists in the dimension list. If both exist, it is determined that the check result is a check pass. If the target analysis index and / or the dimension parameter do not exist, it is determined that the check result is a check fail. The target analysis index and the dimension parameter can then be re-extracted by the large model.
[0172] Further, when the check result indicates that the index and the dimension exist, the processing engine can generate the SQL data corresponding to the natural language data according to the calculation logic of the target analysis index included in the index library and the structure parameter.
[0173] The present application can guarantee the accuracy of the target analysis indexes and the dimension parameters extracted by the large model by checking the target analysis indexes and the dimension parameters, thereby guaranteeing the accuracy of the subsequently generated SQL.
[0174] In an optional implementation, the method further includes adjusting the structure parameter based on a preset structure form to generate an adjusted structure parameter, where the adjusted structure parameter is used to generate the SQL data.
[0175] In consideration of the diversity of the data structure of the natural language data input by the user, such as the date data, which can have a data structure in the form of year-month-day, month-day-year, or the like. In order to more accurately generate the SQL data, the structure parameter can be adjusted based on a preset structure form to generate an adjusted structure parameter in implementation. Further, the processing engine can generate the SQL data corresponding to the natural language data according to the calculation logic of the target analysis index included in the index library and the adjusted structure parameter.
[0176] In an optional implementation, the method further includes adjusting the SQL data corresponding to the natural language data to obtain adjusted SQL data, where the adjustment process includes at least one of the following: 1. adding a limit statement; 2. merging the same subquery; 3. adjusting the filter condition to the query of the virtual table; 4. merging the same filter condition; and 5. formatting processing according to a preset reference format.
[0177] By post-processing adjustment on natural language data, the adjusted SQL data can be more standardized, and the performance of data analysis is better.
[0178] In combination with FIG. 3, the query language generation method proposed in the application is exemplarily described, which specifically includes:
[0179] Step 1, receiving natural language data input by a user to a large model.
[0180] Step 2, obtaining an index list of an index library of a semantic index platform.
[0181] The semantic index platform includes an index library, and the index library is provided with an index list. The index list includes index definitions, i.e., index names and index description information of preset analysis indexes.
[0182] Step 3, using multiple matching algorithms to filter multiple preset analysis indexes in the index list to determine candidate analysis indexes.
[0183] In implementation, the matching degrees between the preset analysis indexes and the natural language data can be determined by using multiple matching algorithms, and the candidate analysis indexes can be selected from the multiple preset analysis indexes according to the matching degrees between each preset analysis index and the natural language data.
[0184] Step 4, using the large model to identify the natural language data based on the index name of the candidate analysis index to determine at least one target analysis index included in the natural language data, and sending the at least one target analysis index to a processing engine.
[0185] Step 5, using the processing engine to generate structured query language (SQL) data corresponding to the natural language data according to the calculation logic of the target analysis indexes included in the index library, wherein the SQL data is used to query data from the original database.
[0186] In implementation, the SQL data generated by the processing engine is exemplarily described in combination with FIG. 4, and the process includes:
[0187] Step 51, receiving a parameter extraction result of the large model.
[0188] The parameter extraction result can include an index parameter (i.e., at least one target analysis index) and a structure parameter, and the structure parameter includes at least one of a dimension parameter, a filtering condition parameter, and a sorting parameter.
[0189] Step 52, format verification.
[0190] Specifically, the at least one target analysis index and the dimension parameter can be verified based on the index list and the dimension list included in the index library to obtain a verification result.
[0191] The large model can send parameter code information indicating the structure parameter and metric code information indicating the metric parameter to the processing engine. The processing engine can further determine whether the parameter format of the parameter code information and the metric code information is correct according to the syntax rule of the SQL.
[0192] Step 53: When the verification result is a verification pass, pre-processing is performed.
[0193] The processing content of the pre-processing can be determined according to the syntax rule of the SQL. The pre-processing can include adjusting the structure parameter based on a preset structure form to generate an adjusted structure parameter.
[0194] For example, when there is date grouping, the date groupBys is used by default; for example, when there is a groupBy / metric that is not extracted in the groupBys, it is added to the groupBys / metricNames, and the like.
[0195] Step 54: SQL generation.
[0196] In implementation, the processing engine generates a metric virtual table corresponding to each target analysis metric according to the calculation logic of each target analysis metric, and generates a dimension virtual table according to the dimension parameter; and generates SQL data corresponding to the natural language data using the metric virtual table of at least one target analysis metric, the dimension virtual table, the filtering condition parameter, and the sorting parameter.
[0197] Step 55: Post-processing.
[0198] In implementation, the process of the post-processing can be: adjusting the SQL data corresponding to the natural language data to obtain adjusted SQL data, wherein the adjustment process includes at least one of the following: adding a limit statement; subquery merging, i.e., merging the same subquery; filtering condition pushing down, i.e., adjusting the filtering condition to the query of the virtual table; filtering condition merging, i.e., merging the same filtering condition; and performing format processing according to a preset reference format.
[0199] The query language generation method of the present application can generate SQL data according to the natural language data input by the user, so that the user can obtain SQL data without understanding the syntax rules of SQL, the structure of the database and other information, reducing the difficulty of generating SQL data. In the present application, the index data of the preset analysis index includes calculation logic, so that SQL data can be generated according to the calculation logic of the preset analysis index, so that the user does not need to add the calculation logic of the target analysis index in the natural language data after inputting the target analysis index, simplifying the input content of the user and improving the user experience. At the same time, by determining the target analysis index, the natural language data is converted into an explicit target analysis index, which realizes a more accurate understanding of the query requirements of the natural language data, and then according to the calculation logic of the target analysis index, the SQL data can be accurately generated.
[0200] Those skilled in the art can understand that in the above method of the specific embodiment, the writing order of each step does not mean a strict execution order and does not constitute any limitation on the implementation process. The specific execution order of each step should be determined by its function and possible internal logic.
[0201] Based on the same concept, the present application also provides a query language generation system, as shown in Figure 5, which is the architecture diagram of the query language generation system provided by the present application, including:
[0202] The index library 501 is used to store the index data of a plurality of preset analysis indexes generated in advance, and the index data includes an index name; wherein the index library is generated based on an original database;
[0203] The large model 502 is used to obtain natural language data input by a user, and obtain the index names of a plurality of preset analysis indexes in the index library 501 generated in advance; and identify the natural language data based on the index names of the plurality of preset analysis indexes, and determine at least one target analysis index included in the natural language data;
[0204] The processing engine 503 is used to generate structured query language (SQL) data corresponding to the natural language data according to the calculation logic of the target analysis index included in the index library, wherein the SQL data is used to obtain index data from the database.
[0205] In one possible implementation, before identifying the natural language data based on the index names of the plurality of preset analysis indexes, the large model 502 is further used to:
[0206] Determine the matching degree between the preset analysis index and the natural language data by using at least one matching algorithm;
[0207] select a candidate analysis indicator from the plurality of preset analysis indicators according to matching degrees between each preset analysis indicator and the natural language data;
[0208] The large model 502 is configured to:
[0209] identify the natural language data based on an indicator name of the candidate analysis indicator, and determine at least one target analysis indicator included in the natural language data.
[0210] In a possible implementation, the large model 502 is further configured to:
[0211] extract a structure parameter from the natural language data, the structure parameter including at least one of a dimension parameter, a filter condition parameter, and a sorting parameter;
[0212] The processing engine is configured to:
[0213] generate SQL data corresponding to the natural language data according to the calculation logic of the target analysis indicator included in the indicator library and the structure parameter.
[0214] In a possible implementation, when the structure parameter includes a dimension parameter, a filter condition parameter, and a sorting parameter, the processing engine 503 is configured to:
[0215] generate an indicator virtual table corresponding to the target analysis indicator according to the calculation logic of the target analysis indicator;
[0216] generate a dimension virtual table according to the dimension parameter;
[0217] generate the SQL data corresponding to the natural language data by using the indicator virtual table of the at least one target analysis indicator, the dimension virtual table, the filter condition parameter, and the sorting parameter.
[0218] In a possible implementation, when the structure parameter includes a dimension parameter, the processing engine 503 is further configured to:
[0219] verify the at least one target analysis indicator and the dimension parameter based on an indicator list and a dimension list included in the indicator library, to obtain a verification result;
[0220] The processing engine is configured to generate SQL data corresponding to the natural language data according to the calculation logic of the target analysis indicator included in the indicator library and the structure parameter.
[0221] When the verification result indicates that the indicator and the dimension exist, the processing engine is configured to generate SQL data corresponding to the natural language data according to the calculation logic of the target analysis indicator included in the indicator library and the structure parameter.
[0222] In a possible implementation, the processing engine 503 is further configured to adjust the structure parameter based on a preset structure form to generate an adjusted structure parameter, where the adjusted structure parameter is used to generate the SQL data.
[0223] In a possible implementation, the processing engine 503 is further configured to:
[0224] adjust the SQL data corresponding to the natural language data to obtain adjusted SQL data, where the adjustment process includes at least one of the following:
[0225] adding a limit statement;
[0226] merging the same subquery;
[0227] adjusting the filter condition to the query of the virtual table;
[0228] merging the same filter condition;
[0229] performing format processing according to a preset reference format.
[0230] In a possible implementation, the system further includes an adjustment module configured to:
[0231] in response to a triggered indicator management operation, display an indicator management interface;
[0232] receive indicator data of an updated analysis indicator input in the indicator management interface, and store the indicator data of the updated analysis indicator to the indicator library, where the indicator data includes an indicator name and calculation logic.
[0233] In a possible implementation, the indicator library 501 is generated according to the following steps:
[0234] determining various indicator types suitable for adapting to various business scenarios;
[0235] determining at least one preset analysis indicator under each indicator type according to the various indicator types and data types stored in the original database;
[0236] Generate the index library based on each preset analysis index under the various index types.
[0237] In some embodiments, the system provided by the embodiments of the present disclosure has functions or contains templates that can be used to perform the methods described in the above method embodiments, and specific implementations can refer to the descriptions of the above method embodiments. For brevity, they will not be repeated here.
[0238] Based on the same technical concept, the embodiments of the present disclosure also provide an electronic device. Referring to FIG. 6, a structural schematic diagram of an electronic device provided by the embodiments of the present disclosure is shown, which includes a processor 601, a memory 602, and a bus 603. Among them, the memory 602 is used to store execution instructions, including an internal memory 6021 and an external memory 6022; the internal memory 6021 here is also called an internal memory, which is used to temporarily store operation data in the processor 601 and exchange data with the external memory 6022 such as a hard disk, and the processor 601 exchanges data with the external memory 6022 through the internal memory 6021, when the electronic device 600 is running, the processor 601 and the memory 602 communicate through the bus 603, so that the processor 601 executes the following instructions:
[0239] Obtain natural language data input by a user to a large model, and obtain index names of a plurality of preset analysis indexes in a pre-generated index library; wherein the index library is generated based on an original database;
[0240] Use the large model to identify the natural language data based on the index names of the plurality of preset analysis indexes, and determine that the natural language data includes at least one target analysis index;
[0241] Use a processing engine to generate structured query language (SQL) data corresponding to the natural language data according to a calculation logic of the target analysis index included in the index library, wherein the SQL data is used to query data from the original database.
[0242] In a possible implementation, among the instructions executed by the processor 601, before using the large model to identify the natural language data based on the index names of the plurality of preset analysis indexes, it further includes:
[0243] Use at least one matching algorithm to determine a matching degree between the preset analysis index and the natural language data;
[0244] Select a candidate analysis index from the plurality of preset analysis indexes according to the matching degree between each preset analysis index and the natural language data;
[0245] The large model is used to identify the natural language data based on the index name of the plurality of preset analysis indicators, to determine at least one target analysis indicator included in the natural language data, including:
[0246] The large model is used to identify the natural language data based on the index name of the candidate analysis indicator, to determine at least one target analysis indicator included in the natural language data.
[0247] In a possible implementation, the instructions executed by the processor 601 further include:
[0248] The large model is used to extract a structure parameter from the natural language data, the structure parameter including at least one of a dimension parameter, a filtering condition parameter, and a sorting parameter.
[0249] The processing engine is used to generate structured query language (SQL) data corresponding to the natural language data according to the calculation logic of the target analysis indicator included in the index library, including:
[0250] The processing engine is used to generate SQL data corresponding to the natural language data according to the calculation logic of the target analysis indicator included in the index library and the structure parameter.
[0251] In a possible implementation, when the structure parameter includes a dimension parameter, a filtering condition parameter, and a sorting parameter, the processor 601 generates, by using the processing engine, SQL data corresponding to the natural language data according to the calculation logic of the target analysis indicator included in the index library and the structure parameter, including:
[0252] The processing engine is used to generate an index virtual table corresponding to the target analysis indicator according to the calculation logic of the target analysis indicator.
[0253] The processing engine is used to generate a dimension virtual table according to the dimension parameter.
[0254] The index virtual table, the dimension virtual table, the filtering condition parameter, and the sorting parameter of the at least one target analysis indicator are used to generate SQL data corresponding to the natural language data.
[0255] In a possible implementation, when the structure parameter includes a dimension parameter, the processor 601 further executes instructions to: verify, by using the processing engine, the at least one target analysis indicator and the dimension parameter based on an index list and a dimension list included in the index library, to obtain a verification result.
[0256] The processing engine generates the SQL data corresponding to the natural language data according to the calculation logic of the target analysis index included in the index library and the structure parameter, including: when the verification result indicates that the index and the dimension exist, the processing engine generates the SQL data corresponding to the natural language data according to the calculation logic of the target analysis index included in the index library and the structure parameter.
[0257] In a possible implementation, the instructions executed by the processor 601 further include:
[0258] The structure parameter is adjusted based on a preset structure form to generate an adjusted structure parameter, where the adjusted structure parameter is used to generate the SQL data.
[0259] In a possible implementation, the instructions executed by the processor 601 further include:
[0260] The SQL data corresponding to the natural language data is adjusted to obtain adjusted SQL data, where the adjustment process includes at least one of the following:
[0261] A limit statement is added;
[0262] Same subqueries are merged;
[0263] Filter conditions are adjusted into queries of virtual tables;
[0264] Same filter conditions are merged;
[0265] The SQL data is formatted according to a preset reference format.
[0266] In a possible implementation, the instructions executed by the processor 601 further include:
[0267] In response to a triggered index management operation, an index management interface is displayed;
[0268] Index data of an updated analysis index input in the index management interface is received, and the index data of the updated analysis index is stored to the index library, where the index data includes an index name and calculation logic.
[0269] In a possible implementation, the instructions executed by the processor 601 further include:
[0270] Various index types suitable for multiple business scenarios are determined;
[0271] At least one preset analysis index under each index type is determined according to the various index types and data types stored in the original database;
[0272] Generate the index library based on each preset analysis index under each index type.
[0273] The specific processing procedure of the processor 601 can refer to the description of the above method embodiments, and will not be described here.
[0274] In addition, the embodiment of the present disclosure further provides a computer readable storage medium, and the computer readable storage medium stores a computer program. When the computer program is run by a processor, the steps of the query language generation method described in the above method embodiments are executed. The storage medium can be a volatile or non-volatile computer readable storage medium.
[0275] The embodiment of the present disclosure further provides a computer program product carrying a program code. The instructions included in the program code can be used to execute the steps of the query language generation method described in the above method embodiments. For details, refer to the above method embodiments, which will not be described here.
[0276] The computer program product can be specifically implemented by hardware, software, or a combination thereof. In an optional embodiment, the computer program product is specifically embodied as a computer storage medium. In another optional embodiment, the computer program product is specifically embodied as a software product, such as a software development kit (SDK) and the like.
[0277] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the above-described system and device can refer to the corresponding process in the foregoing method embodiments, which will not be described here. In several embodiments provided by the present disclosure, it should be understood that the disclosed system, device and method can be implemented by other ways. The above-described device embodiments are only schematic, for example, the division of the units is only a logical function division, and actual implementation can have another division manner, for example, a plurality of units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the coupling or direct coupling or communication connection between the units shown or discussed can be indirect coupling or communication connection through some communication interfaces, devices or units, and can be electrical, mechanical or other forms.
[0278] The units described as separate components can or can not be physically separate, and the components shown as units can or can not be physical units, that is, they can be located in one place, or can be distributed on a plurality of network units. According to actual needs, some or all of the units can be selected to achieve the purpose of the embodiment.
[0279] In addition, each function unit in various embodiments of the present disclosure can be integrated in one processing unit, or each unit can be physically present separately, or two or more units can be integrated in one unit.
[0280] If the functions are implemented in the form of software function units and sold or used as independent products, they can be stored in a nonvolatile computer readable storage medium executable by a processor. Based on this understanding, the technical solutions of the present disclosure essentially or say the part that contributes to the prior art or part of the technical solutions can be embodied in the form of a software product. The computer software product is stored in a storage medium, including a number of instructions to make a computer device (which can be a personal computer, a server, or a network device, etc.) execute all or part of the steps of the method described in various embodiments of the present disclosure. The foregoing storage medium includes: a U disk, a mobile hard disk, a read-only memory (Read-Only Memory, ROM), a random access memory (Random Access Memory, RAM), a magnetic disk or an optical disk, and various media that can store program codes.
[0281] The above is only a specific embodiment of the present disclosure, but the protection scope of the present disclosure is not limited thereto. Any person skilled in the art can easily think of changes or replacements within the technical scope disclosed by the present disclosure, which should be covered within the protection scope of the present disclosure. Therefore, the protection scope of the present disclosure should be subject to the protection scope of the claims.
Claims
1. An electronic device, comprising: The method comprises the following steps: A processor, a memory and a bus, the memory stores machine readable instructions executable by the processor, when the electronic device is running, the processor communicates with the memory through the bus, the machine readable instructions are executed by the processor to execute the query language generation process, the query language generation process comprises: Obtain the natural language data input by the user to the large model, and obtain the index names of a plurality of preset analysis indexes in the pre-generated index library; wherein the index library is generated based on the original database; Using the large model, the natural language data is identified based on the index names of the plurality of preset analysis indexes, and at least one target analysis index included in the natural language data is determined; Using the processing engine, the structured query language SQL data corresponding to the natural language data is generated according to the calculation logic of the target analysis index included in the index library, wherein the SQL data is used to query data from the original database.
2. The electronic device of claim 1, wherein, In the query language generation process executed by the processor, before the natural language data is identified by the large model based on the index names of the plurality of preset analysis indexes, the following steps are further included: Using at least one matching algorithm, the matching degree between the preset analysis index and the natural language data is determined; According to the matching degree between each preset analysis index and the natural language data, the candidate analysis index is selected from the plurality of preset analysis indexes; The natural language data is identified by the large model based on the index names of the candidate analysis index, and at least one target analysis index included in the natural language data is determined. In the query language generation process executed by the processor, the following steps are further included:
3. The electronic device of claim 1, wherein, Using the large model, the structure parameters are extracted from the natural language data, the structure parameters include at least one of the following: dimension parameter, filtering condition parameter, sorting parameter; The SQL data corresponding to the natural language data is generated by the processing engine according to the calculation logic of the target analysis index included in the index library and the structure parameters. In the query language generation process executed by the processor, when the structure parameters include dimension parameter, filtering condition parameter and sorting parameter, the SQL data corresponding to the natural language data is generated by the processing engine according to the calculation logic of the target analysis index included in the index library and the structure parameters, comprising: Using the processing engine, the index virtual table corresponding to the target analysis index is generated according to the calculation logic of the target analysis index; 4. The electronic device of claim 3, wherein, Using the processing engine, the dimension virtual table is generated according to the dimension parameter; Generate SQL data corresponding to the natural language data using the index virtual table of the at least one target analysis index, the dimension virtual table, the filtering condition parameter, and the sorting parameter.
5. The electronic device of claim 3, wherein, In the query language generation process executed by the processor, when the structure parameter includes a dimension parameter, further comprising: Using the processing engine, verify the at least one target analysis index and the dimension parameter based on the index list and the dimension list included in the index library, to obtain a verification result; The processing engine generates SQL data corresponding to the natural language data according to the calculation logic of the target analysis index included in the index library and the structure parameter, comprising: When the verification result indicates that there are indexes and dimensions, the processing engine generates SQL data corresponding to the natural language data according to the calculation logic of the target analysis index included in the index library and the structure parameter.
6. The electronic device of claim 3, wherein, In the query language generation process executed by the processor, further comprising: Adjust the structure parameter based on a preset structure form to generate an adjusted structure parameter, wherein the adjusted structure parameter is used to generate SQL data.
7. The electronic device of any of claims 1-6, wherein, In the query language generation process executed by the processor, further comprising: Adjust the SQL data corresponding to the natural language data to obtain adjusted SQL data, wherein the adjustment process includes at least one of the following: Add a limit statement; The same subquery is combined; Adjust the filtering condition to the query of the virtual table; The same filtering condition is combined; Format according to a preset reference format.
8. The electronic device of any of claims 1-6, wherein, In the query language generation process executed by the processor, further comprising: In response to the triggered index management operation, display an index management interface; Receive the updated analysis index data input in the index management interface, and store the updated analysis index data in the index library, wherein the index data includes the index name and the calculation logic.
9. The electronic device of any of claims 1-6, wherein, In the query language generation process executed by the processor, further comprising: Determine various index types suitable for multiple business scenarios; According to the various index types and the data types stored in the original database, determine at least one preset analysis index under each index type; Based on the various index types and the various preset analysis indexes under each index type, generate the index library.
10. A query language generation method characterized by comprising: Including: Obtain the natural language data input by the user to the large model, and obtain the index names of the plurality of preset analysis indexes in the pre-generated index library; The index library is generated based on the original database; Using the large model, identify the natural language data based on the index names of the plurality of preset analysis indexes, to determine at least one target analysis index included in the natural language data; Using the processing engine, generate structured query language (SQL) data corresponding to the natural language data according to the calculation logic of the target analysis index included in the index library, wherein the SQL data is used to query data from the original database.
11. The method of claim 10, wherein, Before the large model is used to identify the natural language data based on the index names of the plurality of preset analysis indicators, the method further includes: Determining a matching degree between the preset analysis indicators and the natural language data by using at least one matching algorithm; Selecting candidate analysis indicators from the plurality of preset analysis indicators according to the matching degrees between each preset analysis indicator and the natural language data; The large model is used to identify the natural language data based on the index names of the candidate analysis indicators, and at least one target analysis indicator included in the natural language data is determined. The large model is used to identify the natural language data based on the index names of the candidate analysis indicators, and at least one target analysis indicator included in the natural language data is determined.
12. The method of claim 10, wherein The method further includes: Extracting a structure parameter from the natural language data by using the large model, the structure parameter including at least one of a dimension parameter, a filtering condition parameter, and a sorting parameter; The processing engine is used to generate structured query language (SQL) data corresponding to the natural language data according to the calculation logic of the target analysis indicator included in the index library and the structure parameter. The processing engine is used to generate SQL data corresponding to the natural language data according to the calculation logic of the target analysis indicator included in the index library and the structure parameter.
13. The method of claim 12, wherein, When the structure parameter includes a dimension parameter, a filtering condition parameter, and a sorting parameter, the processing engine is used to generate SQL data corresponding to the natural language data according to the calculation logic of the target analysis indicator included in the index library and the structure parameter. The processing engine is used to generate an index virtual table corresponding to the target analysis indicator according to the calculation logic of the target analysis indicator. The processing engine is used to generate a dimension virtual table according to the dimension parameter. The SQL data corresponding to the natural language data is generated by using the index virtual table of the at least one target analysis indicator, the dimension virtual table, the filtering condition parameter, and the sorting parameter.
14. The method of claim 12, wherein, When the structure parameter includes a dimension parameter, the method further includes: The processing engine is used to verify the at least one target analysis indicator and the dimension parameter based on an index list and a dimension list included in the index library, and a verification result is obtained. The processing engine is used to generate SQL data corresponding to the natural language data according to the calculation logic of the target analysis indicator included in the index library and the structure parameter. When the verification result indicates that there are indexes and dimensions, the processing engine is used to generate SQL data corresponding to the natural language data according to the calculation logic of the target analysis indicator included in the index library and the structure parameter.
15. The method of claim 12, wherein, The method further includes: Adjusting the structure parameter based on a preset structure form to obtain an adjusted structure parameter, and the adjusted structure parameter is used to generate SQL data.
16. The method according to any of claims 10 to 15, characterized in that The method further includes: The SQL data corresponding to the natural language data is adjusted to obtain adjusted SQL data, and the adjustment process includes at least one of the following: adding a limit statement; merging the same subquery; adjusting the filter condition to the query of the virtual table; merging the same filter condition; formatting according to a preset reference format.
17. The method of any of claims 10-15, wherein, The method further includes: in response to the triggered index management operation, displaying an index management interface; receiving updated index data of the analysis index input in the index management interface, and storing the updated index data of the analysis index to an index library, wherein the index data includes an index name and a calculation logic.
18. The method of any of claims 10-15, wherein, The method further includes: determining various index types suitable for various business scenarios; determining at least one preset analysis index under each index type according to the various index types and the data types stored in the original database; generating the index library based on the preset analysis index under each index type.
19. A query language generation system, characterized by, It includes: an index library for storing the index data of a plurality of preset analysis indexes generated in advance, the index data including an index name; wherein the index library is generated based on an original database; a large model for obtaining natural language data input by a user and obtaining the index name of a plurality of preset analysis indexes in the index library generated in advance; and identifying the natural language data based on the index name of the plurality of preset analysis indexes to determine at least one target analysis index included in the natural language data; a processing engine for generating structured query language (SQL) data corresponding to the natural language data according to the calculation logic of the target analysis index included in the index library, wherein the SQL data is used to query data from the original database.
20. A computer-readable storage medium, characterized in that, The computer readable storage medium stores a computer program, and the computer program is run by the processor to execute the steps of the query language generation method according to any one of claims 10 to 18.
Citation Information
Patent Citations
Structured query language instruction generation method and device based on index system
CN108681589A
Structured query language generation method and system
CN111984674A
Structured query statement generation method and device and computer readable medium
CN116737762A
Data processing method, device and equipment and computer readable storage medium
CN116821103A
Query language generation method and system, electronic equipment and storage medium
CN118312531A