US-12619404-B2 - Data processing methods and apparatuses, devices, and storage mediums
Abstract
Implementations of this specification provide data processing methods, apparatuses, and systems. In one implementation, a method includes: obtaining a statement for a data operation, wherein the statement comprises a command field, parsing the statement by a compiler, wherein the compiler is configured to support at least one syntax and provide a field translation relation among different syntaxes, in response to determining that the command field is absent from the at least one syntax supported by the complier, determining a target field in the at least one syntax that corresponds to the command field, and performing the data operation based on the target field.
Inventors
- Mengyu LI
Assignees
- Alipay (Hangzhou) Information Technology Co., Ltd.
Dates
- Publication Date
- 20260505
- Application Date
- 20231102
- Priority Date
- 20221102
Claims (20)
- 1 . A computer-implemented method for processing data in a graph database, the method comprising: obtaining a statement for a data operation, wherein the statement comprises a command field; performing syntax parsing on the statement by a compiler based on a plurality of fields comprised in the statement, wherein the compiler supports at least one syntax, provides a field translation relation among different syntaxes, performs lexical analysis on the statement to extract the plurality of fields comprised in the statement, and performs syntax parsing on the statement based on the plurality of fields by selecting a target rule from multiple preset rules for syntax parsing and generating a syntax parsing tree for the statement based on the target rule; in response to determining that the command field is absent from the at least one syntax supported by the compiler, determining a target field in the at least one syntax that corresponds to the command field; and performing the data operation based on the target field.
- 2 . The computer-implemented method according to claim 1 , wherein performing the data operation based on the target field comprises: using a machine code corresponding to the target field as a machine code corresponding to the command field; and performing the data operation based on the machine code corresponding to the target field.
- 3 . The computer-implemented method according to claim 1 , comprising: performing lexical analysis on the statement to extract the plurality of fields comprised in the statement.
- 4 . The computer-implemented method according to claim 3 , wherein performing syntax parsing on the statement based on the plurality of fields comprises: selecting a target rule from multiple rules for syntax parsing, wherein the multiple rules are preset in the compiler, and wherein the target rule matches each of the plurality of fields; and generating a syntax parsing tree for the statement based on the target rule, wherein each node of the syntax parsing tree corresponds to one of the plurality of fields.
- 5 . The computer-implemented method according to claim 4 , wherein performing the data operation based on the target field comprises: determining, based on the syntax parsing tree, an execution sequence of machine codes corresponding to the plurality of fields comprised in the statement; and performing the data operation based on the execution sequence.
- 6 . The computer-implemented method according to claim 1 , wherein the at least one syntax supported by the compiler comprises Neo4j syntax.
- 7 . The computer-implemented method according to claim 1 , wherein structured query language (SQL) syntax is unsupported by the compiler.
- 8 . A non-transitory, computer-readable medium storing one or more instructions executable by a computer system to perform operations comprising: obtaining a statement for a data operation, wherein the statement comprises a command field; performing syntax parsing on the statement by a compiler based on a plurality of fields comprised in the statement, wherein the compiler supports at least one syntax, provides a field translation relation among different syntaxes, performs lexical analysis on the statement to extract the plurality of fields comprised in the statement, and performs syntax parsing on the statement based on the plurality of fields by selecting a target rule from multiple preset rules for syntax parsing and generating a syntax parsing tree for the statement based on the target rule; in response to determining that the command field is absent from the at least one syntax supported by the compiler, determining a target field in the at least one syntax that corresponds to the command field; and performing the data operation based on the target field.
- 9 . The non-transitory, computer-readable medium of claim 8 , wherein performing the data operation based on the target field comprises: using a machine code corresponding to the target field as a machine code corresponding to the command field; and performing the data operation based on the machine code corresponding to the target field.
- 10 . The non-transitory, computer-readable medium of claim 8 , wherein the operations comprise: performing lexical analysis on the statement to extract the plurality of fields comprised in the statement.
- 11 . The non-transitory, computer-readable medium of claim 10 , wherein performing syntax parsing on the statement based on the plurality of fields comprises: selecting a target rule from multiple rules for syntax parsing, wherein the target rule matches each of the plurality of fields, and wherein the syntax parsing is preset in the compiler; and generating a syntax parsing tree for the statement based on the target rule, wherein each node of the syntax parsing tree corresponds to one of the plurality of fields.
- 12 . The non-transitory, computer-readable medium of claim 11 , wherein performing the data operation based on the target field comprises: determining, based on the syntax parsing tree, an execution sequence of machine codes corresponding to the plurality of fields comprised in the statement; and performing the data operation based on the execution sequence.
- 13 . The non-transitory, computer-readable medium of claim 8 , wherein the at least one syntax supported by the compiler comprises Neo4j syntax.
- 14 . The non-transitory, computer-readable medium of claim 8 , wherein structured query language (SQL) syntax is unsupported by the compiler.
- 15 . A computer-implemented system, comprising: one or more computers; and one or more computer memory devices interoperably coupled with the one or more computers and having tangible, non-transitory, machine-readable media storing one or more instructions that, when executed by the one or more computers, perform one or more operations comprising: obtaining a statement for a data operation, wherein the statement comprises a command field; performing syntax parsing on the statement by a compiler based on a plurality of fields comprised in the statement, wherein the compiler supports at least one syntax, provides a field translation relation among different syntaxes, performs lexical analysis on the statement to extract the plurality of fields comprised in the statement, and performs syntax parsing on the statement based on the plurality of fields by selecting a target rule from multiple preset rules for syntax parsing and generating a syntax parsing tree for the statement based on the target rule; in response to determining that the command field is absent from the at least one syntax supported by the compiler, determining a target field in the at least one syntax that corresponds to the command field; and performing the data operation based on the target field.
- 16 . The computer-implemented system of claim 15 , wherein performing the data operation based on the target field comprises: using a machine code corresponding to the target field as a machine code corresponding to the command field; and performing the data operation based on the machine code corresponding to the target field.
- 17 . The computer-implemented system of claim 15 , wherein the operations comprise: performing lexical analysis on the statement to extract the plurality of fields comprised in the statement.
- 18 . The computer-implemented system of claim 17 , wherein performing syntax parsing on the statement based on the plurality of fields comprises: selecting a target rule from multiple rules for syntax parsing, wherein the target rule matches each of the plurality of fields, and wherein the syntax parsing is preset in the compiler; and generating a syntax parsing tree for the statement based on the target rule, wherein each node of the syntax parsing tree corresponds to one of the plurality of fields.
- 19 . The computer-implemented system of claim 18 , wherein performing the data operation based on the target field comprises: determining, based on the syntax parsing tree, an execution sequence of machine codes corresponding to the plurality of fields comprised in the statement; and performing the data operation based on the execution sequence.
- 20 . The computer-implemented system of claim 15 , wherein the at least one syntax supported by the compiler comprises Neo4j syntax, and wherein structured query language (SQL) syntax is unsupported by the compiler.
Description
CROSS-REFERENCE TO RELATED APPLICATIONS This application claims priority to Chinese Patent Application No. 202211364454.8, filed on Nov. 2, 2022, which is hereby incorporated by reference in its entirety. TECHNICAL FIELD This specification relates to the field of data processing technologies, and in particular, to data processing methods and apparatuses, devices, and storage mediums. BACKGROUND Currently, as a common database, a graph database represents and stores data in the form of nodes, edges, etc. (for example, data are stored by using users as nodes and relations between the users as edges), so that multi-layer association query is efficiently performed. A structured query language (SQL) is a special programming language, and is usually used to access, query, and update data in a relational database. A syntax structure of the SQL language is very simple, and data in the database can be processed very conveniently by using the SQL language. However, use of the SQL language is not supported in the graph database. SUMMARY This specification provides data processing methods and apparatuses, devices, and storage mediums, to partially alleviate the problems in the existing technology. The following technical solutions are used in this specification. This specification provides a data processing method, including the following: a data operation statement is obtained; the data operation statement is parsed by using a predetermined compiler; in response to determining, by using the compiler, that the data operation statement includes a command field that does not belong to syntax supported by the compiler, a field corresponding to the command field in the syntax supported by the compiler is determined by using a field translation relation pre-deployed in the compiler, and the field is used as a target field; and an operation corresponding to the data operation statement is performed by using the compiler based on the target field, to process data to be processed corresponding to the data operation statement. Optionally, that an operation corresponding to the data operation statement is performed by using the compiler based on the target field specifically includes the following: machine code corresponding to the target field is used as machine code corresponding to the command field, and the operation corresponding to the data operation statement is performed based on the machine code corresponding to the target field. Optionally, that the data operation statement is parsed by using a predetermined compiler specifically includes the following: lexical analysis is performed on the data operation statement by using the compiler, to extract fields included in the data operation statement; and syntax parsing is performed on the data operation statement based on the fields. Optionally, that syntax parsing is performed on the data operation statement based on the fields specifically includes the following: a syntax parsing rule that matches each field is determined from syntax parsing rules predetermined in the compiler, and the syntax parsing rule is used as a target rule; and a syntax parsing tree for the data operation statement is generated based on the target rule, where each node corresponds to a field in the syntax parsing tree. Optionally, that an operation corresponding to the data operation statement is performed by using the compiler based on the target field specifically includes the following: an execution sequence of machine code corresponding to the fields included in the data operation statement is determined based on the syntax parsing tree; and machine code corresponding to the target field is used as machine code corresponding to the command field, and the operation corresponding to the data operation statement is performed based on the execution sequence. Optionally, the syntax supported by the compiler includes Neo4j syntax, and the syntax not supported by the compiler includes structured query language (SQL) syntax. This specification provides a data processing apparatus, including: an acquisition module, configured to obtain a data operation statement; a parsing module, configured to parse the data operation statement by using a predetermined compiler; a conversion module, configured to: in response to determining, by using the compiler, that the data operation statement includes a command field that does not belong to syntax supported by the compiler, determine, by using a field translation relation pre-deployed in the compiler, a field corresponding to the command field in the syntax supported by the compiler, and use the field as a target field; and an execution module, configured to perform an operation corresponding to the data operation statement by using the compiler based on the target field, to process data to be processed corresponding to the data operation statement. Optionally, the execution module is specifically configured to use machine code corresponding to the target field as