SQL (Structured Query Language) merging method and device for left shift of deep thinking process and storage medium

By using a left-shifting method in the deep thinking process, the initial operation statement is matched with the basic operation type sequence to generate the target operation sequence. The thinking text with the highest similarity is retrieved from the thinking knowledge base and concatenated with the initial prompt word. This is then input into a non-deep thinking model for query statement merging, solving the problem of low SQL script merging efficiency in cloud application development and achieving fast and accurate SQL merging results.

CN121807975APending Publication Date: 2026-04-07CHINA MERCHANTS BANK
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-23
Publication Date
2026-04-07

AI Technical Summary

Technical Problem

In cloud application development, existing technologies struggle to efficiently merge SQL scripts during database change operations. Small-to-medium-sized general-purpose large models cannot accurately understand business logic and syntax constraints, resulting in low accuracy of merged results and long response times, failing to meet the business requirements for real-time performance and efficiency.

Method used

By using the left-shifting method in the deep thinking process, the initial operation statement is matched with the preset basic operation type sequence to generate the target operation sequence. The target thinking text with the highest similarity is retrieved from the thinking knowledge base and concatenated with the initial prompt word. The query statement is then input into the non-deep thinking model and merged. The logic of the deep thinking model is pre-fixed and reused, reducing the high time consumption of online deep thinking.

Benefits of technology

It improves the response speed of SQL query merging, reduces resource consumption, and maintains the accuracy and consistency of merging results, significantly improving response speed and efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121807975A_ABST
    Figure CN121807975A_ABST
Patent Text Reader

Abstract

The invention discloses an SQL (Structured Query Language) merging method and device for left shift of a deep thinking process and a storage medium, and relates to the technical field of data processing, the method comprises the following steps: matching an initial operation statement with a preset basic operation type sequence to obtain a target operation sequence corresponding to the initial operation statement; obtaining the similarity between the target operation sequence and an operation type sequence in a preset thinking knowledge base, and determining a thinking text associated with the operation type sequence with the highest similarity as a target thinking text; splicing the target thinking text and the initial cue word to obtain a target cue word; and inputting the target cue word and the initial operation statement into a preset non-deep thinking model for query statement merging to obtain a target operation statement. The SQL script merging efficiency can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of data processing technology, and in particular to a method, device and storage medium for left-shifting SQL merging in deep thinking process. Background Technology

[0002] In cloud application development scenarios, database change operations are characterized by high frequency and multiple types due to frequent business iterations. In order to improve the maintainability and execution efficiency of SQL scripts, it is necessary to intelligently merge scattered and multi-batch SQL scripts.

[0003] Current intelligent SQL script merging solutions based on large models suffer from limitations in parameter size and scenario adaptability when dealing with database change-related SQL script merging. These limitations make it difficult to accurately understand the business logic and syntactic constraints of SQL operations, resulting in low accuracy and reasonableness of the merging results. While deep thinking models can output high-quality SQL merging results thanks to their powerful logical reasoning capabilities, their long response times make them unsuitable for the real-time and efficient business requirements of cloud application development.

[0004] The above content is only used to help understand the technical solution of this application and does not represent an admission that the above content is prior art. Summary of the Invention

[0005] The main purpose of this application is to provide a method, device and storage medium for merging SQL scripts by shifting the deep thinking process to the left, in order to solve the technical problem of how to improve the efficiency of merging SQL scripts.

[0006] To address the aforementioned issues, this application provides a SQL merging method for left-shifting the deep thinking process, which includes: The initial operation statement is matched with a preset sequence of basic operation types to obtain the target operation sequence corresponding to the initial operation statement; Obtain the similarity between the target operation sequence and the operation type sequence in the preset thinking knowledge base, and determine the thinking text associated with the operation type sequence with the highest similarity as the target thinking text; The target thought text and the initial prompt words are concatenated to obtain the target prompt words; The target prompt and the initial operation statement are input into a preset non-deep thinking model to merge the query statements and obtain the target operation statement.

[0007] In one embodiment, before the step of obtaining the similarity between the target operation sequence and the operation type sequences in the preset thinking knowledge base, and determining the thinking text associated with the operation type sequence with the highest similarity as the target thinking text, the SQL merging method for left-shifting the deep thinking process further includes: The training data is input into a preset deep thinking model and the query statements are merged. Based on the preset prompts, the thinking process text and operation type of the deep thinking model are obtained. The thought process text and the operation type are used to generate the thought knowledge base.

[0008] In one embodiment, the step of matching the initial operation statement with a preset sequence of basic operation types to obtain the target operation sequence corresponding to the query statement includes: Based on preset SQL syntax rules, the initial operation statement is converted into an abstract syntax tree; Traverse the tree nodes of the abstract syntax tree to determine the operation type and operation object in the initial operation statement; Match the operation type and the operation object with the basic operation type sequence; If the operation type and the operation object are completely matched, the target operation sequence is obtained based on the matching result.

[0009] In one embodiment, after the step of matching the operation type and the operation object with the basic operation type sequence, the SQL merging method for left-shifting the deep thinking process further includes: If the operation type and the operation object partially match, or if the match fails, then obtain the corresponding regular expression rule; The regular expression rules are parsed based on a preset regular expression engine, and the regular expression rules are transformed from character form into a syntax pattern tree to obtain the matching logic corresponding to the regular expression rules. The matching logic that matches fixed keywords, wildcards, and anchors is determined as the target matching logic; Based on the target matching logic, the initial operation statement is converted into the target operation sequence.

[0010] In one embodiment, the step of obtaining the similarity between the target operation sequence and operation type sequences in a preset thinking knowledge base, and determining the thinking text associated with the operation type sequence with the highest similarity as the target thinking text, includes: The operation types in the target operation sequence are vectorized to obtain a first vector, and the operation types in the preset thinking knowledge base are vectorized to obtain a second vector; Obtain the cosine similarity between the first vector and the second vector; If the highest cosine similarity is greater than the preset similarity threshold, then the thought text corresponding to the highest cosine similarity is determined as the target thought text.

[0011] In one embodiment, before the step of merging the target prompt and the initial operation statement into a preset non-deep thinking model to obtain the target operation statement, the SQL merging method for left-shifting the deep thinking process further includes: If the matching score between the initial operation statement and the basic operation type sequence is less than a preset matching score threshold, or the thinking fit is less than a preset thinking fit threshold, then the initial operation statement is determined as the second query statement. The second query statement is input into a preset distillation model, and the query statements are merged to obtain the target operation statement.

[0012] In one embodiment, before the step of determining the initial operation statement as the second query statement when the matching score between the initial operation statement and the basic operation type sequence is less than a preset matching score threshold, or the thinking fit is less than a preset thinking fit threshold, the SQL merging method for left-shifting the deep thinking process includes: Obtain the table association matching degree, condition complexity matching degree, and operation type matching degree between the initial operation statement and the target thinking text; The matching degree of the table association number, the matching degree of the condition complexity, and the matching degree of the operation type are weighted and calculated to obtain the thinking fit degree.

[0013] In one embodiment, the SQL merging method for left-shifting the deep thinking process further includes: New and non-compliant query statements are determined based on preset filtering rules; The newly added query statement and the query statement that did not meet the standard are input into a preset deep thinking model to generate new thinking text; The thinking knowledge base is updated based on the newly added thinking text.

[0014] Furthermore, to achieve the above objectives, this application also proposes a deep thinking process left-shifting SQL merging device, the device comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, the computer program being configured to implement the steps of the deep thinking process left-shifting SQL merging method as described above.

[0015] In addition, to achieve the above objectives, this application also proposes a storage medium, which is a computer-readable storage medium, on which a computer program is stored, which, when executed by a processor, implements the steps of the SQL merge method for left shifting the deep thinking process as described above.

[0016] This application provides a SQL merging method for left-shifting the deep thinking process. It matches the initial operation statement with a preset basic operation type sequence to obtain the target operation sequence, and then retrieves the target thinking text with the highest similarity from the thinking knowledge base. This text is then concatenated with the initial prompt word to form the target prompt word. The general logic that has been generalized by the deep thinking model is solidified and reused in advance, allowing non-deep thinking models to complete query matching, thinking text retrieval, and prompt word fusion in the pre-filling stage. In the subsequent decoding stage, only the target operation statement needs to be generated in a lightweight manner. This method not only ensures that the effect of SQL query merging is consistent with the deep thinking model by leveraging the pre-obtained deep thinking logic, but also avoids the high time consumption of online deep thinking of large models, improves response speed, and reduces resource consumption. Attached Figure Description

[0017] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.

[0018] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0019] Figure 1 This is the first flowchart illustrating the SQL merging method with a leftward shift in the deep thinking process of this application. Figure 2 This serves as a verification of the effect of shifting the original deep thinking process to the left in this application; Figure 3 This is a performance comparison chart between this application and other solutions; Figure 4 A second flowchart illustrating the SQL merging method with a leftward shift in the deep thinking process of this application; Figure 5 A third flowchart illustrating the SQL merging method with a leftward shift in the deep thinking process of this application; Figure 6 This is a schematic diagram of the hardware operating environment involved in the SQL merging method of left shifting the deep thinking process in the embodiments of this application.

[0020] The purpose, features, and advantages of this application will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation

[0021] It should be understood that the specific embodiments described herein are merely illustrative of the technical solutions of this application and are not intended to limit this application.

[0022] To better understand the technical solution of this application, a detailed description will be provided below in conjunction with the accompanying drawings and specific implementation methods.

[0023] To achieve the above objectives, this application proposes a SQL merging method for left-shifting the deep thinking process. This method involves matching the initial operation statement with a preset sequence of basic operation types to obtain the target operation sequence corresponding to the query statement; obtaining the similarity between the target operation sequence and operation type sequences in a preset thinking knowledge base; determining the thinking text associated with the operation type sequence with the highest similarity as the target thinking text; concatenating the target thinking text with the initial prompt word to obtain the target prompt word; and inputting the target prompt word and the initial operation statement into a preset non-deep thinking model to merge the query statements, thereby obtaining the target operation statement.

[0024] In cloud application development scenarios, database change operations are characterized by high frequency and multiple types due to frequent business iterations. In order to improve the maintainability and execution efficiency of SQL scripts, it is necessary to intelligently merge scattered and multi-batch SQL scripts.

[0025] Current intelligent SQL script merging solutions based on large models suffer from limitations in parameter size and scenario adaptability when dealing with database change-related SQL script merging. These limitations make it difficult to accurately understand the business logic and syntactic constraints of SQL operations, resulting in low accuracy and reasonableness of the merging results. While deep thinking models can output high-quality SQL merging results thanks to their powerful logical reasoning capabilities, their long response times make them unsuitable for the real-time and efficient business requirements of cloud application development.

[0026] This application provides a SQL merging method for left-shifting the deep thinking process. It matches the initial operation statement with a preset basic operation type sequence to obtain the target operation sequence, and then retrieves the target thinking text with the highest similarity from the thinking knowledge base. This text is then concatenated with the initial prompt word to form the target prompt word. The general logic that the deep thinking model has generalized offline is solidified and reused in advance. This allows non-deep thinking models to complete query matching, thinking text retrieval, and prompt word fusion in the pre-filling stage. In the subsequent decoding stage, only the target operation statement needs to be generated in a lightweight manner. This method not only ensures that the effect of SQL query merging is consistent with the deep thinking model by leveraging the pre-obtained deep thinking logic, but also avoids the high time consumption of online deep thinking of large models, improves response speed, and reduces resource consumption.

[0027] It should be noted that the executing entity in this embodiment can be a computing service device with network communication and program execution functions, such as a tablet computer, personal computer, or mobile phone, or an electronic device or apparatus capable of performing the above functions. The following description uses a SQL merging device with a left-shifting deep thinking process as an example to illustrate this embodiment and the subsequent embodiments.

[0028] Based on this, this application provides a SQL merging method for left-shifting the deep thinking process, referring to... Figure 1 , Figure 1 This is a flowchart illustrating the first embodiment of the SQL merging method with leftward shift in the deep thinking process of this application.

[0029] In this embodiment, the SQL merging method for left-shifting the deep thinking process includes steps S10 to S40: Step S10: Match the initial operation statement with the preset basic operation type sequence to obtain the target operation sequence corresponding to the initial operation statement.

[0030] In this embodiment, based on database operation instances occurring in a real production environment, scenarios for basic SQL operation types are defined, such as creating a table (CREATE TABLE), modifying a data type (ALTER DATATYPE), and modifying an index (ALTERINDEX). The generated sequence of basic operation types can cover various possible operation scenarios. The original SQL scripts in the operation instances undergo preprocessing such as format clarification and syntax validation to avoid format differences affecting operation type extraction, resulting in standardized original SQL scripts.

[0031] Based on the SQL92 standard and database (MySQL / PostgreSQL / Oracle) extended syntax, a predefined set of core operation verbs and operation objects is used. For example, core operation verbs include: CREATE, ALTER, DROP, RENAME, TRUNCATE, ADD, MODIFY, DROP, etc.; operation objects include TABLE, COLUMN, INDEX, CONSTRAINT, VIEW, DATATYPE, PRIMARY KEY, FOREIGN KEY, etc. An AST syntax tree is generated for each standardized SQL statement. The AST tree nodes are traversed, and the core operation verbs and operation objects are matched to obtain the operation verbs and operation objects. The extracted operation verbs and operation objects are then combined and clustered to obtain a sequence of basic operation types.

[0032] In one feasible implementation, step S10 may include steps S11 to S14: Step S11: Based on preset SQL syntax rules, the initial operation statement is converted into an abstract syntax tree; Step S12: Traverse the tree nodes of the abstract syntax tree to determine the operation type and operation object in the initial operation statement; Step S13: Match the operation type and the operation object with the basic operation type sequence; Step S14: If the operation type and the operation object are completely matched, the target operation sequence is obtained based on the matching result.

[0033] In this implementation, for the initial operation statement, comments in the script are identified and deleted; all SQL keywords are converted to uniform uppercase, and redundant spaces, newlines, and tabs in the statement are removed, retaining only the spaces required by the syntax; an SQL syntax parsing tool is called to check whether each single statement after splitting conforms to the syntax rules, and empty statements and statements with syntax errors are filtered out to obtain standardized initial operation statements.

[0034] Based on the target database type, such as MySQL or PostgreSQL, a predefined lexical rule set is loaded. This set clearly defines the identification criteria for different token types. For example, keyword rules match a predefined list of keywords like ALTER, TABLE, and MODIFY; identifier rules match character combinations consisting of letters, numbers, and underscores, such as table names, field names, and index names; and data type rules match data type keywords like VARCHAR, INT, and DECIMAL. Starting from the first character of a single statement, the system iterates character by character. Upon encountering a character sequence that matches a certain rule, the current scan terminates, and a token of the corresponding type is generated, while skipping meaningless characters such as spaces and tabs. All generated tokens are then arranged sequentially into a token sequence.

[0035] Loading the corresponding database's syntax rule set clarifies the hierarchical structure of SQL statements. For example, the ALTER table statement consists of ALTER + TABLE + table name + table operation clauses. Sub-rules define table operation clauses, which can include clauses for modifying fields and adjusting indexes. Leaf rules define clauses for modifying fields as consisting of MODIFY + field name + data type specification. Starting from the first token in the token sequence, matching proceeds layer by layer from top to bottom until all tokens are matched. During the matching process, syntax validity is simultaneously verified. If a token is missing, out of order, or an invalid token is present, it is considered a syntax error and marked as an anomaly. If the match is successful, the tokens are combined into a specific syntax tree (CST) according to the hierarchical relationship of the syntax rules. Each node of the CST corresponds to a syntax unit, preserving all token details and syntax structure.

[0036] Traverse the CST, deleting all nodes without business semantics, such as symbol nodes used only for syntax formatting, empty nodes, and separator nodes used purely for rule matching. Merge multiple nodes expressing the same business semantics into higher-order semantic nodes; for example, merge "MODIFY," "name," and "DATATYPE" into a "COLUMN_MODIFICATION" node, explicitly defining the semantics as modifying a field. Add semantic type labels to each node to distinguish between core semantic nodes and business parameter nodes: core semantic nodes are labeled with operation actions, operation objects, and core attributes; business parameter nodes are labeled PARAM, which only contain specific table names, field names, values, etc., without general semantics, resulting in the Abstract Syntax Tree (AST).

[0037] In this embodiment, a preset traversal rule for AST nodes is established. Optionally, a depth-first traversal method is adopted, starting from the root node, prioritizing the traversal of operation action nodes, and then traversing the operation object nodes, skipping parameter nodes such as table names, field names, and specific data type values. During the traversal, the extracted core semantic nodes are integrated according to the format of the operation action and the operation object. During integration, the node content is converted into a generalized description, such as converting the "DATATYPE" node into a data type; the "INDEX" node is directly retained as an "index" to ensure that feature combinations do not depend on specific business parameters.

[0038] After extraction, compare the feature combination with the preset basic operation type sequence. If the feature combination is completely consistent with the matching rule of a certain type, the corresponding type identifier is directly marked for the statement; if the feature combination only matches part of the rule, all possible candidate type identifiers are marked; if the feature combination does not match any type of matching rule, it is marked as no candidate type.

[0039] In one feasible implementation, steps S15 to S18 may be included after step S14: Step S15: If the operation type and the operation object partially match, or if the match fails, then obtain the corresponding regular expression rule; Step S16: Based on the preset regular expression engine, parse the regular expression rules, convert the regular expression rules from character form into a syntax pattern tree, and obtain the matching logic corresponding to the regular expression rules. Step S17: The matching logic that matches the fixed keyword, wildcard, and anchor point is determined as the target matching logic; Step S18: Based on the target matching logic, the initial operation statement is converted into the target operation sequence.

[0040] In this implementation, a regular expression rule base adapted to different databases is pre-built for the basic SQL operation type sequence, and the typical syntax of each operation type is described by regular expressions. For operation statements with no candidate type, partial match, and AST parsing exception initial operation statements, the corresponding basic SQL operation type sequence is further determined based on the regular expression matching rules.

[0041] If there is a partial match in the AST, filter out the regular expression rules corresponding to the candidate types; if there is no match in the AST, or a parsing error occurs, load the regular expression rules for all types; based on the database type of the current statement, filter out the rule versions suitable for that database.

[0042] The regularized statement is substituted into the filtered regular expression rules, and each rule is checked for a match. The regular expression engine compares the statement with the rules character by character to determine whether the statement conforms to the grammatical structure described by the rules.

[0043] The regular expression engine parses the preset regular expression rules, transforming them from character form into a syntax pattern tree, clarifying the matching logic of the rules. For example, ^ is used to mark the beginning of a statement, ensuring that the match starts from the first character of the statement; ALTER\s+TABLE requires the statement to begin with "ALTER" + any space + "TABLE". Starting from the first character of the SQL statement, the regular expression engine validates each character according to the logic of the syntax pattern tree. First, it performs anchor point validation, checking the beginning and end of the statement to ensure that the match is a complete statement rather than a fragment. Second, it validates fixed keywords, checking for consecutive keywords in the order defined in the rules, ensuring that the keywords are separated only by valid spaces. For wildcards in the rules, it checks whether the characters at the corresponding positions in the statement conform to the wildcard's defined type. If the statement perfectly matches the rule's syntax pattern, and all fixed keywords, wildcards, and anchor points match, then the statement is determined to belong to the operation type corresponding to that rule, and a successful match type identifier is recorded. If any part of the statement does not match the rule, the match is considered a failure, and the specific reason for the failure is recorded.

[0044] For scenarios involving no matching or parsing anomalies in the AST, regular expression rules are loaded sequentially according to a preset priority, such as prioritizing high-frequency types. The character-by-character comparison process described above is executed for each rule. If a rule is matched, the traversal terminates. If no match is found after traversing all rules, it is determined that there is no matching rule. If multiple rules are matched during traversal, it is determined that there is a multi-rule match, and the type identifiers and rules of all successfully matched rules are recorded. If the regular expression matches a unique type, this type is used as the final result, overwriting the initial matching result of the AST. If the regular expression matches multiple types, it is marked as a multi-rule match, triggering manual review. If the regular expression has no matching result, it is marked as a type without a match, triggering manual review.

[0045] In this embodiment, text grammar rules are used to supplement the deficiencies of AST semantic parsing. This not only solves the problem of AST adapting to marginal grammars and non-standard writing, but also accurately distinguishes operation types with similar features, ultimately improving the accuracy of operation type matching.

[0046] Step S20: Obtain the similarity between the target operation sequence and the operation type sequence in the preset thinking knowledge base, and determine the thinking text associated with the operation type sequence with the highest similarity as the target thinking text.

[0047] In this embodiment, the preset thinking knowledge base includes the thinking process during the intelligent merging of SQL scripts by the deep thinking big model, and the thinking process text is associated with the operation type of SQL script merging.

[0048] Please refer to Figure 2 The autoregressive generation mechanism of large language models indicates that, under ideal conditions—namely, identical parameters, deterministic decoding, and completely identical context sequences—the intermediate thinking steps generated by the model itself should produce essentially the same results in subsequent answer generation as the same thinking content directly provided by the user. This is because the model relies only on the probability distribution of the current complete context sequence and does not distinguish the source of the token. Based on this theoretical foundation, for the same query, when a deep thinking model generates a thinking process (think) and outputs an answer (answer1) after inputting the query, and a non-deep model directly processes the query + think combination input to generate an answer (answer2), the outputs of the two should have a certain similarity. Furthermore, considering that the token processing efficiency in the prefill stage of large model inference is significantly higher than that in the decoding stage, advancing the generation of intermediate inference steps from the current model's decoding stage to the prefill stage of any model can effectively reduce the overall inference latency. (The following sentence appears to be a separate, unrelated point: "Generated using DeepSeek-R1...") <think>The content was directly concatenated into existing SQL merge suggestions for testing. Comparative experiments were conducted on the same validation set using two general models (7B and 32B parameter sizes). The results showed that this approach significantly improved model performance, thus validating the effectiveness of the left-shift strategy in deep thinking processes.

[0049] Extract all operation type sequences from the thinking knowledge base, apply the same standardization rules as the target sequence to obtain a set of standard operation type sequences from the knowledge base, and retain the association between each sequence and the thinking text and unique identifier. Perform feature vectorization on the operation type sequences from the thinking knowledge base and the target operation sequence. Optionally, feature vectorization can be achieved by counting the number of times each operation type appears in the sequence and generating vectors according to the vocabulary order; or by retaining the sequence order features, assigning a value from the vocabulary to the operation type at each position, padding with zeros if the length is insufficient, such as when the sequence length is fixed at 5. [ALTER, text embedding models such as Word2Vec and BERT convert the entire sequence into a fixed-dimensional semantic vector.]

[0050] Specifically, step S20 may include steps S21 to S23: Step S21: Vectorize the operation types in the target operation sequence to obtain a first vector, and vectorize the operation types in the preset thinking knowledge base to obtain a second vector; Step S22: Obtain the cosine similarity between the first vector and the second vector; Step S23: If the highest cosine similarity is greater than a preset similarity threshold, then the thought text corresponding to the highest cosine similarity is determined as the target thought text.

[0051] Calculate the similarity between the target operation sequence and the operation type sequence in the knowledge base. For count / position vectors, cosine similarity or edit distance can be used; for semantic embedding vectors, cosine similarity is preferred to ensure semantic matching. Traverse the knowledge base vector set and calculate the similarity value for each vector. The cosine similarity formula is: cosθ = (V_target) / (V_target) The similarity is calculated as V_i) / (||V_target||×||V_i||), with a range of [-1, 1]. The closer the result is to 1, the higher the similarity. Here, V_target is the vector value corresponding to the target operation sequence, and V_i is the knowledge base vector. During edit distance calculation, the minimum number of insertion, deletion, and replacement operations required to transform the vector value corresponding to the target operation sequence into an operation type sequence in the knowledge base is calculated. Fewer operations result in higher similarity. The unique identifier and corresponding similarity value of each knowledge base sequence are recorded, forming a key-value pair list of sequence identifiers and similarity values. The maximum similarity value max_sim in the list and the corresponding unique sequence identifier ID_max are marked.

[0052] The search is performed in the knowledge base based on ID_max, matching the unique identifier field to locate the complete record corresponding to that identifier. The content of the thinking text field is extracted from the matched record. If multiple versions of the thinking text exist, a secondary filtering can be performed using similarity values, such as selecting the text with the highest similarity and a confidence level ≥ a preset threshold. If max_sim is lower than the preset threshold, no matching high-similarity thinking text is marked; otherwise, the extracted thinking text is confirmed as the target thinking text. If a high-similarity match exists, the target thinking text is output; if no high-similarity match exists, a message indicating no match is output, along with the second-highest similarity thinking text as an alternative.

[0053] Step S30: Concatenate the target thought text and the initial prompt word to obtain the target prompt word.

[0054] In this embodiment, the target thinking text and the initial prompt are unified into plain text format, and special characters such as line breaks and tabs, as well as extra spaces, are removed to ensure that the concatenated text is free from formatting interference. The two types of text are concatenated according to a preset template. For example, the target prompt obtained after concatenation is [target thinking text content] + please merge the following SQL query statement based on the above rules and reference logic.

[0055] If the length of the concatenated text exceeds the input limit of the non-deep thinking model, it is truncated according to the principle of retaining the core rules of the initial prompt words and the key decision-making basis of the thinking text, ensuring that the core instructions are not lost. A target prompt word containing basic merging rules and reference thinking logic is generated. This prompt word retains the preset merging rules and incorporates highly similar merging thinking logic, providing clear merging guidance for the non-deep thinking model.

[0056] Step S40: Input the target prompt word and the initial operation statement into a preset non-deep thinking model to merge the query statements and obtain the target operation statement.

[0057] It should be noted that the preset non-deep thinking model has no autonomous deep reasoning ability and only performs merging according to the rules in the input prompts.

[0058] In this embodiment, data is assembled according to the input protocol of the non-deep thinking model. If the model requires a key-value pair format of "instruction + input text", a structured input message such as {"prompt": target prompt word, "input_text": standardized initial operation statement} is constructed. The assembled text data is converted to an encoding format supported by the model, such as UTF-8, to ensure no garbled characters. It is confirmed that the overall length of the assembled input does not exceed the model's input limit. If it does, non-core reference logic in the target prompt word is truncated first, while the initial prompt word rules are retained. Then, non-core fields in the query statement, such as redundant filter condition comments, are truncated. Complete input data conforming to the input specifications of the non-deep thinking model is generated, including enhanced target prompt words and standardized query statements.

[0059] The target prompts and initial operation statements are input into a non-deep thinking model via a pre-defined API interface for reasoning. The model first performs semantic segmentation on the input target prompts, distinguishing between basic rule segments and reference thinking logic segments using keywords such as "rule:" and "reference merging logic:". For the basic rule segments, all valid filtering conditions and rules described in natural language based on primary key relationships between multiple tables are retained and transformed into machine-executable structured instructions. For the reference thinking logic segments, core decision parameters are extracted from the natural language thinking text, including the names of the related tables in the statements to be merged, the relationship conditions between tables, and the processing rules for filtering conditions (such as retain / merge / deduplication), forming a set of parameters that can be directly invoked.

[0060] The received standardized initial operation statement is split into multiple independent sub-statements according to a preset delimiter, ensuring that each sub-statement is a complete SQL fragment. Then, each sub-statement is subjected to lexical analysis: the table names involved in the query are located and extracted by matching the "FROM" keyword; the filter conditions (such as id>10, amount>100) are identified and extracted by matching the "WHERE" keyword; the modified fields (such as *, user.name) are extracted by matching the "ALTER" keyword; at the same time, the basic integrity of the sub-statements is verified, and sub-statements with obvious syntactic errors (such as missing the FROM keyword) are marked.

[0061] The extracted sub-statement table names are compared with the parameters of the related tables in the reference logic to confirm the set of tables to be associated. The validity of the association conditions is then verified, checking whether the fields in the association conditions are the primary keys of the corresponding tables. If they meet the basic rules of primary key-based association, they are considered valid; otherwise, the primary key of the table is automatically matched as the default association condition according to the basic rules. Next, the filtering conditions of all sub-statements are processed, removing meaningless or syntactically incorrect invalid conditions such as "1=1"; repeating conditions are retained only once; complementary conditions such as "id>10" and "id<20" are merged into "id>10ANDid<20"; conflicting conditions such as "id>10" and "id<5" are marked with conflict indicators to ensure that all valid conditions are retained and the logic is clear.

[0062] The template matching and initial statement generation model matches corresponding templates from the built-in statement merging template library based on the association types and basic rules in the reference thinking logic. The extracted information is then populated into the templates: the field section integrates the unique fields of all sub-statements; the table and association condition section is filled with the confirmed main table, associated tables, association types, and association conditions; and the filter condition section is filled with the integrated condition strings, ultimately generating a complete merged SQL statement. By converting the unmerged SQL into a sequence of basic SQL operation types, the most relevant deep thinking processes are retrieved from the knowledge base based on the similarity between sequences. These processes are then appended to the original prompt as the final input to the general large model for reasoning, thus achieving a leftward shift to the prefill stage.

[0063] Please refer to Figure 3 A validation set was constructed by extracting 132 production cases based on three scenario dimensions (whether merging is possible, SQL operation type, and number of SQL statements). Accuracy was evaluated using the percentage of accurate cases (defined as merging the most concise state with consistent execution logic) and average response time. This application achieved significantly higher accuracy than the baseline general model and open-source distillation model, improving by 3.8% and 8.3%, respectively. Due to the leftward shift of the deep thinking process, the large model only outputs the final answer during the decoding stage, and a smaller 7B model is used when RAG is hit. This solution resulted in a much shorter average response time than the baseline, reducing end-to-end response time by 82.3%.

[0064] In this embodiment, the deep thinking process of DeepSeek-R1 is "left-shifted" from the decode stage of online inference to the prefill stage of the 7B small-scale model. A structured knowledge base is constructed by classifying and abstracting production-level SQL merging cases, generalizing and simplifying the deep thinking process, and rewriting the SQL query in a structured manner. During online inference, the SQL to be processed is transformed into a standardized sequence, and the matching generalized thinking process is recalled from the knowledge base, concatenated into the prompt, and then input into the small-scale model. This not only reuses the deep thinking capabilities of DeepSeek-R1, but also improves the response speed by leveraging the efficiency of the small-scale model prefill stage.

[0065] Based on the first embodiment of this application, in the second embodiment of this application, the content that is the same as or similar to that in the first embodiment described above can be referred to the above description, and will not be repeated hereafter. Based on this, please refer to... Figure 4 Before step S20, steps A10 to A20 may also be included: Step A10: Input the training data into the preset deep thinking model and merge the query statements. Based on the preset prompts, obtain the thinking process text and operation type of the deep thinking model.

[0066] In this embodiment, based on the reasoning ability of the deep thinking big model, the query statements in the training data are parsed and merged, the model reasoning process and operation type are extracted, and finally this information is structured and stored as a reusable thinking knowledge base.

[0067] The training data contains multiple SQL queries to be merged, statement context, merging rule requirements, etc. Data integrity is verified according to a preset format, and invalid data lacking key information is filtered out. The SQL statements are standardized to uppercase, redundant spaces / comments are removed, and nested statements are split into independent fragments, transforming them into structured text recognizable by the model, resulting in a standardized and structured training data set. Preset prompts include instructions for outputting the merged SQL statement, detailed thought process text, statement merging, conditional integration, table joins, and other operation types.

[0068] The Deep Thinking large-scale model can be DeepSeek-R1. Standardized training data is concatenated with preset prompts to form the model input message, which is sent to the Deep Thinking large-scale model according to the model interface protocol. Based on its built-in SQL syntax knowledge and statement merging rules, the model performs semantic analysis and logical correlation judgment on the multiple input query statements, generating a merged SQL statement and simultaneously outputting a natural language description of the thought process. For example, it first identifies that both statements query tables A and B and have a primary key relationship, therefore merging them using JOIN while retaining common filtering conditions; it also labels the corresponding operation type, such as merging table join statements. The merged SQL statement, thought process text, and operation type labels are obtained, each corresponding one-to-one with and associated with the original statements to be merged.

[0069] Step A20: Generate the thinking knowledge base based on the thinking process text and the operation type.

[0070] In this embodiment, the thought process text is parsed in a structured manner, and key information is extracted through natural language processing (NLP), which is then broken down into structured fields such as analysis steps, decision basis, and application of merging rules. The operation type labels are standardized and mapped, and the non-standard labels output by the model are uniformly mapped to a preset standard operation type system. The statements are merged into conditional integration types. The relationship between the original statements to be merged, the merged statements, the structured thought process, and the standard operation types is established to form a structured data record.

[0071] Define a storage structure including fields such as primary key, original statement hash value, merged statement, structured fields of the thought process, standard operation type, and creation time. Write the structured reasoning information line by line into the knowledge base storage medium. Create indexes for high-frequency retrieval dimensions such as original statement hash value, operation type, and related table names to improve subsequent query efficiency. This forms a searchable and reusable thought knowledge base that stores the reasoning logic, operation type, and result mapping relationship of the model's merged SQL query statements. It supports quick retrieval of the corresponding thought process and merging scheme based on operation type or original statement characteristics.

[0072] Based on the first embodiment of this application, in the third embodiment of this application, the content that is the same as or similar to that in the first embodiment described above can be referred to the above description and will not be repeated hereafter. Furthermore, step S40 may also include steps S41 to S43: Step S41: When the matching score between the initial operation statement and the basic operation type sequence is less than a preset matching score threshold, or the thinking fit is less than a preset thinking fit threshold, then the initial operation statement is determined as the second query statement. In this embodiment, to address the issue of insufficient recall in long-tail scenarios for RAG (Recall Aggregator), a fallback model is constructed based on historical data distillation. For example, a dedicated model is constructed based on bank production data. The core technology involves shifting the deep thinking process to the prefill stage, combined with the dedicated distillation model, forming a dual-path engineering solution.

[0073] In one feasible implementation, before step S41, the following steps may be included: obtaining the table association number matching degree, condition complexity matching degree, and operation type matching degree between the initial operation statement and the target thinking text; performing a weighted calculation on the table association number matching degree, the condition complexity matching degree, and the operation type matching degree to obtain the thinking fit degree.

[0074] For the initial operation statement, extract the number of table joins, condition complexity, and operation type combination. The number of table joins represents the number of tables involved in the statement; condition complexity represents the sum of the number of filtering conditions and the nesting level of the conditions; operation type combination represents the combination pattern of the core operation types, such as ALTER+INDEX denoted as pattern A, and INSERT+UPDATE denoted as pattern B. For the thought text associated with the candidate operation type sequence in the knowledge base, extract the range of the number of table joins that fits in the thought text (e.g., fitting 2-4 table joins); the range of condition complexity that fits in the thought text; and the operation type combination pattern that fits in the thought text (e.g., only fitting pattern A).

[0075] For each feature dimension, a matching score is calculated. For the table join count matching score, if the number of table joins in the query statement is within the range of the thought text's adaptation, 100 points are awarded; if it exceeds the range, points are deducted based on the difference. For example, if the query matches tables 2-4 and the statement matches table 1, a difference of 1 deducts 20 points, resulting in 80 points; a difference of ≥3 results in 0 points. The rules for condition complexity matching score are the same. For the operation type combination matching score, if the statement combination pattern matches the thought text's adaptation pattern, 100 points are awarded; partial matches result in 50 points; and complete inconsistencies result in 0 points. Weights are assigned according to feature importance, such as 40% for table join count, 40% for condition complexity, and 20% for operation type combination, and a weighted calculation is performed to obtain the thought text adaptation score.

[0076] The system retrieves the matching scores of the initial operation statement and all candidate basic operation type sequences, taking the highest score as the final matching score for that statement. Based on the optimal matching operation type sequence, it retrieves the associated thought text, calls the thought fit calculation logic, and obtains the thought fit score for that statement. A matching score threshold is set based on the average matching effect of RAG on general statements in the business scenario; an example value of 80 points represents the minimum score at which RAG can stably output effective matching results. A score below this value is considered insufficient. A thought text fit data is set based on historical long-tail statements; an example value of 75 points represents the minimum fit that the logic of the thought text can support statement merging; a score below this value is considered that the thought logic cannot fit the current statement.

[0077] If the matching score between the initial operation statement and the basic operation type sequence is less than a preset matching score threshold, or the thinking fit is less than a preset thinking fit threshold, the initial operation statement is marked as a second query statement, and the reason for the determination is recorded. If the matching score is greater than or equal to the matching score threshold and the thinking fit is greater than or equal to the thinking fit threshold, it is determined to be a RAG-processable statement. The RAG process is then followed to match the corresponding operation type sequence and thinking text, completing the statement merging.

[0078] Step S42: Input the second query statement into the preset distillation model, merge the query statements, and obtain the target operation statement.

[0079] In this embodiment, a knowledge base is constructed based on production data collected from a database design management platform, and the deep thinking process is shifted leftward using RAG (Real-Time Augmentation). In scenarios where RAG fails to capture the target data and the generalized deep thinking process cannot be applied, a variety of data augmentation schemes are used to expand the training dataset. Based on this training dataset, a large deep thinking model is distilled to extract knowledge, which is then passed to smaller models to obtain distilled models. For example, DeepSeek-R1 is used to distill Qwen2.5-32B-Base to obtain CMB-Distill-SQL-32B, which is then used as a fallback model.

[0080] In one feasible implementation, the data augmentation scheme includes multi-evolution, random combination, and similarity filtering. A single complete SQL statement is lexically / syntactically parsed using an SQL Parser tool, breaking it down into multiple sub-SQL statements. For example, "ALTERTABLE 'product' ADD COLUMN 'stock' INT, DROP INDEX 'idx_sales'" is split into two sub-statements: "ALTERTABLE 'product' ADD COLUMN 'stock' INT" and "ALTER TABLE 'product' DROP INDEX 'idx_sales'". This splitting expands the sample size. The order of the split sub-SQL statements and the original SQL is adjusted, such as changing the order of filtering conditions and table joins. Simultaneously, some SQL statements are integrated across scripts, such as merging similar table join statements from different business scripts, enriching sample diversity and covering more long-tail combination scenarios. Using the SQL operation type sequence, table name, and filtering conditions as features, the similarity between all samples is calculated. Highly repetitive samples with similarity ≥ a preset similarity threshold are filtered out, retaining differentiated samples and preventing model overfitting. Training data is obtained based on the original data and the augmented data.

[0081] Using DeepSeek-R1's distillation logic and augmented data, a dedicated fallback model is fine-tuned. Optionally, Qwen2.5-32B-Base is chosen as the base model for distillation; distributed training parallel parameters are set: data parallelism (data_parallel = 2), splitting the data across two devices for parallel computation; model parallelism (model_parallel = 8), splitting the model parameters across eight devices; pipeline parallelism (pipeline_stage = 1), a single-stage pipeline adapted to the 32B model scale, ensuring training efficiency. The AdamW optimizer is selected, with a learning rate of 2×10⁻⁶. -5 The training consists of two rounds.

[0082] The labeled original statements, merged statements, and thought process samples are input into the model in batches, with the batch size adapted to the hardware computing power. This allows the small model to learn the deep thinking ability of the large model in SQL merging tasks, such as table join logic, condition integration rules, and long-tail scenario adaptation logic. Full parameter fine-tuning is performed to adapt all model parameters to the SQL merging scenario. During training, the loss value and validation set accuracy are monitored to ensure convergence. After training, the model performance is verified using a test set.

[0083] The marked second query statement is standardized and transformed into a format that the fallback model can parse. The preprocessed second query statement is then input into the deployed fallback model. Based on the deep thinking ability learned by distillation (such as table association rules and condition integration logic in long-tail scenarios), the model autonomously completes the SQL statement merging and outputs the merged initial statement, along with the merging thought process. The merged statement output by the model is then subjected to syntax validation and business rule validation to finally obtain a compliant and accurate target operation statement.

[0084] Please refer to Figure 5 The RAG hit path integrates the generalized deep thinking process into the prefill stage, using the 7B model to achieve a balance between effectiveness and timeliness; the RAG miss fallback path: uses a distillation model to handle miss scenarios while establishing a new case (completely new scenario cases) and bad case (poorly performing cases) feedback mechanism to continuously update the knowledge base and continuously improve effectiveness through an iterative closed loop.

[0085] Based on the first embodiment of this application, in the fourth embodiment of this application, the content that is the same as or similar to that in the first embodiment described above can be referred to the above description and will not be repeated hereafter. Furthermore, before step S40, steps S50 to S70 may be included: Step S50: Determine the newly added query statements and the query statements that do not meet the criteria based on the preset filtering rules; Step S60: Input the newly added query statement and the unqualified query statement into a preset deep thinking model to generate new thinking text; Step S70: Update the thinking knowledge base based on the newly added thinking text.

[0086] It's important to clarify that "new cases" refer to entirely new scenario examples encountered for the first time and not covered by the existing knowledge base. Examples include special SQL queries from new business lines and table join logic that has never appeared before, which may result in retrieval failures or extremely poor processing performance under existing rules. "Bad cases" refer to cases that can match knowledge base content or be processed, but the final result is not as expected or performs poorly. Examples include cases where the matching score is near the threshold, the merged SQL statement contains business logic errors, or the model's processing accuracy does not meet the standards.

[0087] In this embodiment, SQL processing records are read from the log table, including structured fields such as initial operation statement, matching score, thinking fit, model processing result, accuracy, and business tags. New query statements and non-compliant query statements are filtered according to preset numerical rules. For example, a matching score < 80 and model accuracy < 80, with no corresponding operation sequence in the knowledge base, is determined to be a new query statement; a matching score of 75-80 and accuracy of 60-80, with ≥ 3 similar cases, is determined to be a non-compliant query statement. A unique identifier is generated for each query and its type is marked.

[0088] The system automatically parses new queries using the Deep Thinking Model interface, generating new operation type sequences and structured thinking processes. It identifies the root causes of new and non-compliant queries, optimizes existing sequences and thinking logic, and outputs a parsing result table containing corrections. The system reads the parsing results and the existing knowledge base, automatically deduplicating them by calculating similarity. Non-duplicate content is incrementally written to the knowledge base, generating unique identifiers and iteration version numbers, while backing up older versions. The system reads the updated knowledge base, test set, and metric configuration table, automatically calling the RAG+ fallback model to process test set SQL and calculate core metrics such as recall and precision. Based on whether the metrics meet the standards, it automatically triggers the next round of case collection or backtracks to optimize the model and knowledge base.

[0089] This application provides a deep thinking process left-shifting SQL merging device, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to execute the deep thinking process left-shifting SQL merging method of Embodiment 1 described above.

[0090] The following is for reference. Figure 6 The diagram illustrates a structural schematic of an SQL merging device suitable for implementing a left-shifting deep thinking process according to embodiments of this application. The SQL merging device for left-shifting deep thinking processes in embodiments of this application may include, but is not limited to, mobile terminals such as mobile phones, laptops, personal digital assistants (PDAs), tablet computers (PADs), and in-vehicle terminals (e.g., in-vehicle navigation terminals), as well as fixed terminals such as digital TVs and desktop computers. Figure 6 The SQL merging device with a leftward shift in the deep thinking process shown is merely an example and should not impose any limitations on the functionality and scope of use of the embodiments of this application.

[0091] like Figure 6 As shown, the SQL merging device with left-shifting deep thinking process may include a processing unit 1001 (e.g., a central processing unit, a graphics processing unit, etc.) that can perform various appropriate actions and processes according to a program stored in read-only memory (ROM) 1002 or a program loaded from storage device 1003 into random access memory (RAM) 1004. The random access memory 1004 also stores various programs and data required for the operation of the SQL merging device with left-shifting deep thinking process. The processing unit 1001, ROM 1002, and RAM 1004 are interconnected via a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Typically, the following systems can be connected to I / O interface 1006: input devices 1007 including, for example, touchscreens, touchpads, keyboards, mice, image sensors, microphones, accelerometers, gyroscopes, etc.; output devices 1008 including, for example, liquid crystal displays (LCDs), speakers, vibrators, etc.; storage devices 1003 including, for example, magnetic tapes, hard disks, etc.; and communication devices 1009. Communication device 1009 allows the SQL merging device for left-shifting deep thinking processes to communicate wirelessly or wiredly with other devices to exchange data. Although the figure shows an SQL merging device for left-shifting deep thinking processes with various systems, it should be understood that it is not required to implement or have all the systems shown. More or fewer systems can be implemented or have alternatively.

[0092] Specifically, according to the embodiments disclosed in this application, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments disclosed in this application include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device, or installed from storage device 1003, or installed from read-only memory 1002. When the computer program is executed by processing device 1001, it performs the functions defined in the methods of the embodiments disclosed in this application.

[0093] The SQL merging device with left-shifted deep thinking process provided in this application, employing the SQL merging method with left-shifted deep thinking process described in the above embodiments, can solve the technical problem of how to allocate sequences corresponding to training data, thereby reducing resource waste caused by invalid padding. Compared with the prior art, the beneficial effects of the SQL merging device with left-shifted deep thinking process provided in this application are the same as those of the SQL merging method with left-shifted deep thinking process described in the above embodiments, and other technical features in this SQL merging device with left-shifted deep thinking process are the same as those disclosed in the method of the previous embodiment, and will not be repeated here.

[0094] It should be understood that the various parts disclosed in this application can be implemented using hardware, software, firmware, or a combination thereof. In the description of the above embodiments, specific features, structures, materials, or characteristics can be combined in any suitable manner in one or more embodiments or examples.

[0095] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

[0096] This application provides a computer-readable storage medium having computer-readable program instructions (i.e., a computer program) stored thereon, the computer-readable program instructions being used to execute the SQL merging method for left shifting the deep thinking process in the above embodiments.

[0097] The computer-readable storage medium provided in this application may be, for example, a USB flash drive, but is not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems or devices, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to: electrical connections having one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system or device. The program code contained on the computer-readable storage medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, radio frequency (RF), etc., or any suitable combination thereof.

[0098] The aforementioned computer-readable storage medium may be included in the SQL merging device for left-shifting deep thinking processes; or it may exist independently and not assembled into the SQL merging device for left-shifting deep thinking processes. The aforementioned computer-readable storage medium carries one or more programs that, when executed by the SQL merging device for left-shifting deep thinking processes, cause the SQL merging device to: match an initial operation statement with a preset basic operation type sequence to obtain a target operation sequence corresponding to the initial operation statement; obtain the similarity between the target operation sequence and operation type sequences in a preset thinking knowledge base, and determine the thinking text associated with the operation type sequence with the highest similarity as the target thinking text; concatenate the target thinking text with an initial prompt word to obtain a target prompt word; and input the target prompt word and the initial operation statement into a preset non-deep thinking model for query statement merging to obtain the target operation statement.

[0099] Computer program code for performing the operations of this application can be written in one or more programming languages ​​or a combination thereof, including object-oriented programming languages ​​such as Java, Smalltalk, and C++, as well as conventional procedural programming languages ​​such as "C" or similar programming languages. The program code can be executed entirely on the client computer, partially on the client computer, as a standalone software package, partially on the client computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the client computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0100] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.

[0101] The modules described in the embodiments of this application can be implemented in software or hardware. The names of the modules do not necessarily limit the functionality of the unit itself.

[0102] The readable storage medium provided in this application is a computer-readable storage medium that stores computer-readable program instructions (i.e., a computer program) for executing the SQL merging method of left shifting in the deep thinking process described above. This solves the technical problem of how to allocate sequences corresponding to training data, thereby reducing resource waste caused by invalid padding. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided in this application are the same as those of the SQL merging method of left shifting in the deep thinking process provided in the above embodiments, and will not be repeated here.

[0103] The above description is only a part of the embodiments of this application and does not limit the patent scope of this application. All equivalent structural transformations made under the technical concept of this application and using the contents of the specification and drawings of this application, or direct / indirect applications in other related technical fields, are included in the patent protection scope of this application.< / think>

Claims

1. A SQL merging method with left-shifting in a deep thinking process, characterized in that, The SQL merging method for left-shifting the deep thinking process includes: The initial operation statement is matched with a preset sequence of basic operation types to obtain the target operation sequence corresponding to the initial operation statement; Obtain the similarity between the target operation sequence and the operation type sequence in the preset thinking knowledge base, and determine the thinking text associated with the operation type sequence with the highest similarity as the target thinking text; The target thought text and the initial prompt words are concatenated to obtain the target prompt words; The target prompt and the initial operation statement are input into a preset non-deep thinking model to merge the query statements and obtain the target operation statement.

2. The SQL merging method for left-shifting the deep thinking process as described in claim 1, characterized in that, Before the step of obtaining the similarity between the target operation sequence and the operation type sequences in the preset thinking knowledge base, and determining the thinking text associated with the operation type sequence with the highest similarity as the target thinking text, the SQL merging method for left-shifting the deep thinking process further includes: The training data is input into a preset deep thinking model and the query statements are merged. Based on the preset prompts, the thinking process text and operation type of the deep thinking model are obtained. The thought process text and the operation type are used to generate the thought knowledge base.

3. The SQL merging method for left-shifting the deep thinking process as described in claim 1, characterized in that, The step of matching the initial operation statement with a preset sequence of basic operation types to obtain the target operation sequence corresponding to the query statement includes: Based on preset SQL syntax rules, the initial operation statement is converted into an abstract syntax tree; Traverse the tree nodes of the abstract syntax tree to determine the operation type and operation object in the initial operation statement; Match the operation type and the operation object with the basic operation type sequence; If the operation type and the operation object are completely matched, the target operation sequence is obtained based on the matching result.

4. The SQL merging method for left-shifting the deep thinking process as described in claim 3, characterized in that, Following the step of matching the operation type and the operation object with the basic operation type sequence, the deep thinking process left-shifting SQL merging method further includes: If the operation type and the operation object partially match, or if the match fails, then obtain the corresponding regular expression rule; The regular expression rules are parsed based on a preset regular expression engine, and the regular expression rules are transformed from character form into a syntax pattern tree to obtain the matching logic corresponding to the regular expression rules. The matching logic that matches fixed keywords, wildcards, and anchors is determined as the target matching logic; Based on the target matching logic, the initial operation statement is converted into the target operation sequence.

5. The SQL merging method for left-shifting the deep thinking process as described in claim 1, characterized in that, The step of obtaining the similarity between the target operation sequence and the operation type sequences in the preset thinking knowledge base, and determining the thinking text associated with the operation type sequence with the highest similarity as the target thinking text, includes: The operation types in the target operation sequence are vectorized to obtain a first vector, and the operation types in the preset thinking knowledge base are vectorized to obtain a second vector; Obtain the cosine similarity between the first vector and the second vector; If the highest cosine similarity is greater than the preset similarity threshold, then the thought text corresponding to the highest cosine similarity is determined as the target thought text.

6. The SQL merging method for left-shifting the deep thinking process as described in claim 1, characterized in that, Before the step of merging the target prompt and the initial operation statement into a preset non-deep thinking model to obtain the target operation statement, the SQL merging method for left-shifting the deep thinking process further includes: If the matching score between the initial operation statement and the basic operation type sequence is less than a preset matching score threshold, or the thinking fit is less than a preset thinking fit threshold, then the initial operation statement is determined as the second query statement. The second query statement is input into a preset distillation model, and the query statements are merged to obtain the target operation statement.

7. The SQL merging method for left-shifting the deep thinking process as described in claim 6, characterized in that, Before the step of determining the initial operation statement as the second query statement when the matching score between the initial operation statement and the basic operation type sequence is less than a preset matching score threshold, or the thinking fit is less than a preset thinking fit threshold, the SQL merging method for left-shifting the deep thinking process includes: Obtain the table association matching degree, condition complexity matching degree, and operation type matching degree between the initial operation statement and the target thinking text; The matching degree of the table association number, the matching degree of the condition complexity, and the matching degree of the operation type are weighted and calculated to obtain the thinking fit degree.

8. The SQL merging method for left-shifting the deep thinking process as described in claim 1, characterized in that, The left-shifting SQL merging method in the deep thinking process also includes: New and non-compliant query statements are determined based on preset filtering rules; The newly added query statement and the query statement that did not meet the standard are input into a preset deep thinking model to generate new thinking text; The thinking knowledge base is updated based on the newly added thinking text.

9. A SQL merging device for left-shifting deep thinking processes, characterized in that, The device includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, the computer program being configured to implement the steps of the SQL merge method for left shifting of the deep thinking process as claimed in any one of claims 1 to 8.

10. A storage medium, characterized in that, The storage medium is a computer-readable storage medium, on which a computer program is stored, which, when executed by a processor, implements the steps of the SQL merge method for left shifting the deep thinking process as described in any one of claims 1 to 8.