Structural query statement construction method and system based on intelligent prediction
Automatically continue writing structured query statements through intelligent prediction technology, solving the problem of cumbersome and inefficient construction of ad hoc queries, and improving query statement construction efficiency and user experience.
Patent Information
- Application Number
- CN202410901833.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-05
- Publication Date
- 2024-10-08
AI Technical Summary
Under the existing ad hoc query method, users need to manually configure meta-information such as databases, tables, fields, etc., which makes the construction of structured query statements cumbersome, time-consuming, and inefficient, affecting the data query and analysis experience.
Through intelligent prediction technology, the basic query information typed by users in real time is obtained, an abstract syntax tree is generated, the pre-built metadata cache is queried, model input data is assembled, a large language model is input to extract target query information, and structured query statements are automatically continued.
It simplifies the construction process of structured query statements, improves construction efficiency, and improves users' data query and analysis experience.
Smart Images

Figure CN118747176A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of computer technology, and in particular to a method and system for constructing a structured query statement based on intelligent prediction. Background Art
[0002] At present, in data analysis scenarios, ad hoc queries are often used to query data. Ad hoc queries refer to mapping dimension tables and fact tables in the data warehouse to the semantic layer, selecting tables through the semantic layer, establishing associations between tables, and finally generating SQL (Structured Query Language) statements to query the engine database through SQL statements to obtain the required data.
[0003] However, in related ad hoc query scenarios, users need to manually configure metadata of various databases, tables, fields, etc., and then build complete SQL statements. The entire process is cumbersome and time-consuming, and the efficiency of building SQL statements is low, which affects the user's data query and analysis experience. Summary of the invention
[0004] The embodiments of the present application provide a method and system for constructing a structured query statement based on intelligent prediction, which can assist in constructing a structured query statement through intelligent prediction, improve the construction efficiency of the structured query statement, and solve the technical problem of the cumbersome and inefficient process of constructing the structured query statement.
[0005] In a first aspect, an embodiment of the present application provides a method for constructing a structured query statement based on intelligent prediction, comprising:
[0006] Obtain the basic query information currently typed by the user in real time, parse the basic query information, and generate an abstract syntax tree;
[0007] Based on the abstract syntax tree, the pre-built metadata cache is queried to obtain the corresponding metadata information, and the model input data is assembled based on the metadata information;
[0008] Input the model input data into the specified large language model, obtain the corresponding model output information, extract the target query information from the model output information, continue the basic query information based on the target query information, generate a structured query statement, and perform data query based on the structured query statement.
[0009] In a second aspect, an embodiment of the present application provides a system for constructing a structured query statement based on intelligent prediction, comprising:
[0010] A parsing module, configured to obtain basic query information currently typed in by the user in real time, parse the basic query information, and generate an abstract syntax tree;
[0011] A query module is configured to query a pre-built metadata cache based on an abstract syntax tree, obtain corresponding metadata information, and assemble model input data based on the metadata information;
[0012] The continuation module is configured to input the model input data into the specified large language model, obtain the corresponding model output information, extract the target query information from the model output information, continue to write the basic query information based on the target query information, generate a structured query statement, and perform data query based on the structured query statement.
[0013] In a third aspect, an embodiment of the present application provides a structured query statement construction device based on intelligent prediction, including:
[0014] memory and one or more processors;
[0015] The memory is configured to store one or more programs;
[0016] When the one or more programs are executed by the one or more processors, the one or more processors implement the method for constructing a structured query statement based on intelligent prediction as described in the first aspect.
[0017] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, which stores computer-executable instructions, and the computer-executable instructions, when executed by a computer processor, are configured to execute the method for constructing a structured query statement based on intelligent prediction as described in the first aspect.
[0018] In a fifth aspect, an embodiment of the present application provides a computer program product, which includes instructions that, when executed on a computer or a processor, cause the computer or processor to execute the method for constructing a structured query statement based on intelligent prediction as described in the first aspect.
[0019] The embodiment of the present application obtains the basic query information typed by the current user in real time, parses the basic query information, and generates an abstract syntax tree; queries the pre-built metadata cache based on the abstract syntax tree to obtain the corresponding metadata information, and assembles the model input data based on the metadata information; inputs the model input data into the specified large language model to obtain the corresponding model output information, extracts the target query information from the model output information, continues the basic query information based on the target query information, generates a structured query statement, and performs data query based on the structured query statement. The above-mentioned technical means are adopted to automatically continue the basic query information in combination with the large language model, realize the intelligent prediction of the structured query statement, simplify the construction process of the structured query statement, improve the construction efficiency of the structured query statement, and thus improve the user's data query analysis experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] Figure 1 It is a flowchart of a method for constructing a structured query statement based on intelligent prediction provided in an embodiment of the present application;
[0021] Figure 2 is a flow chart of generating an abstract syntax tree in an embodiment of the present application;
[0022] Figure 3 This is a schematic diagram of the continuation of basic query information in an embodiment of the present application;
[0023] Figure 4 is a schematic diagram of completing a structured query statement in an embodiment of the present application;
[0024] Figure 5 is a flow chart of checking and correcting structured query statements in an embodiment of the present application;
[0025] Figure 6 It is a structural diagram of a system for constructing structured query statements based on intelligent prediction provided in an embodiment of the present application;
[0026] Figure 7 It is a structural diagram of a structured query statement construction device based on intelligent prediction provided in an embodiment of the present application. DETAILED DESCRIPTION
[0027] In order to make the purpose, technical scheme and advantages of the present application clearer, the specific embodiments of the present application are further described in detail below in conjunction with the accompanying drawings. It is understood that the specific embodiments described herein are only used to explain the present application, rather than to limit the present application. It should also be noted that, for the convenience of description, only the part related to the present application but not all the contents are shown in the accompanying drawings. Before discussing the exemplary embodiments in more detail, it should be mentioned that some exemplary embodiments are described as processes or methods depicted as flow charts. Although the flow chart describes each operation (or step) as a sequential process, many of the operations therein can be implemented in parallel, concurrently or simultaneously. In addition, the order of each operation can be rearranged. The process can be terminated when its operation is completed, but it can also have additional steps not included in the accompanying drawings. The process can correspond to a method, a function, a procedure, a subroutine, a subprogram, etc.
[0028] The method for constructing a structured query statement based on intelligent prediction provided in the present application aims to realize intelligent prediction of structured query statements and simplify the construction process of structured query statements by automatically continuing basic query information in combination with a large language model.
[0029] In relevant ad hoc query scenarios, the process of users manually configuring the entire SQL statement is cumbersome and complex, and the efficiency is low. For this reason, WeBank DataSphereStudio or Cloudera Hue (visual analysis) tools are usually used to assist in the construction of SQL statements. Among them, WeBank DataSphereStudio provides a basic intelligent completion function for SQL statements, but it is only a simple library and table completion, and does not do complex nested SQL parsing, such as nested queries, alias parsing, etc.; Cloudera Hue provides complex SQL parsing, but for long SQL parsing, the parsing time is too long, resulting in a high page crash rate. In addition, its cloud data information caching solution is not flexible enough, and it cannot fully utilize the maximum advantages of the client and server at the same time, and the completion efficiency is low. Moreover, the above two tools are based on simple completion and SQL parsing completion to assist in the construction of SQL statements, and the content of their completion is relatively simple.
[0030] Based on this, a method for constructing a structured query statement based on intelligent prediction is provided in an embodiment of the present application to solve the technical problem that the process of constructing a structured query statement is cumbersome and inefficient. Based on the SQL parser, intelligent completion prediction of complex SQL is realized, and an efficient parser execution strategy and a three-level metadata cache strategy are provided to provide high-performance and efficient intelligent prediction of libraries, tables, fields, etc. At the same time, a large language model is combined with SQL table parsing and field acquisition to provide an efficient SQL continuation strategy.
[0031] Example:
[0032] Figure 1 A flowchart of a method for constructing a structured query statement based on intelligent prediction provided in an embodiment of the present application is provided. The method for constructing a structured query statement based on intelligent prediction provided in this embodiment can be executed by a structured query statement construction device based on intelligent prediction. The structured query statement construction device based on intelligent prediction can be implemented by software and / or hardware. The structured query statement construction device based on intelligent prediction can be composed of two or more physical entities, or can be composed of one physical entity. Generally speaking, the structured query statement construction device based on intelligent prediction can be a computer, a tablet, or other computing device.
[0033] The following describes the method for constructing a structured query statement based on intelligent prediction by taking the technical problem of the cumbersome and inefficient process of constructing a structured query statement as an example. Figure 1 , the method for constructing a structured query statement based on intelligent prediction specifically includes:
[0034] S110: Obtain basic query information currently entered by the user in real time, parse the basic query information, and generate an abstract syntax tree.
[0035] When constructing SQL statements, the present application continues to write the basic query information input by the user for constructing SQL statements through intelligent prediction to assist in efficient and simple SQL statement construction.
[0036] Among them, when constructing an SQL statement, the user opens the SQL statement construction page and enters the relevant information for creating an SQL statement in the page. By using front-end technology (such as JavaScript, React, Vue, etc.), the user's input events (such as onInput or onChange) are monitored. The basic query information typed by the user is processed in real time. The basic query information can be a SQL query string, a part of an SQL statement, a key field of an SQL statement, or a natural language. The embodiment of the present application does not impose fixed restrictions on the form of the basic query information, and only needs to satisfy the generation of an abstract syntax tree, which will not be elaborated here.
[0037] For the basic query information input by the user, the corresponding abstract syntax tree AST is obtained by parsing it. Among them, the parsing of the basic query information includes lexical analysis and syntax analysis. For lexical analysis (LexicalAnalysis), the basic query information is decomposed into a series of lexical units (tokens), also known as morphemes or tags. These lexical units are the smallest grammatical units in the SQL language, such as keywords (such as SELECT, FROM), identifiers (such as table names, column names), operators (such as =, <), numbers, strings, etc. These lexical units are identified by a lexical analyzer (also called a scanner or lexical scanner) using predefined rules (usually called regular expressions). For syntax analysis (SyntaxAnalysis), the lexical unit sequence generated by the lexical analyzer is received by the syntax analyzer. Use context-free grammar (CFG) or parse tree (parse tree) to check whether these lexical units are arranged according to the syntax rules of the SQL language. If the lexical unit sequence conforms to the syntax rules, the syntax analyzer will generate a parse tree. This tree structure represents the hierarchy and components of the query, that is, the abstract syntax tree. If a syntax error is found, the parser reports the error and stops processing.
[0038] In addition, the parsing of basic query information also includes semantic analysis, which checks the abstract syntax tree through the semantic analyzer to ensure that the query is logically correct. Semantic analysis can verify the existence of database objects (such as tables, columns, functions, etc.) and user access rights to these objects. The semantic analyzer also checks whether the data types in the query match and performs other checks related to the query logic. If a semantic error is found, the semantic analyzer will report an error and stop processing.
[0039] Optionally, refer to Figure 2 , parse the basic query information, including:
[0040] S1101, generating a parsing task for basic query information based on the client main thread, and sending the parsing task to the working thread;
[0041] S1102, communicating with the parser through the worker thread to perform the parsing task, and returning the corresponding parsing result to the main thread, and the parsing result is used to generate an abstract syntax tree.
[0042] This application is based on the Web Worker worker thread executing the parsing task issued by the client main thread, and based on the long SQL parsing mechanism of the Web Worker worker thread, the client main thread communicates with the Web Worker worker thread to achieve efficient parsing of super-long SQL. The main thread itself does not need to perform the parsing task. By issuing the parsing task to each Web Worker worker thread, independent communication under multiple editors and multiple SQL can be guaranteed, solving the problem of blocking the resynthesis of the DOM tree and style tree and causing frame drops when the main thread executes the long SQL parsing, and achieving efficient information parsing.
[0043] S120, querying the pre-built metadata cache based on the abstract syntax tree, obtaining corresponding metadata information, and assembling model input data based on the metadata information.
[0044] Furthermore, the pre-built metadata cache is queried based on the above-mentioned abstract syntax tree to obtain metadata information. The type and range of metadata to be queried can be determined based on the abstract syntax tree, and then the matching metadata information can be obtained from the metadata cache according to the nodes in the abstract syntax tree and the index of the metadata cache.
[0045] Among them, metadata cache includes client cache, browser cache and server cache;
[0046] A pre-built metadata cache based on an abstract syntax tree query, including:
[0047] The pre-built client cache, browser cache, and server cache are queried sequentially based on the abstract syntax tree.
[0048] The metadata information of this application adopts a three-level cache strategy, which includes client cache (redux), client browser cache (IndexedDB) and server cache.
[0049] Among them, the client cache is stored in redux, which is lost before the browser is refreshed. It has the fastest reading speed and can avoid reading client files or server overhead; the browser cache IndexedDB is stored in the client file, which has a faster reading speed and can avoid the overhead of communicating with the server. By caching the cluster-library-table-field and its mapping relationship of each metadata to the object space of IndexedDB, and expanding the mechanism that IndexedDB does not support ttl, the query and insertion of each object space perform the verification, update and deletion operations of lastmodifiedTimestamp and ttl to ensure the timeliness of the client IndexedDB cache; the server cache is set in the server redis. By setting a three-layer cache strategy, the maximum advantages of the client and server can be brought into play and the cache efficiency can be improved. When it is necessary to query cloud data information, query the client cache, the client's browser cache and the server cache in turn. If the queried metadata exists in the client cache, it is directly read. At this time, the time taken to read the metadata information is extremely short and can be ignored; if the queried metadata exists in the browser cache, the time taken to read the metadata information can be reduced to milliseconds; if the corresponding metadata information cannot be found in both the client cache and the browser cache, the server cache is queried. At this time, the time taken to read the server redis cache can be reduced to seconds. The three-level cache strategy can achieve efficient metadata access by rationally utilizing the resources of the client and server.
[0050] Furthermore, based on the metadata information collected above, by assembling the model data of the large language model, the large language model can be used to assist in the continuation of SQL statements. The step of assembling the model input data based on the metadata information includes:
[0051] The few-sample test data, restriction data and metadata information are assembled to generate model input data. The few-sample test data is used to provide metadata information prediction examples to the specified large language model, and the restriction data is used to limit the generation of model output information.
[0052] Based on the metadata information obtained, since it is an incomplete SQL statement, it needs to be converted into a complete SQL statement through a large language model to achieve the effect of SQL statement continuation. In addition, the model input data prompt needs to include corresponding small sample test data, and the small sample test data provides the large language model with prediction instances of metadata information to guide the large language model on how to predict complete statements based on metadata information. In addition, the model input data also needs to include restrictions to limit the generation form, type, specific content, etc. of the model output information. After the model input data is constructed, it can be sent to the large language model for prediction. The large model will generate continuation content based on the input model input data and its own training data. It should be noted that the designated large language model of this application can be a large language model such as Wenxin Yiyan, chat-gbt, etc. This application does not impose fixed restrictions on specific large language models, and will not be elaborated here.
[0053] S130, inputting the model input data into the specified large language model, obtaining the corresponding model output information, extracting the target query information from the model output information, continuing the basic query information based on the target query information, generating a structured query statement, and performing data query based on the structured query statement.
[0054] Based on the model input data assembled above, by inputting a specified large language model, the model input data can be processed with the help of the large language model to obtain corresponding model output information.
[0055] The model output information returned by a large model is usually a series of text, which needs to be parsed and adapted to extract valid SQL content, that is, the target query information.
[0056] The target query information is extracted from the model output information, including:
[0057] Filter out the specified invalid information in the model output information, adapt and adjust the model output information according to the set grammatical rules, and generate target query information.
[0058] Specifically, when generating the target query information, first remove the specified invalid information in the model output information, such as extra spaces and line breaks generated by the model. Then use the SQL parser to perform syntax check on the extracted SQL content to ensure that it is a valid SQL statement. Then, according to the context information of the original SQL query (such as AST and metadata cache) and the set grammatical rules of the SQL statement, adapt the extracted SQL content, such as replacing placeholders, adjusting table names or column names, etc., to obtain the target query information. The target query information can be used as a continuation of the basic query information to generate the corresponding structured query statement.
[0059] For example, refer to Figure 3 When constructing SQL statements, the user enters the basic query information "--Create table tmp.xx_uid_sms_20231110 to record user uid, churn type, and game type creation". Since this comment is in natural language, it needs to be converted into SQL content that conforms to grammatical rules. This triggers the continuation of the basic query information. Among them, the abstract syntax tree AST is obtained by parsing the basic query information entered by the current user, and multiple lines of AI intelligent continuation are performed based on the language large model, SQL parsing, three-level metadata cache, and result conversion layer, which can provide the effect of converting comments to SQL content, and obtain the following: Figure 3 In addition, according to the actual construction scenario, you can also continue to write SQL contents such as context paragraph SQL, multi-line SQL, subquery, etc. based on the basic query information to achieve efficient and convenient SQL statement construction.
[0060] In addition, based on the above target query information, it is cached and the context of the continuation content is hashed as the key. When automatically rewriting, the hash query is performed later. If the key is the same, the cache is directly read to complete the continuation, which can further improve the efficiency of continuation and reduce the overhead of large language models.
[0061] Optionally, after generating the abstract syntax tree, the following steps are also included:
[0062] Locate the real-time typing position of the current user corresponding to the basic query information, query the pre-built metadata cache based on the abstract syntax tree and the real-time typing position, obtain metadata completion information from the metadata cache, and complete the information of the real-time typing position based on the metadata completion information.
[0063] Corresponding to the above basic query information, the SQL parser is used to perform lexical and grammatical analysis, and context and completion meta-information are added to the grammatical analysis to generate the grammar and completion abstract syntax tree AST. Corresponding to the current user's real-time typing position, the type and context that need to be completed at the current typing position are obtained from the abstract syntax tree AST, and then the associated metadata information is obtained level by level from the three-level metadata cache, which is defined as metadata completion information. The metadata completion information is completed to the typing position, so that efficient completion of libraries, tables, fields, keywords, subqueries or aliases can be achieved.
[0064] Reference Figure 4 , the user enters the location as "crea...", and through the above cloud data information completion method, the metadata completion information is determined to be "create-time", and the cloud data information of the location is completed using the completion information. When multiple metadata completion information is determined, the user manually selects the final metadata completion information for completion.
[0065] Based on the intelligent prediction method of the above SQL statements, when writing basic query information, you only need to indicate the specified table name. The device will automatically output the fields of the table under the metadata based on the intelligent prediction structured query statement construction method, and provide intelligent completion based on the context. If the SQL content continuation condition is triggered, paragraphs and multiple lines of SQL will be directly generated based on the context, comments, etc. By combining the intelligent completion of SQL statements and AI intelligent continuation, the accuracy of SQL statement construction can be improved, statement prediction can be enhanced, and the overall SQL writing efficiency can be improved.
[0066] Optionally, refer to Figure 5 After generating the structured query statement, it also includes:
[0067] S1301, performing syntax check on the structured query statement;
[0068] S1302: When it is determined that a syntax check error occurs, obtain a historical query statement error log, input the historical query statement error log and the structured query statement into a designated large language model, and output the error cause and / or correction result of the structured query statement.
[0069] Based on the structured query statement constructed above, first add the predicted result (continuation content or completion content) to the existing context content for syntax check to form a complete SQL statement, and use the SQL parser to perform syntax check on the spliced SQL statement to ensure the completeness and correctness of the statement. If there are grammatical problems in the SQL statement, the prediction results of common grammatical problems are added to fill in. For example, the large language model may not be able to recognize the comment line breaks, spaces and other scenarios. By improving the first step of verification based on syntax detection based on SQL parsing, the user experience can be improved and the workload of manual correction by users can be reduced.
[0070] Furthermore, when an error occurs during SQL execution, the engine will return an error log and specific line number. Based on the current data source and error log, as well as the historical query statement error log, the system will assemble a model input data prompt containing the SQL execution context and error information, and send it to the big model for analysis. The big model will analyze and return the error cause and the corrected SQL statement, and the user can directly re-execute the corrected SQL.
[0071] In addition, the system can also make optimization suggestions for SQL statements. For example, for Hive table creation statements, the system will identify and assemble the comments (standardized data governance) of the tables and columns required for optimization in one click, and then send them to the large language model to generate optimized and standardized new SQL statements. The optimized SQL returned by the large model can help users better write and execute SQL statements and improve query efficiency.
[0072] In the above, the basic query information typed by the current user in real time is obtained, the basic query information is parsed, and an abstract syntax tree is generated; based on the abstract syntax tree, the pre-built metadata cache is queried to obtain the corresponding metadata information, and the model input data is assembled based on the metadata information; the model input data is input into the specified large language model to obtain the corresponding model output information, the target query information is extracted from the model output information, the basic query information is continued based on the target query information, and a structured query statement is generated to perform data query based on the structured query statement. The above technical means are adopted to automatically continue the basic query information in combination with the large language model, so as to realize the intelligent prediction of the structured query statement, simplify the construction process of the structured query statement, improve the construction efficiency of the structured query statement, and thus improve the user's data query and analysis experience.
[0073] Based on the above embodiments, Figure 6 A schematic diagram of a structured query statement construction system based on intelligent prediction provided by this application. Figure 6 The structured query statement construction system based on intelligent prediction provided in this embodiment specifically includes: a parsing module 21, a query module 22 and a continuation module 23.
[0074] The parsing module 21 is configured to obtain basic query information currently typed in by the user in real time, parse the basic query information, and generate an abstract syntax tree;
[0075] The query module 22 is configured to query the pre-built metadata cache based on the abstract syntax tree, obtain the corresponding metadata information, and assemble the model input data based on the metadata information;
[0076] The continuation module 23 is configured to input the model input data into the specified large language model, obtain the corresponding model output information, extract the target query information from the model output information, continue to write the basic query information based on the target query information, generate a structured query statement, and perform data query based on the structured query statement.
[0077] Specifically, the basic query information is parsed, including:
[0078] Generates parsing tasks for basic query information based on the client main thread, and sends the parsing tasks to the working thread;
[0079] The parsing task is performed by communicating with the parser through the worker thread, and the corresponding parsing result is returned to the main thread. The parsing result is used to generate an abstract syntax tree.
[0080] Specifically, metadata cache includes client cache, browser cache, and server cache;
[0081] A pre-built metadata cache based on an abstract syntax tree query, including:
[0082] The pre-built client cache, browser cache, and server cache are queried sequentially based on the abstract syntax tree.
[0083] Specifically, the model input data is assembled based on metadata information, including:
[0084] The few-sample test data, restriction data and metadata information are assembled to generate model input data. The few-sample test data is used to provide metadata information prediction examples to the specified large language model, and the restriction data is used to limit the generation of model output information.
[0085] Specifically, after generating the abstract syntax tree, it also includes:
[0086] After generating the abstract syntax tree, it also includes:
[0087] Locate the real-time typing position of the current user corresponding to the basic query information, query the pre-built metadata cache based on the abstract syntax tree and the real-time typing position, obtain metadata completion information from the metadata cache, and complete the information of the real-time typing position based on the metadata completion information.
[0088] Specifically, the target query information is extracted from the model output information, including:
[0089] Filter out the specified invalid information in the model output information, adapt and adjust the model output information according to the set grammatical rules, and generate target query information.
[0090] Specifically, after generating the structured query statement, it also includes:
[0091] Perform syntax check on structured query statements;
[0092] When it is determined that a syntax check error occurs, a historical query statement error log is obtained, the historical query statement error log and the structural query statement are input into a designated large language model, and the error cause and / or correction result of the structural query statement is output.
[0093] In the above, the basic query information typed by the current user in real time is obtained, the basic query information is parsed, and an abstract syntax tree is generated; based on the abstract syntax tree, the pre-built metadata cache is queried to obtain the corresponding metadata information, and the model input data is assembled based on the metadata information; the model input data is input into the specified large language model to obtain the corresponding model output information, the target query information is extracted from the model output information, the basic query information is continued based on the target query information, and a structured query statement is generated to perform data query based on the structured query statement. The above technical means are adopted to automatically continue the basic query information in combination with the large language model, so as to realize the intelligent prediction of the structured query statement, simplify the construction process of the structured query statement, improve the construction efficiency of the structured query statement, and thus improve the user's data query and analysis experience.
[0094] The structured query statement construction system based on intelligent prediction provided in the embodiment of the present application can be configured to execute the structured query statement construction method based on intelligent prediction provided in the above embodiment, and has corresponding functions and beneficial effects.
[0095] Based on the above practical example, the present application embodiment also provides a structured query statement construction device based on intelligent prediction, referring to Figure 7 , the structured query statement construction device based on intelligent prediction includes: a processor 31, a memory 32, a communication module 33, an input device 34 and an output device 35. The memory, as a computer-readable storage medium, can be configured to store software programs, computer executable programs and modules, such as program instructions / modules corresponding to the structured query statement construction method based on intelligent prediction described in any embodiment of the present application (for example, the parsing module, query module and continuation module in the structured query statement construction system based on intelligent prediction). The communication module is configured to transmit data. The processor executes various functional applications and data processing of the device by running the software programs, instructions and modules stored in the memory, that is, realizing the above-mentioned structured query statement construction method based on intelligent prediction. The input device can be configured to receive input digital or character information, and generate key signal input related to the user settings and function control of the device. The output device may include a display device such as a display screen. The structured query statement construction device based on intelligent prediction provided above can be configured to execute the structured query statement construction method based on intelligent prediction provided in the above-mentioned embodiment, and has corresponding functions and beneficial effects.
[0096] On the basis of the above embodiments, the embodiments of the present application further provide a computer-readable storage medium, wherein the computer-readable storage medium stores computer-executable instructions, wherein the computer-executable instructions are configured to execute a method for constructing a structured query statement based on intelligent prediction when executed by a computer processor, and the storage medium may be any of various types of memory devices or storage devices. Of course, the computer-executable instructions of the computer-readable storage medium provided in the embodiments of the present application are not limited to the method for constructing a structured query statement based on intelligent prediction as described above, and may also execute related operations in the method for constructing a structured query statement based on intelligent prediction provided in any embodiment of the present application.
[0097] On the basis of the above embodiments, the embodiments of the present application also provide a computer program product. The essence of the technical solution of the present application or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product. The computer program product is stored in a storage medium, including a number of instructions for enabling a computer device, a mobile terminal or a processor therein to execute all or part of the steps of the method for constructing a structured query statement based on intelligent prediction described in each embodiment of the present application.
Claims
1. A method for constructing a structured query statement based on intelligent prediction, characterized in that: include: Obtaining basic query information currently typed in by the user in real time, parsing the basic query information, and generating an abstract syntax tree; Querying a pre-built metadata cache based on the abstract syntax tree to obtain corresponding metadata information, and assembling model input data based on the metadata information; The model input data is input into a specified large language model, corresponding model output information is obtained, target query information is extracted from the model output information, the basic query information is continued based on the target query information, a structured query statement is generated, and data query is performed based on the structured query statement.
2. The method for constructing a structured query statement based on intelligent prediction according to claim 1, characterized in that: The step of assembling model input data based on the metadata information includes: The few-sample test data, the restriction data and the metadata information are assembled to generate model input data, the few-sample test data is used to provide metadata information prediction examples to the specified large language model, and the restriction data is used to limit the generation of the model output information.
3. The method for constructing a structured query statement based on intelligent prediction according to claim 1, characterized in that: The extracting target query information from the model output information includes: Specified invalid information in the model output information is filtered out, the model output information is adapted and adjusted according to the set grammatical rules, and target query information is generated.
4. The method for constructing a structured query statement based on intelligent prediction according to claim 1, characterized in that: After generating the abstract syntax tree, the method further includes: Locate the real-time typing position of the current user corresponding to the basic query information, query a pre-built metadata cache based on the abstract syntax tree and the real-time typing position, obtain metadata completion information from the metadata cache, and complete information for the real-time typing position based on the metadata completion information.
5. The method for constructing a structured query statement based on intelligent prediction according to claim 1, characterized in that: After generating the structured query statement, the method further includes: Performing syntax check on the structured query statement; When it is determined that a syntax check error occurs, a historical query statement error log is obtained, the historical query statement error log and the structured query statement are input into the designated large language model, and the error cause and / or correction result of the structured query statement is output.
6. The method for constructing a structured query statement based on intelligent prediction according to any one of claims 1 to 5, characterized in that: The metadata cache includes client cache, browser cache and server cache; The metadata cache pre-built based on the abstract syntax tree query includes: The pre-built client cache, the browser cache, and the server cache are queried in sequence based on the abstract syntax tree.
7. The method for constructing a structured query statement based on intelligent prediction according to any one of claims 1 to 5, characterized in that: The parsing of the basic query information includes: Generate a parsing task for the basic query information based on the client main thread, and send the parsing task to the working thread; The parsing task is performed by communicating with the parser through the worker thread, and the corresponding parsing result is returned to the main thread, and the parsing result is used to generate the abstract syntax tree.
8. A structured query statement construction system based on intelligent prediction, characterized in that: include: A parsing module, configured to obtain basic query information currently typed in by a user in real time, parse the basic query information, and generate an abstract syntax tree; A query module configured to query a pre-built metadata cache based on the abstract syntax tree, obtain corresponding metadata information, and assemble model input data based on the metadata information; The continuation module is configured to input the model input data into a specified large language model, obtain corresponding model output information, extract target query information from the model output information, continue to write the basic query information based on the target query information, generate a structured query statement, and perform data query based on the structured query statement.
9. A device for constructing structured query statements based on intelligent prediction, characterized in that: include: memory and one or more processors; The memory is configured to store one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the method for constructing a structured query statement based on intelligent prediction as described in any one of claims 1-7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, which, when executed by a computer processor, are configured to execute the method for constructing a structured query statement based on intelligent prediction as described in any one of claims 1 to 7.
11. A computer program product, characterized in that The computer program product includes instructions, and when the instructions are executed on a computer or a processor, the computer or the processor executes the method for constructing a structured query statement based on intelligent prediction as described in any one of claims 1 to 7.
Citation Information
Cited By
Data processing method and device, computer equipment, readable storage medium and program product
CN119646024A
Database adaptation method and device, electronic equipment and storage medium
CN120973837A
A database adaptation method and device, electronic equipment and storage medium
CN120973837B
