Statement conversion method and device, computer equipment and storage medium

By constructing a syntax tree and generating an abstract syntax tree, combined with training a model and compatibility testing, a high-accuracy cross-database DDL statement conversion was achieved, solving the problem of inconsistent conversion results in existing technologies and improving the automation and accuracy of migration.

CN121807876APending Publication Date: 2026-04-07SHANGHAI PUDONG DEVELOPMENT 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-11-25
Publication Date
2026-04-07

AI Technical Summary

Technical Problem

Existing database migration tools lack self-learning and error correction capabilities, resulting in insufficient consistency and reliability of cross-database DDL statement conversion results, and failing to complete automated conversion with high accuracy.

Method used

By constructing a syntax tree for the initial statement, identifying the syntactic relationships between nodes, generating an abstract syntax tree, and performing synonym conversion, a statement recognizable by the target database is generated. The trained statement conversion model is used to handle conversion failure nodes, perform compatibility checks and word replacements, and ensure that the conversion results conform to the target database specifications.

Benefits of technology

It significantly improves the accuracy, automation, and versatility of database statement migration, reduces compatibility issues caused by syntax differences and manual adaptation costs, and ensures the integrity and accuracy of cross-database migration.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121807876A_ABST
    Figure CN121807876A_ABST
Patent Text Reader

Abstract

The invention relates to a statement conversion method and device, computer equipment and a storage medium. The method comprises the steps of obtaining an initial statement to be subjected to semantic conversion; the initial statement is a statement which can be identified by the first database; performing grammar recognition on the initial statement, and constructing a grammar tree of the initial statement; nodes in the syntax tree represent statement vocabularies in the initial statement; the node information of different nodes comprises grammar information of corresponding statement vocabularies in the initial statement; the relationship among different nodes is a grammatical relationship among corresponding statement vocabularies; according to semantic types of different nodes in the syntax tree, performing semantic conversion on the syntax information in the syntax tree to obtain an abstract syntax tree; performing synonymous conversion on the node vocabularies in the abstract syntax tree to obtain a target statement; the target statement is a statement which can be identified by the second database. By adopting the method, statement conversion can be accurately carried out.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of database technology, and in particular to a statement conversion method, apparatus, computer device, and storage medium. Background Technology

[0002] With the rapid development of database technology, enterprise applications are increasingly demanding data storage, processing, and migration capabilities, especially in critical industries such as finance and telecommunications. Smooth database migration and compatibility assurance have become crucial aspects of system upgrades and architectural evolution. Against this backdrop, various database syntax conversion technologies have emerged, aiming to achieve statement compatibility and automated migration between different database systems.

[0003] In traditional technologies, database migration often relies on manually writing conversion scripts or using basic syntax matching tools. For example, when migrating Informix's Data Definition Language (DDL) to GoldenDB, technicians typically need to analyze the structure and semantics of each Informix statement and then manually rewrite or adapt them according to GoldenDB's syntax specifications. While some tools have some syntax recognition capabilities, they still primarily rely on keyword replacement and simple rule matching, lacking an understanding of the overall structure and deep semantics of the statements.

[0004] However, existing tools generally lack self-learning and error correction capabilities, and cannot progressively optimize mapping rules during the conversion process, resulting in insufficient consistency and reliability of the conversion results. Therefore, there is an urgent need for a technical solution that can automate and accurately complete the conversion of cross-database DDL statements. Summary of the Invention

[0005] Therefore, it is necessary to provide a statement conversion method, apparatus, computer equipment, and storage medium that can accurately perform statement conversion in response to the above-mentioned technical problems.

[0006] Firstly, this application provides a statement conversion method, including:

[0007] Obtain the initial statement to be semantically transformed; the initial statement is a statement that the first database can recognize;

[0008] The initial statement is subjected to grammar recognition, and a syntax tree is constructed for the initial statement. The nodes in the syntax tree represent the vocabulary of the initial statement. The node information of different nodes includes the grammatical information of the corresponding vocabulary in the initial statement. The relationship between different nodes is the grammatical relationship between the corresponding vocabulary.

[0009] Based on the semantic types of different nodes in the syntax tree, the grammatical information in the syntax tree is semantically transformed to obtain an abstract syntax tree;

[0010] The node words in the abstract syntax tree are transformed into synonyms to obtain the target statement; the target statement is a statement that the second database can recognize.

[0011] In one embodiment, syntax recognition is performed on the initial statement, and a syntax tree for the initial statement is constructed, including:

[0012] Extract the vocabulary from the initial statement and construct a vocabulary sequence based on the order of the vocabulary in the initial statement;

[0013] Syntax recognition is performed on the word sequence to construct the syntax tree of the initial statement.

[0014] In one embodiment, the syntax tree is semantically transformed according to the semantic types of different nodes in the syntax tree to obtain an abstract syntax tree, including:

[0015] Based on the semantic type of different nodes in the syntax tree, the syntax tree is pruned to update the syntax tree;

[0016] For nodes whose semantic type belongs to the first preset type, semantic transformation is performed on the nodes based on preset semantic transformation rules to obtain an abstract syntax tree; the first preset type is a semantic type that can only be recognized by the first database.

[0017] In one embodiment, the syntax tree is pruned according to the semantic types of different nodes in the syntax tree to update the syntax tree, including:

[0018] Delete nodes in the syntax tree whose semantic type is symbolic in order to update the syntax tree;

[0019] Nodes in the syntax tree whose semantic type belongs to the second preset type are merged to update the syntax tree again; the second preset type includes at least one of table name type, column name type and constraint type.

[0020] In one embodiment, the method further includes:

[0021] Extract the target node from the abstract syntax tree where the statement transformation failed;

[0022] Based on the trained sentence conversion model, the target mapping relationship of the target node is determined according to the node information of the target node; the target mapping relationship represents that the first word and the second word of the target node are synonymous; the first word is a word that can be recognized by the first database; the second word is a word that can be recognized by the second database.

[0023] Based on the target mapping relationship, the vocabulary of the sentences represented by the target node is transformed to obtain the target vocabulary of the target node;

[0024] Update the target sentence based on the target vocabulary.

[0025] In one embodiment, the method further includes:

[0026] Based on the preset compatibility exception type, the semantic type of different words in the target statement is checked for compatibility, and the compatibility check result of the target statement is determined.

[0027] If the compatibility test result is incompatible, for the incompatible words in the target statement, find the replacement words that match the incompatible words from the preset word mapping library, and update the target statement based on the replacement words.

[0028] Secondly, this application also provides a sentence conversion apparatus, comprising:

[0029] The acquisition module is used to acquire the initial statement to be semantically converted; the initial statement is a statement that the first database can recognize.

[0030] The construction module is used to perform syntax recognition on the initial statement and build a syntax tree for the initial statement; the nodes in the syntax tree represent the vocabulary of the initial statement; the node information of different nodes includes the grammatical information of the corresponding vocabulary in the initial statement; the relationship between different nodes is the grammatical relationship between the corresponding vocabulary.

[0031] The transformation module is used to semantically transform the grammatical information in the syntax tree according to the semantic type of different nodes in the syntax tree, so as to obtain an abstract syntax tree;

[0032] The target module is used to perform synonym conversion on the node words in the abstract syntax tree to obtain the target statement; the target statement is a statement that the second database can recognize.

[0033] Thirdly, this application also provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to perform the following steps:

[0034] Obtain the initial statement to be semantically transformed; the initial statement is a statement that the first database can recognize;

[0035] The initial statement is subjected to grammar recognition, and a syntax tree is constructed for the initial statement. The nodes in the syntax tree represent the vocabulary of the initial statement. The node information of different nodes includes the grammatical information of the corresponding vocabulary in the initial statement. The relationship between different nodes is the grammatical relationship between the corresponding vocabulary.

[0036] Based on the semantic types of different nodes in the syntax tree, the grammatical information in the syntax tree is semantically transformed to obtain an abstract syntax tree;

[0037] The node words in the abstract syntax tree are transformed into synonyms to obtain the target statement; the target statement is a statement that the second database can recognize.

[0038] Fourthly, this application also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, performs the following steps:

[0039] Obtain the initial statement to be semantically transformed; the initial statement is a statement that the first database can recognize;

[0040] The initial statement is subjected to grammar recognition, and a syntax tree is constructed for the initial statement. The nodes in the syntax tree represent the vocabulary of the initial statement. The node information of different nodes includes the grammatical information of the corresponding vocabulary in the initial statement. The relationship between different nodes is the grammatical relationship between the corresponding vocabulary.

[0041] Based on the semantic types of different nodes in the syntax tree, the grammatical information in the syntax tree is semantically transformed to obtain an abstract syntax tree;

[0042] The node words in the abstract syntax tree are transformed into synonyms to obtain the target statement; the target statement is a statement that the second database can recognize.

[0043] Fifthly, this application also provides a computer program product, including a computer program that, when executed by a processor, performs the following steps:

[0044] Obtain the initial statement to be semantically transformed; the initial statement is a statement that the first database can recognize;

[0045] The initial statement is subjected to grammar recognition, and a syntax tree is constructed for the initial statement. The nodes in the syntax tree represent the vocabulary of the initial statement. The node information of different nodes includes the grammatical information of the corresponding vocabulary in the initial statement. The relationship between different nodes is the grammatical relationship between the corresponding vocabulary.

[0046] Based on the semantic types of different nodes in the syntax tree, the grammatical information in the syntax tree is semantically transformed to obtain an abstract syntax tree;

[0047] The node words in the abstract syntax tree are transformed into synonyms to obtain the target statement; the target statement is a statement that the second database can recognize.

[0048] The aforementioned statement conversion method, apparatus, computer equipment, and storage medium, by constructing a syntax tree of the initial statements and identifying the syntactic relationships between nodes, convert statements recognizable by the first database into an abstract syntax tree with universal semantic expression. Then, based on the semantic types of the nodes, cross-database conversion of syntactic information is achieved, and finally, a target statement compatible with the second database is generated through synonym substitution. This method preserves the structural information and semantic logic of the statements during the conversion process, effectively improving the accuracy, automation, and universality of database statement migration, and significantly reducing compatibility issues caused by syntactic differences and the cost of manual adaptation. Attached Figure Description

[0049] To more clearly illustrate the technical solutions in the embodiments or related technologies of this application, the accompanying drawings used in the description of the embodiments or related technologies will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0050] Figure 1 This is an application environment diagram of a statement conversion method provided in this embodiment;

[0051] Figure 2 This is a flowchart illustrating the first statement conversion method provided in this embodiment;

[0052] Figure 3 This is a flowchart illustrating the steps of an abstract syntax tree provided in this embodiment;

[0053] Figure 4 This is a flowchart illustrating a step for updating a target statement, as provided in this embodiment.

[0054] Figure 5 This is a flowchart illustrating a step for updating a target statement, as provided in this embodiment.

[0055] Figure 6 This is a structural block diagram of a statement conversion device provided in this embodiment;

[0056] Figure 7 This is an internal structural diagram of a computer device provided in this embodiment. Detailed Implementation

[0057] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.

[0058] The statement conversion method provided in this application embodiment can be applied to, for example, Figure 1In the application environment shown, terminal 102 communicates with server 104 via a network. A data storage system can store the data that server 104 needs to process. The data storage system can be integrated onto server 104 or placed on a cloud or other network server. The computer device acquires the initial statement to be semantically converted; the initial statement is a statement that the first database can recognize; syntactic recognition is performed on the initial statement to construct a syntax tree; nodes in the syntax tree represent the vocabulary in the initial statement; the node information of different nodes includes the syntactic information of the corresponding vocabulary in the initial statement; the relationship between different nodes is the syntactic relationship between the corresponding vocabulary; based on the semantic type of different nodes in the syntax tree, semantic conversion is performed on the syntactic information in the syntax tree to obtain an abstract syntax tree; synonym conversion is performed on the node vocabulary in the abstract syntax tree to obtain the target statement; the target statement is a statement that the second database can recognize. Terminal 102 can be, but is not limited to, various personal computers, laptops, smartphones, tablets, IoT devices, and portable wearable devices. IoT devices can be smart speakers, smart TVs, smart air conditioners, smart in-vehicle devices, etc. Portable wearable devices can be smartwatches, smart bracelets, head-mounted devices, etc. Server 104 can be implemented using a standalone server or a server cluster consisting of multiple servers.

[0059] In one exemplary embodiment, such as Figure 2 As shown, a statement conversion method is provided, which can be applied to... Figure 1 Taking a computer device as an example, the explanation includes the following steps S201 to S204. Wherein:

[0060] S201 retrieves the initial statement to be semantically transformed.

[0061] The initial statement is a statement that the first database can recognize. For example, the initial statement can be a Data Definition Language (DDL) statement of the Informix database, which serves as the raw content received by the input layer.

[0062] In some embodiments, the system automatically reads all DDL statements from a .xml or .sql file provided by the user.

[0063] It should be noted that, to ensure the consistency of input content, this embodiment can also perform encoding standardization, validity verification, and integrity checks after receiving the DDL. Encoding standardization converts all input to UTF-8 format to avoid parsing errors caused by encoding differences. Validity verification checks whether the input content is empty, contains illegal characters, or contains unclosed parentheses or quotation marks. Integrity checks confirm that the input DDL statement is a complete statement ending with a semicolon; if missing, it is automatically completed or a prompt is given to the user.

[0064] It should be noted that, furthermore, before formally entering the syntax analysis stage, this embodiment can also preprocess the received DDL statements to ensure they can be correctly parsed. Preprocessing can include comment cleanup, whitespace handling, and statement segmentation. Comment cleanup can remove single-line comments (starting with --) and multi-line comments ( / *...* / ) to avoid non-syntactic content interfering with analysis. Whitespace handling can remove redundant spaces, newlines, and tabs to standardize statement formatting. Statement segmentation can use semicolons as delimiters to divide the input content into multiple independent DDL statements, assigning each statement a unique number for easy subsequent tracking.

[0065] It should be noted that this embodiment can also store the standardized DDL statement in a buffer, along with a source identifier, location information, and a timestamp. The source identifier indicates whether the statement originated from a file, command line, or remote interface. The location information records the line and column positions of the statement in the original input, facilitating subsequent debugging or error localization. The timestamp records the time the input was received, ensuring process traceability.

[0066] S202 performs syntax recognition on the initial statement and constructs a syntax tree for the initial statement.

[0067] The syntax tree, a hierarchical structure generated through lexical and syntactic analysis, fully represents the syntactic information and relationships of each word in the initial statement (such as Informix DDL), including all grammar-related nodes (such as keywords, identifiers, delimiters, etc.) and their nesting rules. Nodes in the syntax tree represent the vocabulary of the initial statement; the node information of different nodes includes the syntactic information of the corresponding vocabulary in the initial statement; and the relationships between different nodes represent the syntactic relationships between the corresponding vocabulary.

[0068] In one alternative embodiment, a syntax tree of the initial statement is constructed based on a syntax recognition algorithm.

[0069] In one alternative embodiment, the vocabulary of the initial statement is extracted, and a vocabulary sequence is constructed according to the order of the vocabulary in the initial statement; the vocabulary sequence is then subjected to grammar recognition to construct a syntax tree for the initial statement.

[0070] For example, this embodiment can construct a word sequence based on preset lexical rules and the order of words in the initial statement. For instance, it can classify the smallest syntactic units that may appear in the Informix DDL; read the character stream; read the input DDL statement character by character in sequence; and determine the token to which the current character belongs based on the rules to obtain a token sequence, for example:

[0071] [CREATE][TABLE][my_table][(][id][INT][PRIMARY][KEY][,][name][VARCHAR][(]

[50] [)][)].

[0072] Keywords include CREATE, TABLE, INDEX, PRIMARY, FOREIGN, etc. Identifiers include table names, column names, and index names; literals include numbers, strings, dates, etc. Separators include commas, parentheses, and semicolons; operators include equal signs, greater than signs, and less than signs, etc.

[0073] It should be noted that when a complete morpheme (such as "VARCHAR" or "NOTNULL") is encountered, a corresponding token is generated immediately. Each token includes: type (keyword / identifier / literal, etc.), primitive value (such as "VARCHAR"), position (row number, column number), and error handling. If an unrecognized character (such as an illegal symbol) is encountered, an error token is generated, and the error message is recorded.

[0074] For example, this embodiment can perform grammar recognition on a lexical sequence based on preset grammar rules to construct a syntax tree for an initial statement. The following example illustrates how InformixDDL's syntax is defined using BNF:

[0075] <create_table_stmt> ::=CREATETABLE<table_name> (<column_def_list> [<table_constraint_list> ]);

[0076] <column_def> ::=<col_name><data_type> [<column_constraint_list> ];

[0077] <data_type> ::=INT|VARCHAR( <number>)|DECIMAL( <number> , <number>).

[0078] Starting from the beginning of the token sequence, match step by step according to the grammar; upon matching CREATETABLE, proceed to...<create_table_stmt> Branch; Identify table name my_table → Enter<table_name> Encounter (→ Enter)<column_def_list> ; Parse each column definition according to the rules until a ); Generate a ParseTree, where each grammar rule corresponds to a node in the ParseTree. Among them, the preset grammar rules determine the legal combinations between tokens. The preset grammar rules include recursive descent parsing and an LR(1) parser.

[0079] It should be noted that if a token does not conform to the grammar (such as missing parentheses), the parser will throw an error and mark the location of the error. The original token can be retained for later repair of the erroneous node.

[0080] It should be noted that, further, this embodiment can also introduce an AI semantic analysis model to automatically verify and semantically correct the AST conversion results, and identify potential logical errors or semantic conflicts (such as undefined index columns, incompatible data types, etc.).

[0081] S203 performs semantic transformation on the grammatical information in the syntax tree according to the semantic types of different nodes in the syntax tree, and obtains an abstract syntax tree.

[0082] The abstract syntax tree (AST) is a semantically simplified syntax tree representation. It retains only the core semantic nodes (such as table structure, column definitions, and constraints) compatible with the target database (e.g., GoldenDB), removes redundant syntax symbols (such as punctuation and separators), and forms a standardized structure through semantic normalization (such as data type conversion and constraint merging). The AST includes common node types used to express the core semantics of the statement: CreateTable represents a table creation statement; ColumnDef represents a column definition; Constraint represents constraints (primary key, foreign key, unique constraint, etc.); DataType represents a data type; IndexDef represents an index definition; and each node retains necessary attributes (such as table name, column name, and data type parameters).

[0083] In some embodiments, based on a preset language conversion algorithm, the grammatical information in the syntax tree is semantically converted according to the semantic type of different nodes in the syntax tree to obtain an abstract syntax tree.

[0084] S204 performs synonym transformation on the node words in the abstract syntax tree to obtain the target sentence.

[0085] The target statement is a transformed statement that can be directly recognized and executed by a second database (such as GoldenDB). It is obtained through synonym substitution and compatibility correction using an abstract syntax tree, ensuring that both the syntax and semantics conform to the target database's specifications. The target statement is a statement that the second database can recognize.

[0086] For example, Informix-specific data types (such as SERIAL) are converted to standardized semantics (INT + auto_increment). Multi-word keywords are merged (e.g., PRIMARYKEY → Constraint{type=PRIMARY_KEY}). Default values ​​are made explicit; that is, if NULL / NOTNULL is not specified in the column definition, it is explicitly marked as NULL_ALLOWED=true. During the AST generation process, symbolic information such as table names, column names, and constraint names is recorded. Column names within the same table are ensured to be unique; columns referenced by constraints must be defined. If Informix-specific, GoldenDB-incompatible, or currently unparseable syntax is encountered, an "unsupported" flag is added to the AST nodes. The original text is preserved for later processing or to prompt manual intervention. The final AST is generated, with a simplified tree structure but stronger expressiveness.

[0087] The aforementioned statement conversion method constructs an initial statement syntax tree and identifies the syntactic relationships between nodes. This transforms statements recognizable by the first database into an abstract syntax tree with universal semantic expression. Then, based on the semantic types of nodes, it achieves cross-database conversion of syntactic information. Finally, it generates a target statement compatible with the second database through synonym substitution. This method preserves the structural information and semantic logic of the statements during the conversion process, effectively improving the accuracy, automation, and universality of database statement migration, and significantly reducing compatibility issues caused by syntactic differences and the cost of manual adaptation.

[0088] Figure 3 This is a flowchart illustrating the steps for obtaining an abstract syntax tree in one embodiment. This embodiment refines the steps in the above embodiment where the syntax tree undergoes semantic transformation based on the semantic types of different nodes to obtain an abstract syntax tree, including the following steps:

[0089] S301 performs pruning on the syntax tree based on the semantic types of different nodes in the syntax tree in order to update the syntax tree.

[0090] In some embodiments, nodes with a semantic type of symbol in the syntax tree are deleted to update the syntax tree; nodes with a semantic type of a second preset type in the syntax tree are merged to update the syntax tree again; the second preset type includes at least one of table name type, column name type and constraint type.

[0091] S302 performs semantic transformation on nodes whose semantic type belongs to the first preset type based on preset semantic transformation rules to obtain an abstract syntax tree.

[0092] The first preset type is a semantic type that can only be recognized by the first database. The preset semantic transformation rules are a set of predefined rules used to map the syntax structure or data type specific to the source database (such as Informix) to the compatible equivalent of the target database (such as GoldenDB). These rules cover operations such as keyword replacement, data type standardization (such as Informix's SERIAL → GoldenDB's INT + auto_increment), and constraint transformation to ensure semantic equivalence.

[0093] In some embodiments, for nodes whose semantic type belongs to a first preset type, semantic transformation is performed on the nodes based on preset semantic transformation rules to obtain an abstract syntax tree.

[0094] In the above embodiments, the syntax tree is pruned based on the semantic type of the nodes, effectively eliminating redundant structures and simplifying the syntax tree. Furthermore, for semantic nodes that are only recognizable by the first database, precise semantic conversion is performed using preset conversion rules, thereby generating a standardized abstract syntax tree. This method significantly improves the efficiency of syntax tree conversion and the compatibility with the target database while preserving the core semantics of the original statement, laying a reliable foundation for subsequent cross-database statement generation.

[0095] Figure 4 This is a flowchart illustrating the steps for updating the target statement in one embodiment. This embodiment refines the above embodiment and includes the following steps:

[0096] S401 extracts the target node from the abstract syntax tree where the statement transformation failed.

[0097] In some embodiments, for an abstract syntax tree where statement transformation fails, the target node of the failed statement transformation is extracted from the abstract syntax tree.

[0098] Based on the trained sentence conversion model, S402 determines the target mapping relationship of the target node according to the node information of the target node.

[0099] In this context, the target mapping relationship represents that the first word and the second word of the target node are synonymous; the first word is a word that the first database can recognize; and the second word is a word that the second database can recognize.

[0100] In some embodiments, based on the trained sentence conversion model, the target mapping relationship of the target node is determined according to the node information of the target node.

[0101] S403 transforms the vocabulary of the sentences represented by the target node based on the target mapping relationship to obtain the target vocabulary of the target node.

[0102] In some embodiments, based on the target mapping relationship, the vocabulary of the statement represented by the target node is converted into target vocabulary that can be recognized by the second database to obtain the target vocabulary of the target node.

[0103] S404 updates the target sentence based on the target vocabulary.

[0104] In some embodiments, in the target statement where the statement conversion fails, the statement words corresponding to the target node are replaced with the target words to update the target statement.

[0105] In the above embodiments, by identifying target nodes that fail to be converted from the abstract syntax tree and utilizing the trained sentence conversion model, a precise mapping relationship is established between the vocabulary of the first database and the synonyms of the second database, thereby completing the semantic conversion and sentence update of the target nodes. This mechanism effectively improves the conversion efficiency in complex semantic scenarios, enhances the system's ability to handle unconventional syntax and proper nouns, significantly reduces the need for manual intervention, and ensures the integrity and accuracy of cross-database sentence conversion.

[0106] Figure 5 This is a flowchart illustrating the steps for updating the target statement in one embodiment. This embodiment refines the above embodiment and includes the following steps:

[0107] S501 performs compatibility testing on the semantic types of different words in the target statement based on preset compatibility exception types, and determines the compatibility test results of the target statement.

[0108] In some embodiments, a preset verification method can be used to perform compatibility checks on the semantic types of different words in the target statement based on preset compatibility exception types, and to determine the compatibility check result of the target statement. The preset verification method can be based on GoldenDB's built-in syntax checker or parser.

[0109] If the compatibility detection result is incompatible, S502 searches for the incompatible words in the target sentence from the preset word mapping library to find the replacement words that match the incompatible words, and updates the target sentence based on the replacement words.

[0110] For example, in this embodiment, the predefined alternatives may include:

[0111] Informix BYTE → GoldenDB BLOB;

[0112] Informix DATETIME YEAR TO FRACTION(5) → GoldenDB TIMESTAMP(5).

[0113] In the above embodiments, semantic type detection of the target statement is performed by pre-setting compatible exception types to accurately identify incompatible words and phrases. Based on a pre-set vocabulary mapping library, words are automatically matched and replaced, achieving intelligent correction of the target statement. This mechanism effectively improves the success rate of the converted statement in the target database, enhances the system's adaptability to semantic differences, significantly reduces the cost of manual investigation and correction, and ensures the accuracy and reliability of cross-database conversion results.

[0114] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.

[0115] Based on the same inventive concept, this application also provides a statement conversion apparatus for implementing the statement conversion method described above. The solution provided by this apparatus is similar to the implementation described in the above method; therefore, the specific limitations in one or more statement conversion apparatus embodiments provided below can be found in the limitations of the statement conversion method described above, and will not be repeated here.

[0116] In one exemplary embodiment, such as Figure 6 As shown, a statement conversion device is provided, including: an acquisition module 601, a construction module 602, a conversion module 603, and a target module 604, wherein:

[0117] The acquisition module 601 is used to acquire the initial statement to be semantically converted; the initial statement is a statement that the first database can recognize;

[0118] Module 602 is used to perform syntax recognition on the initial statement and construct a syntax tree for the initial statement; the nodes in the syntax tree represent the vocabulary of the initial statement; the node information of different nodes includes the syntax information of the corresponding vocabulary in the initial statement; the relationship between different nodes is the syntax relationship between the corresponding vocabulary.

[0119] The conversion module 603 is used to perform semantic conversion on the grammatical information in the syntax tree according to the semantic type of different nodes in the syntax tree, so as to obtain an abstract syntax tree;

[0120] The target module 604 is used to perform synonym conversion on the node words in the abstract syntax tree to obtain the target statement; the target statement is a statement that the second database can recognize.

[0121] In some embodiments, the construction module 602 is further configured to extract the sentence words in the initial sentence and construct a word sequence according to the order of the sentence words in the initial sentence; and perform grammar recognition on the word sequence to construct a syntax tree of the initial sentence.

[0122] In some embodiments, the conversion module 603 is further configured to prune the syntax tree according to the semantic type of different nodes in the syntax tree to update the syntax tree; for nodes whose semantic type belongs to a first preset type, semantic conversion is performed on the nodes based on preset semantic conversion rules to obtain an abstract syntax tree; the first preset type is a semantic type that can only be recognized by the first database.

[0123] In some embodiments, the conversion module 603 is further configured to delete nodes in the syntax tree whose semantic type is symbol type in order to update the syntax tree; and to merge nodes in the syntax tree whose semantic type belongs to a second preset type in order to update the syntax tree again; the second preset type includes at least one of table name type, column name type and constraint type.

[0124] In some embodiments, the statement conversion apparatus further includes: an update module, configured to extract target nodes from the abstract syntax tree where statement conversion failed; determine the target mapping relationship of the target node based on the node information of the target node according to the trained statement conversion model; the target mapping relationship represents that the first word and the second word of the target node are synonymous; the first word is a word that can be recognized by the first database; the second word is a word that can be recognized by the second database; convert the statement words represented by the target node based on the target mapping relationship to obtain the target words of the target node; and update the target statement according to the target words.

[0125] In some embodiments, the update module is further configured to perform compatibility detection on the semantic types of different statement words in the target statement based on a preset compatibility exception type, and determine the compatibility detection result of the target statement; if the compatibility detection result is incompatible, for the incompatible statement words in the target statement, find the replacement words that match the incompatible statement words from the preset word mapping library, and update the target statement according to the replacement words.

[0126] Each module in the aforementioned statement conversion device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in the processor of a computer device in hardware form or independent of it, or stored in the memory of a computer device in software form, so that the processor can call and execute the operations corresponding to each module.

[0127] In one exemplary embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 7 As shown, this computer device includes a processor, memory, input / output (I / O) interfaces, and a communication interface. The processor, memory, and I / O interfaces are connected via a system bus, and the communication interface is also connected to the system bus via the I / O interfaces. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and a database. The internal memory provides the environment for the operating system and computer programs stored in the non-volatile storage media. The database stores data. The I / O interfaces are used for exchanging information between the processor and external devices. The communication interface is used for communicating with external terminals via a network connection. When the computer program is executed by the processor, it implements a statement translation method.

[0128] Those skilled in the art will understand that Figure 7 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.

[0129] In one embodiment, a computer device is also provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in the above method embodiments.

[0130] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon that, when executed by a processor, implements the steps in the above method embodiments.

[0131] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps in the above method embodiments.

[0132] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of the relevant data must comply with relevant regulations.

[0133] Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments described above. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc., and are not limited to these.

[0134] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0135] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.< / number> < / number> < / number>

Claims

1. A statement conversion method, characterized in that, The method includes: Obtain the initial statement to be semantically transformed; the initial statement is a statement that the first database can recognize; The initial statement is subjected to grammar recognition, and a syntax tree of the initial statement is constructed; the nodes in the syntax tree represent the vocabulary of the initial statement; the node information of different nodes includes the grammatical information of the corresponding vocabulary in the initial statement; the relationship between different nodes is the grammatical relationship between the corresponding vocabulary. Based on the semantic types of different nodes in the syntax tree, the grammatical information in the syntax tree is semantically transformed to obtain an abstract syntax tree; The node words in the abstract syntax tree are subjected to synonym conversion to obtain the target statement; the target statement is a statement that the second database can recognize.

2. The method according to claim 1, characterized in that, The step of performing syntax recognition on the initial statement and constructing a syntax tree for the initial statement includes: Extract the vocabulary from the initial statement and construct a vocabulary sequence based on the order of the vocabulary in the initial statement; The lexical sequence is subjected to grammar recognition in order to construct a syntax tree for the initial statement.

3. The method according to claim 1, characterized in that, The step of semantically transforming the syntax tree based on the semantic types of different nodes in the syntax tree to obtain an abstract syntax tree includes: Based on the semantic type of different nodes in the syntax tree, the syntax tree is pruned to update the syntax tree; For nodes whose semantic type belongs to the first preset type, semantic transformation is performed on the nodes based on preset semantic transformation rules to obtain an abstract syntax tree; the first preset type is a semantic type that can only be recognized by the first database.

4. The method according to claim 3, characterized in that, The step of pruning the syntax tree according to the semantic types of different nodes in the syntax tree to update the syntax tree includes: Delete nodes in the syntax tree whose semantic type is symbol to update the syntax tree; The nodes in the syntax tree whose semantic type belongs to the second preset type are merged to update the syntax tree again; the second preset type includes at least one of table name type, column name type and constraint type.

5. The method according to any one of claims 1 to 4, characterized in that, The method further includes: Extract the target nodes from the abstract syntax tree where the statement transformation failed; Based on the trained sentence conversion model, the target mapping relationship of the target node is determined according to the node information of the target node; the target mapping relationship represents that the first word and the second word of the target node are synonymous; the first word is a word that can be recognized by the first database; the second word is a word that can be recognized by the second database. Based on the target mapping relationship, the vocabulary of the sentences represented by the target node is transformed to obtain the target vocabulary of the target node; Update the target sentence based on the target vocabulary.

6. The method according to claim 5, characterized in that, The method further includes: Based on preset compatibility exception types, the semantic types of different words in the target statement are tested for compatibility, and the compatibility test results of the target statement are determined. If the compatibility detection result is incompatible, for the incompatible words in the target statement, a replacement word matching the incompatible word is found from a preset word mapping library, and the target statement is updated according to the replacement word.

7. A statement conversion device, characterized in that, The device includes: The acquisition module is used to acquire the initial statement to be semantically converted; the initial statement is a statement that the first database can recognize. A construction module is used to perform syntax recognition on the initial statement and construct a syntax tree for the initial statement; the nodes in the syntax tree represent the vocabulary of the initial statement; the node information of different nodes includes the syntax information of the corresponding vocabulary in the initial statement; the relationship between different nodes is the syntax relationship between the corresponding vocabulary. The conversion module is used to perform semantic conversion on the grammatical information in the syntax tree according to the semantic type of different nodes in the syntax tree, so as to obtain an abstract syntax tree; The target module is used to perform synonym conversion on the node words in the abstract syntax tree to obtain the target statement; the target statement is a statement that the second database can recognize.

8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 6.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 6.

10. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 6.