Error recognition method and device for structured query statement, equipment and storage medium
By extracting the matching of intention test points and query test points, combined with the semantic understanding of the large language model, the difficulty of structured query statement error recognition in the existing technology when standard answers are lacking, achieving higher accuracy and comprehensiveness.
Patent Information
- Application Number
- CN202510559656.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-29
- Publication Date
- 2025-08-15
AI Technical Summary
When identifying errors in structured query statements, it is difficult to achieve accurate recognition in the absence of standard answers, especially in terms of semantic and logical errors.
By extracting the intent test points of query intent and the query test points of structured query statements, the pre-constructed test point mapping relationship is used to match, identify hidden error information, and combine the semantic understanding and pattern recognition capabilities of the large language model to deeply explore potential errors.
The accurate identification of errors can be achieved without relying on standard answers, which improves the accuracy of error detection, reduces misjudgment and misjudgment, and improves the comprehensiveness of error recognition.
Smart Images

Figure CN120492474A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a method, device, equipment and storage medium for identifying errors in structured query statements. Background Art
[0002] In database query applications using structured query statements, the accuracy of query statements constructed using Structured Query Language (SQL) is crucial. Currently, error detection for SQL statements relies primarily on standard test answers (GTs). Without accurate GTs, it is difficult to accurately identify potential errors in SQL statements. Summary of the Invention
[0003] In view of this, the present invention provides a method, apparatus, device and storage medium for error identification of structured query statements to solve the problem of difficulty in accurately identifying errors in SQL statements.
[0004] In a first aspect, the present invention provides a method for identifying errors in structured query statements, comprising: obtaining the query intent of a target object and a structured query statement generated based on the query intent; extracting the intent test points of the query intent and the query test points of the structured query statement; using a pre-constructed test point mapping relationship to perform test point matching on the intent test points and the query test points, and identifying target error information in the structured query based on the test point matching results; wherein the test point mapping relationship is generated based on the correspondence between the intent test points and the structured query statement test points.
[0005] In the second aspect, the present invention provides an error recognition device for structured query statements, including: an acquisition module for acquiring the query intent of a target object and a structured query statement generated for the query intent; an extraction module for extracting the intention test points of the query intent and the query test points of the structured query statement; an error recognition module for using a pre-built test point mapping relationship to match the intention test points and the query test points, and based on the test point matching results, identifying the target error information in the structured query; wherein the test point mapping relationship is generated based on the correspondence between the intention test points and the structured query statement test points.
[0006] In a third aspect, the present invention provides a computer device comprising: a memory and a processor, the memory and the processor being communicatively connected to each other, the memory storing computer instructions, and the processor executing the error identification method for structured query statements of the first aspect or any corresponding embodiment thereof by executing the computer instructions.
[0007] In a fourth aspect, the present invention provides a computer-readable storage medium having computer instructions stored thereon, the computer instructions being used to enable a computer to execute the error identification method for structured query statements according to the first aspect or any corresponding embodiment thereof.
[0008] In a fifth aspect, the present invention provides a computer program product comprising computer instructions, wherein the computer instructions are used to enable a computer to execute the error identification method for structured query statements according to the first aspect or any corresponding embodiment thereof.
[0009] The error recognition method, device, equipment and storage medium for structured query statements provided by the embodiments of the present invention extract the intention test points corresponding to the query intent and the query test points corresponding to the structured query statement, and use the test point mapping relationship between the intention test points and the query test points to match the intention test points and the query test points, and identify the error information hidden in the structured query statement through the test point matching results. Thus, by matching the intention test points with the query test points, accurate identification of error information can be achieved without relying on standard answers, which can meet the error recognition scenarios of structured query statements in the absence of reference answers. Combined with the test point matching results, it can more accurately judge whether the generated structured query statement meets the query intent of the target object, thereby effectively improving the accuracy of error detection, reducing misjudgments and missed judgments, and improving the comprehensiveness of error recognition. BRIEF DESCRIPTION OF THE DRAWINGS
[0010] In order to more clearly illustrate the specific embodiments of the present invention or the technical solutions in related technologies, the following briefly introduces the drawings required for use in the specific embodiments or related technical descriptions. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0011] Figure 1 is a schematic diagram of an application scenario according to an embodiment of the present invention;
[0012] Figure 2 is a flow chart of a method for identifying errors in structured query statements according to an embodiment of the present invention;
[0013] Figure 3 is a flow chart of another method for identifying errors in structured query statements according to an embodiment of the present invention;
[0014] Figure 4 is a flow chart of another method for identifying errors in structured query statements according to an embodiment of the present invention;
[0015] Figure 5is a structural block diagram of an apparatus for identifying errors in structured query statements according to an embodiment of the present invention;
[0016] Figure 6 2 is a schematic diagram of the hardware structure of a computer device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0017] To make the purpose, technical solutions, and advantages of the embodiments of the present invention more clear, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without making creative efforts shall fall within the scope of protection of the present invention.
[0018] It is understandable that before using the technical solutions disclosed in the various embodiments of this disclosure, the type, scope of use, usage scenarios, etc. of the personal information involved in this disclosure should be informed to the user and the user's authorization should be obtained in an appropriate manner in accordance with relevant laws and regulations.
[0019] For example, in response to a user's active request, a prompt message is sent to the user to clearly inform the user that the operation requested will require the acquisition and use of the user's personal information. This allows the user to independently choose whether to provide personal information to the computer device, application, server, storage medium, or other software or hardware that performs the operation of the disclosed technical solution based on the prompt message.
[0020] As an optional but non-limiting implementation, in response to receiving a user's active request, the prompt information may be sent to the user in the form of a pop-up window, in which the prompt information may be presented in text form. Furthermore, the pop-up window may also contain a selection control for the user to select "agree" or "disagree" to provide personal information to the computer device.
[0021] It is understandable that the above notification and user authorization process are merely illustrative and do not limit the implementation of the present disclosure. Other methods that comply with relevant laws and regulations may also be applied to the implementation of the present disclosure.
[0022] It is understandable that the data involved in this technical solution (including but not limited to the data itself, the acquisition or use of the data) must comply with the requirements of relevant laws, regulations and relevant provisions.
[0023] SQL statement errors can manifest in a wide variety of forms, and current detection methods primarily include string matching and execution accuracy matching. However, string matching focuses solely on the textual form of SQL statements, making it difficult to detect errors involving deeper semantics, logic, and other issues. For example, SQL statements with the same functionality but slightly different written formats may be misjudged as errors. Execution accuracy matching relies on actual execution results, making it difficult to provide early warnings for potential logical errors and performance risks. Furthermore, both string matching and execution accuracy matching methods are highly dependent on reference standard answers (GTs). This means that in the absence of accurate GTs, the reliability of current detection methods is significantly compromised, making it difficult to meet the demands of complex and ever-changing SQL environments.
[0024] Based on this, the disclosed technical solution meticulously examines the user's query intent and the key points in the generated SQL statements, leveraging the semantic understanding and pattern recognition capabilities of a large language model to deeply uncover potential errors in SQL statements, significantly improving the comprehensiveness and accuracy of SQL error detection. This enables accurate error identification without relying on GT, overcoming the limitations of error identification in related technologies.
[0025] As an optional application scenario of the embodiment of the present invention, Figure 1 As shown, the application scenario includes test point extraction, test point relationship mapping, and error type labeling. For the extraction of intent test points, the intent test point set can be used to pre-train the corresponding intent test point extraction model, and the intent test point extraction task can be constructed through the intent test point extraction model to extract the intent test points in the query intent; for the extraction of SQL test points, the SQL test point set can be used to pre-train the corresponding SQL test point extraction model, and the SQL test point extraction task can be constructed through the SQL test point extraction model to extract the SQL test points in the SQL statement. For test point relationship mapping, the target object can pre-construct the mapping relationship between intent test points and SQL test points, and determine the test point intersection and test point difference set between intent test points and SQL test points. For error type labeling, the test point intersection and test point difference set can be used to pre-train the corresponding error recognition model, and the error type of the generated SQL statement can be labeled through the error recognition model to obtain the corresponding error recognition information.
[0026] Specifically, the intent test point extraction model, the SQL test point extraction model and the error recognition model can be independently deployed in a computer device, or they can be cascaded into a code generation model and deployed in a computer device.
[0027] Here, a computer device refers to a device that has computing resources or computing capabilities and can be a device with computing capabilities. For example, a computer device can be provided with a processor and memory, or can be equipped with a dedicated accelerator (such as a graphics processing unit (GPU)). In addition, a computer device can store and maintain data.
[0028] Examples of computer devices may include supercomputers, personal computers, laptop computers, vehicle-mounted computing devices, mobile devices (such as smartphones, tablet computers, etc.), or a combination of any one or more of the above devices. It should be understood that the computer devices described herein are merely exemplary and non-limiting, and for example, other different types of computer devices may also be used.
[0029] According to an embodiment of the present invention, an embodiment of a method for identifying errors in structured query statements is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0030] In this embodiment, a method for identifying errors in structured query statements is provided, which can be used on computer devices such as computers, laptops, tablet computers, etc. Figure 2 FIG. 1 is a flow chart of a method for identifying errors in structured query statements according to an embodiment of the present invention. Figure 2 As shown, the process includes the following steps:
[0031] Step S201: Obtain the query intent of the target object and a structured query statement generated based on the query intent.
[0032] Query intent represents the target object's operation to retrieve data from the database; structured query statements are SQL statements generated by semantically understanding the query intent and combining the results of semantic understanding. Specifically, a code generation model is deployed in the computer device, and this code generation model has a corresponding interactive page. The target object can enter the query intent in the interactive page according to actual needs, such as "What is the average daily raw call tier of XX in the past seven days?" or "What is the raw call volume of the code generation model in the past three days?" The code generation model can then parse the semantics represented by the query intent and generate structured query statements based on the semantics represented by the query intent.
[0033] Step S202: extract the intent test points of the query intention and the query test points of the structured query statement.
[0034] Intent test points represent the query keywords carried in the query intent. These intent test points may include relative dates, absolute dates, public holidays, promotions, year-on-year growth, month-on-month growth, proportions, conditional filtering, grouping, segmented statistics / hierarchical analysis of indicator values, value mapping, extreme values, TopN, sorting, indicator query - mean, indicator query - count, indicator query - deduplication, indicator query - median / XX quantile, indicator query - mode, indicator query - variance / standard deviation, indicator query - difference, indicator query - sum, indicator query - simple indicator, and dimension query.
[0035] Specifically, semantic understanding is performed on the query intent of the target object to extract intention test points from the query intent that are both comprehensive and can accurately reflect the core query demands, and the intention test points are expressed in a specific form, such as "test point: keyword".
[0036] Query test points refer to the query keywords carried in the structured query statement. The query test points may include: lateral view, join, cube, grouping sets, distribute by, union, partition by, subquery, group by, order, limit, conditional filtering, specific time, time function, regular screening, regular replacement, regular extraction, quantile function, json function, map function, array function", "window function, string function, split, cast, conditional judgment, aggregation function, simple function, incremental comparison, currency conversion, storage conversion, ratio conversion, time conversion, caliber definition, column aggregation, row aggregation, month-on-month comparison, retention, sampling, deduplication, average, count, sum, maximum and minimum values, etc.
[0037] Specifically, the grammatical structure and semantic logic of the structured query statement are analyzed to accurately locate and extract the key operations, data references, logical judgments, etc. contained in the structured query statement, and the query test points are represented in a specific form, such as "test point: SQL fragment".
[0038] Step S203 , using the pre-built test point mapping relationship, perform test point matching on the intended test points and the query test points, and identify target error information in the structured query based on the test point matching result.
[0039] Among them, the test point mapping relationship is generated based on the correspondence between the intention test points and the structured query statement test points.
[0040] The test point matching result is used to characterize the matching relationship between the intended test point and the query test point; the target error information is used to characterize the errors in the structured query statement, including the error type (such as syntax error, semantic error, logical error), error location, etc.
[0041] In order to accurately match the query intent of the target object with the structured query statement, the intent test points corresponding to the query intent and the query test points corresponding to the structured query statement are matched according to the test point mapping relationship to obtain the corresponding test point matching results. For example, "total sales" is accurately mapped to the specific field total_sales in the structured query statement.
[0042] Based on the test point matching results between the intent test points and the query test points, the semantic association between the intent test points and the query test points is analyzed. Based on the semantic association relationship, the generated structured query statement is determined to determine whether it can achieve the query intent of the target object. If the structured query statement does not exactly match the query intent, the target error information in the structured query statement is identified based on the test point matching results.
[0043] The error recognition method for structured query statements provided in this embodiment extracts the intent test points corresponding to the query intent and the query test points corresponding to the structured query statement, and uses the test point mapping relationship between the intent test points and the query test points to match the intent test points with the query test points. The error information hidden in the structured query statement is identified through the test point matching results. Thus, by matching the intent test points with the query test points, accurate identification of error information can be achieved without relying on standard answers. This can meet the error recognition scenarios of structured query statements in the absence of reference answers. Combined with the test point matching results, it can more accurately determine whether the generated structured query statement meets the query intent of the target object, thereby effectively improving the accuracy of error detection, reducing misjudgments and missed judgments, and improving the comprehensiveness of error recognition.
[0044] In this embodiment, a method for identifying errors in structured query statements is provided, which can be used on computer devices such as computers, laptops, tablet computers, etc. Figure 3 FIG. 1 is a flow chart of a method for identifying errors in structured query statements according to an embodiment of the present invention. Figure 3 As shown, the process includes the following steps:
[0045] Step S301: Obtain the query intent of the target object and the structured query statement generated based on the query intent. Please refer to the description of the corresponding steps in the above embodiment for details, which will not be repeated here.
[0046] Step S302: extract the intent test points of the query intention and the query test points of the structured query statement.
[0047] Specifically, the above step S302 includes:
[0048] Step S3021, obtain the intention test point set and the first prompt description information corresponding to the query intention.
[0049] The intent test point set is a collection of test points derived from analyzing and summarizing query intent in the SQL domain. Specifically, this intent test point set can be extracted from public datasets, from test point datasets corresponding to open source models, or by annotating intents and key points using annotation tools or manually collected data. The method for obtaining the intent test point set is not specifically limited here, and those skilled in the art can determine it based on actual needs.
[0050] The first prompt description information is prompt information for marking the intended test points. The first prompt description information is set according to the specific business scenario of test point marking. Specifically, the first prompt description information includes prompt word parameter information, model input parameters, model output parameters, etc.
[0051] The prompt word parameter information is parameter information obtained by abstractly designing the model role, the definition of the intended test point, etc. In a specific example, the prompt word parameter information is set as follows:
[0052] {system_role} #role definition for large model
[0053] {intent_point_define} #intent point definition
[0054] Model input parameters are mainly customized parameters for the business scenario of the target object's query intent, such as business knowledge, blacklisting definitions, etc. In a specific example, the model input parameters are set as follows:
[0055] {query}#Enter user question
[0056] {inspection_point}#Inspect special business knowledge, jargon, etc.
[0057] The model output parameters are used to set the output format of the intent test point. In a specific example, the model input parameters are set as follows:
[0058] [{"Exam point 1":"Keyword 1"},{"Exam point 2":"Keyword 2"},{"Exam point 3":"Keyword 3"},{"Exam point 4":"Keyword 4"}]# Output format list
[0059] Output description:
[0060] - Identify test information and keywords in corresponding questions based on the target object’s query intent
[0061] - If multiple values are identified, store them in a list with {"key":"value"}
[0062] -Answer in Chinese.
[0063] The prompt word parameter information, model input parameters, and model output parameters are concatenated to obtain the complete first prompt description information, namely:
[0064] prompt="""
[0065] {system_role} #role definition for large model
[0066] {intent_point_define} #intent point definition
[0067] [{"Exam point 1":"Keyword 1"},{"Exam point 2":"Keyword 2"},{"Exam point 3":"Keyword 3"},{"Exam point 4":"Keyword 4"}]# Output format list
[0068] Output description:
[0069] - Identify test information and keywords in corresponding questions based on the target object’s query intent
[0070] - If multiple values are identified, store them in a list with {"key":"value"}
[0071] -Answer in Chinese
[0072] {query}#Enter user question
[0073] {inspection_point}#Inspection of special business knowledge, jargon, etc.
[0074] """.
[0075] Step S3022: Use the first prompt description information to guide the pre-trained first test point labeling model to extract the intent test points corresponding to the query intent from the intent test point set.
[0076] The first test point model is a model that has the ability to understand the intent and label test points based on the query intent. Specifically, this first test point labeling model is trained based on the model architecture of the large language model, and the first test point model can be continuously tuned to achieve better labeling results.
[0077] The query intent of the target object is input into the first test point labeling model, and the first prompt description information is used to guide the test point labeling process of the first test point labeling model. The first test point labeling model can parse the query intent according to the first prompt description information, and perform semantic understanding of the query intent to extract the intent test points corresponding to the query intent from the intent test point set.
[0078] Step S3023: Obtain a structured query statement test point set, where the structured query statement test points are determined based on the node information of the structured query statement.
[0079] A structured query statement test point set is a collection of test points derived from analyzing and summarizing the node information corresponding to the grammatical structure and data manipulation language within the SQL domain. Specifically, this structured query statement test point set can be extracted from a public dataset, an online test dataset, or determined by accessing an open dataset containing structured query statements. The method for obtaining the structured query statement test point set is not specifically limited herein and can be determined by those skilled in the art based on actual needs.
[0080] Step S3024: parse the grammatical structure of the structured query statement to obtain an abstract syntax tree structure corresponding to the structured query statement.
[0081] An Abstract Syntax Tree (AST) is a data structure generated during the parsing of a structured query. This AST represents the grammatical structure of the structured query in the form of a tree. Specifically, a lexical analysis is performed on the structured query, breaking it down into a series of tokens to identify keywords, identifiers, numbers, strings, operators, and other elements within the query. Syntax analysis is then performed based on the lexical analysis results. The token sequence generated by the lexical analysis is converted into an AST structure according to the grammatical rules of the structured query.
[0082] Step S3025 , extracting query test points corresponding to the structured query statement from the structured query statement test point set according to the abstract syntax tree structure.
[0083] According to the node information in the abstract syntax tree structure and the test point definition for the query test point, the structured query statement is marked with test points, the corresponding code snippet in the structured query statement is located, the code snippet is matched with the structured query statement test point set, and the query test point corresponding to the structured query statement is extracted from the structured query statement test point set.
[0084] In a specific example, if the structured query SQL statement is: SELECT `month`, SUM(`gross profit`) FROM dataset WHERE `year` = '2023' AND `region` = 'Eastern District' GROUP BY `month`. The marking process for the query test point is: according to the group by node marking, the code snippet "GROUP BY `month`" is obtained; according to the where node marking, the code snippet "WHERE `year` = '2023' AND `region` = 'Eastern District'" is obtained; according to the SUM node marking, the code snippet "SUM(`gross profit`)" is obtained. The structured query statement is converted into an abstract syntax tree structure, and the corresponding SQL code snippet is accurately located according to the SQL node information in the abstract syntax tree structure, as follows:
[0085] (SELECT expressions:
[0086] (COLUMN this:
[0087] (IDENTIFIER this:month,quoted:True)),
[0088] (SUM this: #aggregation function, sum
[0089] (COLUMN this:
[0090] (IDENTIFIER this:gross profit,quoted:True))),from:
[0091] (FROM this:
[0092] (TABLE this:
[0093] (IDENTIFIER this:dataset,quoted:False))),where:
[0094] (WHERE this:#conditional filtering
[0095] (AND this:
[0096] (EQ this:
[0097] (COLUMN this:
[0098] (IDENTIFIER this:year,quoted:True)),expression:
[0099] (LITERAL this:2023,is_string:True)),expression:
[0100] (EQ this:
[0101] (COLUMN this:
[0102] (IDENTIFIER this:area,quoted:True)),expression:
[0103] (LITERAL this:Eastern District,is_string:True)))),group:
[0104] (GROUP expressions:#group by
[0105] (COLUMN this:
[0106] (IDENTIFIER this:month,quoted:True)))).
[0107] Thus, the marking result of the query test point can be obtained as follows: [{"group by":"GROUP BY`month`"},{"condition filtering":"WHERE`year`='2023'AND`region`='East District'"},{"aggregate function":"SUM(`gross profit`)"},{"sum":"SUM(`gross profit`)"}].
[0108] In some complex query intents, the writing of the structured query statement SQL generated for the query intent will be very complicated. At this time, the test point labeling based on the abstract syntax tree structure may have certain limitations, and it is difficult to avoid omissions in the test point labeling. At this time, a model can be introduced to recall the test point labels of the structured query statement SQL to ensure the comprehensiveness and accuracy of the recall of the query test points.
[0109] Accordingly, in some optional implementations, the above step S302 may further include:
[0110] Step S3026: Obtain second prompt description information corresponding to the structured query statement.
[0111] The second prompt description information is prompt information for marking test points for the structured query statement, and the second prompt description information is set according to the query target of the structured query statement. Specifically, the second prompt description information includes prompt word parameter information, model input parameters, model output parameters, etc.
[0112] The prompt word parameter information is parameter information obtained by abstractly designing the model role, query test point definition, etc. In a specific example, the prompt word parameter information is set as follows:
[0113] {system_role} #role definition of the model
[0114] {intent_point_define} #SQL test point definition
[0115] Model input parameters are mainly customized parameters for the business scenario of the query intent, such as business knowledge, blacklisting definitions, etc. In a specific example, the model input parameters are set as follows:
[0116] {query}#Enter user question
[0117] {labeled_point}# Pass the identified test points and code snippets to the model to enable the model to better recall unrecognized test points
[0118] {inspection_point}#Inspect special business knowledge, jargon, etc.
[0119] Model output parameters are used to set the output format of the query test point. In a specific example, the model input parameters are set as follows:
[0120] [{"Exam point 1":"Code snippet 1"},{"Exam point 2":"Code snippet 2"},{"Exam point 3":"Code snippet 3"},{"Exam point 4":"Code snippet 4"}]#Output format list
[0121] Output description:
[0122] -Identify test point information and corresponding keywords based on query intent
[0123] - If multiple values are identified, store them in a list with {"key":"value"}
[0124] -Answer in Chinese.
[0125] The prompt word parameter information, model input parameters, and model output parameters are concatenated to obtain the complete first prompt description information, namely:
[0126] prompt="""
[0127] {system_role} #role definition for large model
[0128] {intent_point_define} #intent point definition
[0129] [{"Exam point 1":"Code snippet 1"},{"Exam point 2":"Code snippet 2"},{"Exam point 3":"Code snippet 3"},{"Exam point 4":"Code snippet 4"}]#Output format list
[0130] Output description:
[0131] - Identify test information and keywords in corresponding questions based on the target object’s query intent
[0132] - If multiple values are identified, store them in a list with {"key":"value"}
[0133] -Answer in Chinese
[0134] {query}#Enter user question
[0135] {labeled_point}# Input the recognized test points and code snippets into the model to help the model better recall the unrecognized test points
[0136] {inspection_point}#Inspection of special business knowledge, jargon, etc.
[0137] """.
[0138] Step S3027: Use the second prompt description information to guide the pre-trained second test point labeling model to extract the query test points corresponding to the structured query statement from the structured query statement test point set.
[0139] The second test point model is a model that has the ability to understand intent and label test points for structured query statements. Specifically, this second test point labeling model is trained based on the model architecture of the large language model and can be continuously tuned to achieve better labeling results.
[0140] The structured query statement is input into the second test point labeling model, and the second prompt description information is used to guide the test point labeling process of the second test point labeling model. The second test point labeling model can parse the structured query statement according to the second prompt description information, and perform semantic understanding of the structured query statement to extract the query test points corresponding to the structured query statement from the structured query statement test point set.
[0141] It should be noted that the first test point marking model and the second test point marking model can be two marking sub-models corresponding to the code generation model, that is, the first test point marking model corresponds to the intention test point marking task of the code generation model, and the second test point marking model corresponds to the query test point marking task of the code generation model; the first test point marking model and the second test point marking model can also be two independent marking models, which are not specifically limited here and can be determined according to actual needs.
[0142] In a specific example, if the query intent is "What is the average daily original call tier of XX in the past 7 days?", the structured query SQL statement generated for this query intent is: WITH Recent7DaysData AS(SELECT `sales name`, SUM(`original call volume`) AS total_original_calls, COUNT(DISTINCT `call date`) AS unique_days FROM TAB WHERE `call date` BETWEEN CAST('2024-12-13' AS DATE) AND CAST('2024-12-19' AS DATE) AND `sales name` = 'XX' GROUP BY `sales name`), DailyAverage AS(SELECT `sales name`, total_original_calls / unique_days AS daily_avg_original_calls FROM Recent7DaysData) SELECT `sales name`, daily_avg_original_calls, CASE WHEN daily_avg_original_calls>100000000 THEN 'Above 100 million' WHEN daily_avg_original_calls>=1000000 THEN '1 million - 100 million' ELSE 'Below 1 million' END AS Bin FROM DailyAverage.
[0143] The test point marking result of using abstract syntax tree to query test points is: [{"group by":"GROUP BY`Sales Name`"},{"Condition filtering":"WHERE`Call date`BETWEEN CAST('2024-12-13'AS DATE)ANDCAST('2024-12-19'AS DATE)AND`Sales Name`='XX'"},{"Specific time":"`Call date`BETWEENCAST('2024-12-13'AS DATE)AND CAST('2024-12-19'AS DATE)"},{"Sum":"SUM(`Original call volume`)"},{"Count":"COUNT(DISTINCT`Call date`)"}].
[0144] By matching the test point marking results of the query test point with the intended test point of the query intent, it can be determined that the currently unrecalled query test point is: {"Conditional judgment":"CASE WHEN daily_avg_original_calls>100000000THEN'More than 100 million'WHEN daily_avg_original_calls>=1000000THEN'1 million - 100 million'ELSE'Less than 1 million'END AS bin"}.
[0145] At this point, the second test point labeling model can be used to make up for the problem of insufficient abstract syntax tree labeling capabilities. The prompt description information corresponding to the structured query statement can be used to guide the second test point labeling model to label the structured query statement, and extract the unrecalled query test points from the structured query statement: {"Condition judgment":"CASE WHEN daily_avg_original_calls>100000000THEN'more than 100 million'WHEN daily_avg_original_calls>=1000000THEN'1 million-100 million'ELSE'less than 1 million'END AS bin"}.
[0146] In step S303, the pre-established test point mapping relationship is used to match the intended test points with the query test points. Based on the test point matching results, the target error information in the structured query is identified. The test point mapping relationship is generated based on the correspondence between the intended test points and the test points in the structured query statement. For details, please refer to the description of the corresponding steps in the above-described embodiment and will not be repeated here.
[0147] The error identification method for structured query statements provided in this embodiment sets prompt description information to guide the first test point labeling model to label the query intent test points. This allows the first test point labeling model to perform semantic understanding and analysis of the query intent, ensuring that the extraction of the test points can comprehensively and accurately reflect the core query requirements of the target object. Combining the abstract syntax tree structure and the second test point labeling model to label the query test points of the generated structured query statement can deeply understand the grammatical structure and semantic logic of the structured query statement, thereby accurately locating and extracting the query test points carried in the structured query statement.
[0148] In this embodiment, a method for identifying errors in structured query statements is provided, which can be used on computer devices such as computers, laptops, tablet computers, etc. Figure 4 FIG. 1 is a flow chart of a method for identifying errors in structured query statements according to an embodiment of the present invention. Figure 4 As shown, the process includes the following steps:
[0149] Step S401: Obtain the query intent of the target object and the structured query statement generated based on the query intent. Please refer to the description of the corresponding steps in the above embodiment for details, which will not be repeated here.
[0150] Step S402: extracting the query intention test points and the query test points of the structured query statement. Please refer to the description of the corresponding steps in the above embodiment for details, which will not be repeated here.
[0151] Step S403: Use the pre-built test point mapping relationship to match the intended test points with the query test points, and identify the target error information in the structured query based on the test point matching results. The test point mapping relationship is generated based on the correspondence between the intended test points and the test points in the structured query statement.
[0152] Specifically, the above step S403 includes:
[0153] Step S4031: Match the intended test points and the query test points based on the test point mapping relationship to obtain a matched test point set and an unmatched test point set.
[0154] The matched test point set is the set of test points that are successfully matched with the intended test points and the query test points, that is, the test point intersection of the intended test points and the query test points; the unmatched test point set is the test point difference set between the intended test points and the query test points, including the intended test points that are not matched with the query test points and the query test points that are not matched with the intended test points.
[0155] According to the established test point mapping relationship, the intended test points and the query test points are matched to determine the test point intersection and test point difference set. The test point intersection is determined as the matched test point set, and the test point difference set is determined as the unmatched test point set.
[0156] Step S4032: Use the matching test point set to perform error identification on the structured query statement and generate first error identification information.
[0157] The first error identification information is used to characterize whether the intention test point and the query test point are completely consistent in semantic expression. Specifically, the intention test point and the query test point that are successfully matched are used as test point inspection items, and the test point inspection items are used to perform error identification on the structured query statement to determine whether the intention test point and the query test point are consistent in semantic expression. If it is determined that the intention test point and the query test point are consistent in semantic expression, it is determined that there is no error in the structured query statement; if it is determined that the intention test point and the query test point are inconsistent in semantic expression, it is determined that there is an error in the structured query statement, and the corresponding first error identification information is generated.
[0158] Step S4033: Use the unmatched test point set to perform error recognition on the structured query statement to generate second error recognition information.
[0159] The second error identification information is used to represent the error information corresponding to the unsuccessfully matched test points, including error comments, error types, and error locations. Specifically, the unmatched intent test points and query test points are used as key inspection items, and the structured query statement is inspected using these key inspection items to identify the test points missed by the structured query language. Error identification is performed on the structured query statement based on the missed test points, and error identification information such as error comments, error types, and error locations present in the structured query statement is determined.
[0160] Step S4034: Generate target error information of the structured query statement based on the fusion result of the first error recognition information and the second error recognition information.
[0161] The first error identification information and the second error identification information are fused to obtain the corresponding target error information. In a specific example, if the test point marking result of the intended test point is: [{"Relative Date":"Last Three Days"}, {"Conditional Filter":"MM Model"}, {"Indicator Query-Sum":"Original Call Volume"}]; the test point marking result of the query test point is: [{"Conditional Filter":"where`Call Date`>=CURRENT_DAY-3'day'and`Model Type`='MM'"}, {"Time Function":"`Call Date`>=CURRENT_DAY–3'day'"}]; the matching test point set is: intent_union_sql, that is, ["Relative Date","Conditional Filter"]; the unmatched test point set is: intent_diff_sql and sql_diff_intent, that is, ["Indicator Query-Sum"] and []. Combining the matched test point set and the unmatched test point set for error identification, the corresponding target error identification information is: {"result":"false","errorinfo":"Aggregation function error: The aggregation function is missing and the original call volume is not aggregated","errortype":"Aggregation function error","errorinserted":"SELECT`Original call volume`from table where`Call date`=CURRENT_DAY-1'day' / *Aggregation function error: According to the query intention, the original call volume needs to be aggregated, but the original call volume is not SUM aggregated in SQL* / "}.
[0162] The error recognition method for structured query statements provided in this embodiment, combined with the test point matching results of the intended test points and the query test points, can determine the set of successfully matched matching test points and the set of unmatched test points that were not successfully matched. The matching test point set and the unmatched test point set are used to perform corresponding error recognition, and the corresponding error recognition information is obtained. The target error information can be obtained by fusing the various error recognition information. As a result, there is no need to rely on reference standard answers, which reduces the dependence on reference standard answers and the preparation time. It can quickly perform error detection on a large number of structured query statements in combination with the test point matching results, greatly improving the detection efficiency and meeting the efficiency requirements in practical applications.
[0163] In some optional implementations, the mapping relationship includes a first mapping relationship, which represents the test point association relationship between the intended test point and the structured query statement test point. Accordingly, constructing the mapping relationship between the intended test point and the structured query statement test point includes:
[0164] Step a1: Obtain at least one structured query statement test point corresponding to each intention test point.
[0165] Step a2: semantically associate the intention test point and each corresponding structured query statement test point to obtain a first mapping relationship between the intention test point and the structured query statement test point.
[0166] Due to the complexity of intent points and the limitations of structured query statement points, not all intent points corresponding to query intent necessarily have corresponding structured query statement points. Therefore, for any intent point, it is necessary to determine one or more corresponding structured query statement points. For any intent point, a semantic association is established between the intent point and its corresponding structured query statement point, generating a mapping relationship between the intent point and its structured query statement point.
[0167] In a specific example, the first mapping relationship can be expressed as:
[0168] intent_union_sql={
[0169] 'Relative date':["time function","specific time","time conversion"],
[0170] 'Absolute date':["time function","specific time","time conversion"],
[0171] 'Public Holiday':["Time Function","Specific Time","Time Conversion"],
[0172] 'Big promotion': ["time function", "specific time", "time conversion"],
[0173] 'Year-on-year':["Month-on-month",],
[0174] 'Mono-month':["Mono-month",],
[0175] 'Proportion': ["Incremental comparison", "Ratio conversion", "Caliber definition"],
[0176] 'Conditional Filter': ["Conditional Filter"],
[0177] 'Grouping':["grouping sets","group by"],
[0178] 'Extreme value': ["maximum and minimum value"],
[0179] 'TopN':["limit"],
[0180] 'Sorting':["order"],
[0181] 'Indicator query-sum': ["sum", "count"],
[0182] 'Indicator query-mean': ["average"],
[0183] 'Indicator Query-Count':["Sum","Count"],
[0184] 'Indicator Query-Duplicate Removal': ["Duplicate Removal"],
[0185] 'Indicator Query - Median / XX Percentile': ["Percentile Function", "Partition by"],
[0186] 'Statistics / stratified analysis by indicator value':["conditional judgment"]}.
[0187] The error identification method for structured query statements provided in this embodiment combines the semantic correspondence between natural language and SQL language to construct an association between intent test points and query test points, ensuring that the query intent and structured query statement can be accurately matched, making it easier to more accurately determine whether the structured query statement meets the query intent of the target object, and providing a basis for subsequent error detection.
[0188] In some optional implementations, the mapping relationship includes a second mapping relationship and a third mapping relationship. The second mapping relationship indicates that the intended test point is not in the structured query statement test point; the third mapping relationship indicates that the structured query statement test point marks the test point that does not exist in the intended test point.
[0189] Accordingly, a mapping relationship between the intent test points and the structured query statement test points is constructed, including:
[0190] Step b1: for the target intent test points that are not matched with the structured query statement test points in the intent test points, a second mapping relationship corresponding to the target intent test points is constructed.
[0191] Step b2: for the target query test points that are not matched with the intended test points in the structured query statement test points, a third mapping relationship corresponding to the target query test points is constructed.
[0192] Cross-compare the intent test points with the structured query test points, remove the intent test points that have been successfully matched to the structured query test points from the intent test points, obtain the corresponding target intent test points, and construct a separate mapping relationship for the target intent test points. In a specific example, the second mapping relationship can be expressed as:
[0193] intent_diff_sql = ["Indicator Value Segment Statistics / Hierarchical Analysis", "Value Mapping", "Indicator Query - Mode", "Indicator Query - Variance / Standard Deviation", "Indicator Query - Simple Indicator", "Dimension Query"].
[0194] Cross-compare the intent test points with the structured query test points, remove the structured query test points that have successfully matched the intent test points from the structured query test points, obtain the corresponding target query test points, and construct a separate mapping relationship for the target query test points. In a specific example, the third mapping relationship can be expressed as:
[0195] sql_diff_intent = ["lateral view", "join", "cube", "distribute by", "union", "subquery", "regular filter", "regular replace", "regular extract", "json function", "map function", "array function", "window function", "string function", "split", "cast", "aggregate function", "simple function", "currency conversion", "storage conversion", "column aggregation", "row aggregation", "retention", "sampling"].
[0196] It should be noted that the second mapping relationship and the third mapping relationship are used to represent that there is no test point association between the intended test point and the structured query statement test point, that is, there is no test point mapping between the intended test point and the structured query statement test point.
[0197] The error recognition method for structured query statements provided in this embodiment establishes a comprehensive mapping relationship between intended test points and query test points by setting a reasonable mapping mechanism, thereby ensuring the accuracy of subsequent error recognition.
[0198] In some optional implementations, generating the first error identification information and the second error identification information includes:
[0199] Step c1, obtaining third prompt description information for test site matching check.
[0200] Step c2: using the third prompt description information to guide the pre-trained error recognition model to perform error recognition on the structured query, and generating first error recognition information and second error recognition information.
[0201] The third prompt description information is prompt information for error recognition of structured query statements using the intention test points and query test points as inspection items. Specifically, the third prompt description information includes prompt word parameter information, model input parameters, and model output parameters. Among them, the prompt word parameter information uses the intention test points and query test points as inspection items to better identify errors in structured query statements and improve the inspection effect of the error types of structured query statements; the model input parameters are mainly customized for error recognition; the model output parameters are used to set the output form of the error recognition information. In a specific example, the setting of the third prompt description information is as follows:
[0202] dataset_critic_prompt="""
[0203] {task_information} #role definition;
[0204] {notice_point} #Note;
[0205] Output format:
[0206] {"result":"","errorinfo":"","errortype":"","errorinserted":""}
[0207] Output description:
[0208] -result is true if the NL2SQL task is successful, false if it is an error;
[0209] When -result is false, errorinfo is a detailed error comment. There may be more than one error, so each error comment needs to be given;
[0210] When -result is false, errortype is the error type. You can only select one or more from the provided list:
[0211] {mistake_taxonomies} # Check the error type list;
[0212] When -result is false, errorinserted is the specific SQL error location;
[0213] {errortype_explaination} #Error type definition;
[0214] {inspection_point} #General inspection item;
[0215] {intent_union_sql}#Query the intersection of intent test points and SQL test points, which can be used for simple checks;
[0216] {intent_diff_sql}#SQL test points are missed and key points are checked;
[0217] {sql_diff_intent}#SQL test point misidentification, do key inspection;
[0218] {task_comment}#Task description: Such as single-round task of NLP dataset;
[0219] {schema}#table structure;
[0220] {history_query}#Historical user questions: only for multi-round conversations;
[0221] {timeinfo}#User inquires about time;
[0222] {query}#User question;
[0223] {pred_sql} #SQL to be marked.
[0224] The error recognition model is a model that has the ability to understand intent and identify errors. Specifically, the error recognition model is trained based on the model architecture of the large language model, and can be continuously tuned to achieve better error recognition results.
[0225] A structured query statement generated based on the query intent is input into the error recognition model, and the third prompt description information is used to guide the error recognition process of the error recognition model. The error recognition model can parse the structured query statement according to the third prompt description information, perform error recognition on the structured query statement according to the matching test point set, identify corresponding first error recognition information from the structured query statement, and perform error recognition on the structured query statement according to the unmatched test point set, and identify corresponding second error recognition information from the structured query statement.
[0226] It should be noted that the first test point marking model, the second test point marking model and the error recognition model can be sub-models corresponding to the code generation model, that is, the first test point marking model corresponds to the intention test point marking task of the code generation model, and the second test point marking model corresponds to the query test point marking task of the code generation model; the error recognition model corresponds to the error recognition task of the code generation model; the first test point marking model, the second test point marking model and the error recognition model can also be three independent models, which are not specifically limited here and can be determined according to actual needs.
[0227] The error recognition method for structured query statements provided in this embodiment combines test point matching results with the semantic understanding and analysis capabilities of the error recognition model to perform error recognition on generated structured query statements. This method not only detects common syntactic errors but also deeply identifies semantic and logical errors, breaking through the limitation of only detecting surface errors and greatly expanding the error detection scope of structured query statements. Furthermore, by utilizing the error recognition model for error checking and fine-tuning and prompt engineering optimization, the error recognition model possesses intelligent error recognition capabilities. It can intelligently analyze and determine error types based on different structured query scenarios and user query requirements, generating more targeted error prompts and improvement suggestions, thereby enhancing the intelligent error detection of structured query statements.
[0228] As a specific application embodiment of the present invention, if the query intent of the target object is: what is the original call volume of the MM model in the past N days; generate a corresponding structured query statement for the query intent: SELECT `original call volume` from table where `call date` > = CURRENT_DAY-3'day' and `model type` = 'MM'; the table structure is: name, field type, enumeration value (optional) `original call volume`, int, `paid call volume`, int, `model type`, string, `call date`, date.
[0229] The query intent is marked with test points, and the test points are: [{"Relative date":"Recent N days"},{"Condition filtering":"MM model"},{"Indicator query-sum":"Original call volume"}].
[0230] The test points of the structured query statement are marked, and the query test points are obtained: [{"condition filtering":"where`call date`>=CURRENT_DAY-N'day'and`model type`='MM'"},{"time function":"`call date`>=CURRENT_DAY–N'day'"}].
[0231] Match the intended test points with the query test points to obtain the matched test point set, that is, the test point intersection of the intended test points and the query test points, intent_union_sql: ["Relative Date", "Conditional Filter"]; match the intended test points with the query test points to obtain the unmatched test point set, that is, the test point difference set of the intended test points and the query test points, intent_diff_sql: ["Indicator Query - Sum"] and sql_diff_intent: [].
[0232] Combine the matching test point set and the unmatched test point set to identify errors in the structured query statement and generate the corresponding target error information, namely {"result":"false","errorinfo":"Aggregation function error: the aggregation function is missing and the original call volume is not aggregated","errortype":"Aggregation function error","errorinserted":"SELECT`Original call volume`from table where`Call date`=CURRENT_DAY-N'day' / *Aggregation function error: According to the query intention, the original call volume needs to be aggregated, but the original call volume is not SUM aggregated in the structured query statement* / "}.
[0233] In this embodiment, a structured query statement error identification device is also provided. The device is used to implement the above-mentioned embodiments and preferred embodiments, and the details already described will not be repeated. As used below, the term "module" can refer to a combination of software and / or hardware that implements a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, implementation using hardware, or a combination of software and hardware, is also possible and contemplated.
[0234] This embodiment provides a structured query statement error recognition device, such as Figure 5 Shown, including:
[0235] The acquisition module 501 is used to acquire the query intent of the target object and the structured query statement generated based on the query intent.
[0236] The extraction module 502 is used to extract the intention points of the query intention and the query points of the structured query statement.
[0237] Error identification module 503 is used to match the intended test points with the query test points using a pre-built test point mapping relationship, and identify target error information in the structured query based on the test point matching results. The test point mapping relationship is generated based on the correspondence between the intended test points and the test points in the structured query statement.
[0238] In some optional implementations, the extraction module 502 includes:
[0239] The intention test point information acquisition unit is used to obtain the intention test point set and the first prompt description information corresponding to the query intention.
[0240] The intention test point extraction unit is used to use the first prompt description information to guide the pre-trained first test point labeling model to extract the intention test points corresponding to the query intention from the intention test point set.
[0241] In some optional implementations, the extraction module 502 includes:
[0242] The query test point information acquisition unit is used to obtain a structured query statement test point set, where the structured query statement test points are determined based on the node information of the structured query statement.
[0243] The grammatical structure parsing unit is used to parse the grammatical structure of the structured query statement and obtain the abstract syntax tree structure corresponding to the structured query statement.
[0244] The first query test point extraction unit is used to extract query test points corresponding to the structured query statement from the structured query statement test point set according to the abstract syntax tree structure.
[0245] In some optional implementations, the above step S302 may further include:
[0246] The first prompt obtaining unit is configured to obtain second prompt description information corresponding to the structured query statement.
[0247] The second query test point extraction unit is used to use the second prompt description information to guide the pre-trained second test point labeling model to extract the query test points corresponding to the structured query statement from the structured query statement test point set.
[0248] In some optional implementations, the error identification module 503 includes:
[0249] The test point matching unit is used to match the intended test points and the query test points based on the test point mapping relationship to obtain a matched test point set and an unmatched test point set.
[0250] The first error recognition unit is used to use the matching test point set to perform error recognition on the structured query statement and generate first error recognition information.
[0251] The second error recognition unit is used to use the unmatched test point set to perform error recognition on the structured query statement and generate second error recognition information.
[0252] The error fusion unit is used to generate target error information of the structured query statement based on the fusion result of the first error recognition information and the second error recognition information.
[0253] In some optional implementations, the mapping relationship includes a first mapping relationship. Accordingly, the error identification module 503 includes:
[0254] The test point corresponding unit is used to obtain at least one structured query statement test point corresponding to each intention test point.
[0255] The first mapping construction unit is used to semantically associate the intention test point and its corresponding structured query statement test points to obtain a first mapping relationship between the intention test point and the structured query statement test point.
[0256] In some optional implementations, the mapping relationship includes a second mapping relationship and a third mapping relationship. Accordingly, the error identification module 503 includes:
[0257] The second mapping construction unit is used to construct a second mapping relationship corresponding to the target intent test point that is not matched to the structured query statement test point in the intent test point.
[0258] The third mapping construction unit is used to construct a third mapping relationship corresponding to the target query test point for the target query test point that is not matched with the intention test point in the structured query statement test point.
[0259] In some optional implementations, the error identification module 503 includes:
[0260] The third prompt obtaining unit is used to obtain third prompt description information for test site matching check.
[0261] The error recognition unit is used to use the third prompt description information to guide the pre-trained error recognition model to perform error recognition on the structured query, and generate first error recognition information and second error recognition information.
[0262] The further functional description of each of the above modules and units is the same as that of the above corresponding embodiments and will not be repeated here.
[0263] The error recognition device for structured query statements provided by the embodiments of the present disclosure can execute the error recognition method for structured query statements provided by any embodiment of the present disclosure, and has the functional modules and beneficial effects corresponding to the execution method. By extracting the intention test points corresponding to the query intent and the query test points corresponding to the structured query statement, and utilizing the test point mapping relationship between the intention test points and the query test points, the intention test points and the query test points are matched, and the error information hidden in the structured query statement is identified through the test point matching results. Thus, by matching the intention test points and the query test points, accurate identification of error information can be achieved without relying on standard answers, which can meet the error recognition scenarios of structured query statements in the absence of reference answers. Combined with the test point matching results, it can more accurately judge whether the generated structured query statement meets the query intent of the target object, thereby effectively improving the accuracy of error detection, reducing misjudgments and missed judgments, and improving the comprehensiveness of error recognition.
[0264] Figure 6 A schematic diagram of the structure of a computer device provided in an embodiment of the present disclosure.
[0265] The following specific reference Figure 6, which shows a schematic diagram of the structure of a computer device suitable for implementing the embodiments of the present disclosure. The computer device may include a processor (e.g., a central processing unit, a graphics processing unit, etc.) 601, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 602 or a program loaded from a memory 608 into a random access memory (RAM) 603. Various programs and data required for the operation of the computer device are also stored in the RAM 603. The processor 601, ROM 602, and RAM 603 are connected to each other via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.
[0266] Typically, the following devices may be connected to the I / O interface 605: an input device 606 including, for example, a touch screen, a touchpad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 607 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 608 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 609. The communication device 609 may allow the computer device to communicate with other devices wirelessly or by wire to exchange data. Although Figure 6 A computer device having various devices is shown, but it should be understood that it is not required to implement or possess all of the devices shown, and more or fewer devices may be implemented or possessed instead.
[0267] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication device 609, or installed from the memory 608, or installed from the ROM 602. When the computer program is executed by the processor 601, the above-mentioned functions defined in the error identification method of the structured query statement of the embodiment of the present disclosure are performed.
[0268] Figure 6 The computer device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.
[0269] The embodiment of the present invention also provides a computer-readable storage medium. The above-mentioned method according to the embodiment of the present invention can be implemented in hardware, firmware, or implemented as a computer code that can be recorded in a storage medium, or downloaded through a network and originally stored in a remote storage medium or a non-temporary machine-readable storage medium and will be stored in a local storage medium, so that the method described herein can be stored in such software processing on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. Among them, the storage medium can be a magnetic disk, an optical disk, a read-only storage memory, a random access memory, a flash memory, a hard disk or a solid-state drive, etc.; further, the storage medium can also include a combination of the above-mentioned types of memory. It can be understood that the computer, processor, microprocessor controller or programmable hardware includes a storage component that can store or receive software or computer code. When the software or computer code is accessed and executed by the computer, processor or hardware, the error recognition method of the structured query statement shown in the above embodiment is implemented.
[0270] A portion of the present invention may be applied as a computer program product, such as a computer program instruction, which, when executed by a computer, can call or provide the method and / or technical solution according to the present invention through the operation of the computer. Those skilled in the art should understand that the form in which the computer program instruction exists in a computer-readable medium includes, but is not limited to, a source file, an executable file, an installation package file, etc. Accordingly, the way in which the computer program instruction is executed by the computer includes, but is not limited to: the computer directly executes the instruction, or the computer compiles the instruction and then executes the corresponding compiled program, or the computer reads and executes the instruction, or the computer reads and installs the instruction and then executes the corresponding installed program. Here, the computer-readable medium may be any available computer-readable storage medium or communication medium that can be accessed by the computer.
[0271] Although the embodiments of the present invention have been described with reference to the accompanying drawings, those skilled in the art may make various modifications and variations without departing from the spirit and scope of the present invention. Such modifications and variations are all within the scope defined by the appended claims.
Claims
1. A method for identifying errors in structured query statements, characterized in that: The method comprises: Obtaining a query intent of a target object and a structured query statement generated based on the query intent; Extracting the intention test points of the query intention and the query test points of the structured query statement; Using the pre-constructed test point mapping relationship, the intended test points and the query test points are matched, and based on the test point matching results, the target error information in the structured query statement is identified; wherein, the test point mapping relationship is generated based on the correspondence between the intended test points and the structured query statement test points.
2. The method according to claim 1, characterized in that Extract the intent test points of the query intent, including: Obtaining an intent test point set and first prompt description information corresponding to the query intent; The first prompt description information is used to guide the pre-trained first test point labeling model to extract the intent test points corresponding to the query intent from the intent test point set.
3. The method according to claim 1 or 2, characterized in that Extracting query points of the structured query statement includes: Obtaining a structured query statement test point set, wherein the structured query statement test points are determined based on node information of the structured query statement; Parsing the grammatical structure of the structured query statement to obtain an abstract syntax tree structure corresponding to the structured query statement; The query test points corresponding to the structured query statement are extracted from the structured query statement test point set according to the abstract syntax tree structure.
4. The method according to claim 3, characterized in that Also includes: Obtaining second prompt description information corresponding to the structured query statement; The second prompt description information is used to guide the pre-trained second test point labeling model to extract the query test point corresponding to the structured query statement from the structured query statement test point set.
5. The method according to claim 1, wherein Construct a mapping relationship between intent test points and structured query statement test points, including: Obtaining at least one structured query statement test point corresponding to each of the intention test points; Semantically associating the intention test point and each of the corresponding structured query statement test points to obtain a first mapping relationship between the intention test point and the structured query statement test point; The mapping relationship includes the first mapping relationship.
6. The method according to claim 5, characterized in that Also includes: For a target intention test point that is not matched to a test point of the structured query statement among the intention test points, construct a second mapping relationship corresponding to the target intention test point; For the target query test points in the structured query statement that are not matched to the intended test points, construct a third mapping relationship corresponding to the target query test points; The mapping relationship includes the second mapping relationship and the third mapping relationship.
7. The method according to claim 1, 5 or 6, characterized in that: The method of using a pre-built test point mapping relationship to perform test point matching on the intended test point and the query test point, and identifying target error information in the structured query based on the test point matching result, includes: Performing test point matching on the intended test points and the query test points based on the test point mapping relationship to obtain a matched test point set and an unmatched test point set; Performing error recognition on the structured query statement using the matching test point set to generate first error recognition information; Performing error identification on the structured query statement using the unmatched test point set to generate second error identification information; Based on a fusion result of the first error identification information and the second error identification information, target error information of the structured query statement is generated.
8. The method according to claim 7, characterized in that The generating of the first error identification information and the second error identification information includes: Obtain the third prompt description information for the test site matching check; The third prompt description information is used to guide a pre-trained error recognition model to perform error recognition on the structured query, thereby generating the first error recognition information and the second error recognition information.
9. A structured query statement error recognition device, characterized in that: The device comprises: An acquisition module, configured to acquire the query intent of a target object and a structured query statement generated based on the query intent; An extraction module, configured to extract the intention test points of the query intention and the query test points of the structured query statement; An error recognition module is used to use a pre-built test point mapping relationship to match the intended test points with the query test points, and based on the test point matching results, identify the target error information in the structured query; wherein the test point mapping relationship is generated based on the correspondence between the intended test points and the structured query statement test points.
10. A computer device, characterized in that: include: A memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the error identification method for structured query statements according to any one of claims 1 to 8 by executing the computer instructions.
11. A computer-readable storage medium, characterized in that The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a computer to execute the error identification method for structured query statements according to any one of claims 1 to 8.
12. A computer program product, characterized in that The method comprises computer instructions, wherein the computer instructions are used to enable a computer to execute the error identification method of the structured query statement according to any one of claims 1 to 8.
Citation Information
Patent Citations
Structured query language error correction method and device and volatile storage medium
CN119201968A