CN114386402A - Statement auditing method and device, computer equipment and storage medium - Google Patents

Statement auditing method and device, computer equipment and storage medium Download PDF

Info

Publication number
CN114386402A
CN114386402A CN202210039752.3A CN202210039752A CN114386402A CN 114386402 A CN114386402 A CN 114386402A CN 202210039752 A CN202210039752 A CN 202210039752A CN 114386402 A CN114386402 A CN 114386402A
Authority
CN
China
Prior art keywords
audited
audit
query statement
statement
auditing
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202210039752.3A
Other languages
Chinese (zh)
Inventor
王英杰
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Weikun Shanghai Technology Service Co Ltd
Original Assignee
Weikun Shanghai Technology Service Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Weikun Shanghai Technology Service Co Ltd filed Critical Weikun Shanghai Technology Service Co Ltd
Priority to CN202210039752.3A priority Critical patent/CN114386402A/en
Publication of CN114386402A publication Critical patent/CN114386402A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/20Natural language analysis
    • G06F40/253Grammatical analysis; Style critique
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/242Query formulation
    • G06F16/2433Query languages
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/20Natural language analysis
    • G06F40/205Parsing
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/20Natural language analysis
    • G06F40/279Recognition of textual entities
    • G06F40/289Phrasal analysis, e.g. finite state techniques or chunking

Abstract

The application relates to the field of artificial intelligence, and discloses a statement auditing method, a statement auditing device, computer equipment and a storage medium, wherein the statement auditing device comprises: acquiring a structural query statement to be audited in a target file, and analyzing the structural query statement to be audited to obtain a syntax analysis tree corresponding to the structural query statement to be audited; determining a target execution plan corresponding to the structured query statement to be audited according to the syntax parse tree; setting operation according to the audit rule detected in the user audit interface to determine the audit rule, determining the data to be audited corresponding to the audit rule from the target execution plan, and auditing the data to be audited based on the audit rule; and if the structural query statement to be audited is determined to pass statement audit according to the audit result, outputting a statement audit passing result on a user audit interface. Automatic statement auditing can be realized, and the working efficiency is improved. The present application relates to blockchain techniques, such as the above data may be written into a blockchain for auditing and other scenarios.

Description

Statement auditing method and device, computer equipment and storage medium
Technical Field
The present application relates to the field of computer technologies, and in particular, to a statement auditing method and apparatus, a computer device, and a storage medium.
Background
In the related work of the database, for example, when a Query, an addition, or the like is performed on the database by using a Structured Query Language (SQL) statement, the SQL statement with poor performance may cause the overall performance of the database to be reduced. Therefore, it is usually necessary to audit the SQL statements executed in the database, so as to avoid that the SQL statements with poor performance enter the database, which results in the overall performance of the database being reduced. At present, most auditing systems adopt a manual auditing method, namely, each SQL statement needs to be audited manually, so that the operation is quite troublesome, time and labor are wasted, errors are easy to occur during auditing, and the working efficiency cannot be improved. Therefore, how to quickly and accurately audit the SQL statement becomes a hot research problem at present.
Disclosure of Invention
The embodiment of the application provides a statement auditing method and device, computer equipment and a storage medium, which can automatically audit statements and audit according to auditing rules set by a user, solve the problem of complicated manual operation which is easy to make mistakes, and improve the working efficiency.
In a first aspect, an embodiment of the present application discloses a statement auditing method, where the method includes:
acquiring a structural query statement to be audited in a target file, and analyzing the structural query statement to be audited to obtain a syntax analysis tree corresponding to the structural query statement to be audited;
determining a target execution plan corresponding to the structured query statement to be audited according to the syntax parse tree, wherein the target execution plan comprises: executing the operation data to be checked during the structured query statement in the database;
setting operation according to an audit rule detected in a user audit interface to determine an audit rule, determining to-be-audited data corresponding to the audit rule from the target execution plan, and auditing the to-be-audited data based on the audit rule;
and if the structural query statement to be audited is determined to pass statement audit according to the audit result, outputting a statement audit passing result on the user audit interface.
In a second aspect, an embodiment of the present application discloses a statement auditing apparatus, where the apparatus includes:
the parsing unit is used for acquiring a structural query statement to be audited in a target file, and parsing the structural query statement to be audited to obtain a syntax parsing tree corresponding to the structural query statement to be audited;
a determining unit, configured to determine, according to the syntax parse tree, a target execution plan corresponding to the to-be-audited structured query statement, where the target execution plan includes: executing the operation data to be checked during the structured query statement in the database;
the auditing unit is used for setting operation according to the auditing rule detected in a user auditing interface to determine an auditing rule, determining the data to be audited corresponding to the auditing rule from the target execution plan, and auditing the data to be audited based on the auditing rule;
and the output unit is used for outputting a statement audit passing result on the user audit interface if the structural query statement to be audited passes the statement audit according to the audit result.
In a third aspect, an embodiment of the present application discloses a computer device, including a processor and a memory, where the memory is used for storing a computer program, the computer program includes program instructions, and the processor is configured to call the program instructions to execute the method of the first aspect.
In a fourth aspect, embodiments of the present application disclose a computer-readable storage medium storing a computer program, the computer program comprising program instructions that, when executed by a processor, cause the processor to perform the method of the first aspect.
In the embodiment of the application, the structural query statement to be audited in the target file can be obtained, and the structural query statement to be audited is analyzed, so that the syntax analysis tree corresponding to the structural query statement to be audited is obtained. Then, a target execution plan corresponding to the structured query statement to be audited can be determined according to the syntax parse tree, so that the audit rule can be determined according to the audit rule setting operation detected in the user audit interface, and the to-be-audited nuclear data corresponding to the audit rule can be determined from the target execution plan. Furthermore, the data to be audited can be audited based on the audit rule, and if the structured query statement to be audited is determined to pass statement audit according to the audit result, the statement audit passing result is output on the user audit interface. The automatic statement auditing method and the system can realize automatic statement auditing and audit according to the auditing rule set by the user, solve the problem of complicated manual operation which is easy to make mistakes, and improve the working efficiency.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings needed to be used in the description of the embodiments are briefly introduced below, and it is obvious that the drawings in the following description are some embodiments of the present application, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without creative efforts.
FIG. 1a is a schematic flow chart of a statement review scheme provided in an embodiment of the present application;
fig. 1b is a schematic architecture diagram of a statement auditing system according to an embodiment of the present application;
fig. 2 is a schematic flowchart of a statement auditing method according to an embodiment of the present application;
FIG. 3 is a schematic interface diagram of a user review interface provided in an embodiment of the present application;
FIG. 4 is a schematic flow chart of another statement auditing method provided in the embodiments of the present application;
fig. 5 is a schematic structural diagram of a statement auditing apparatus according to an embodiment of the present application;
fig. 6 is a schematic structural diagram of a computer device according to an embodiment of the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are some, but not all, embodiments of the present application. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
The embodiment of the application can acquire and process related data based on an artificial intelligence technology. Among them, Artificial Intelligence (AI) is a theory, method, technique and application system that simulates, extends and expands human Intelligence using a digital computer or a machine controlled by a digital computer, senses the environment, acquires knowledge and uses the knowledge to obtain the best result.
The artificial intelligence infrastructure generally includes technologies such as sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, big data processing technologies, operation/interaction systems, mechatronics, and the like. The artificial intelligence software technology mainly comprises a computer vision technology, a robot technology, a biological recognition technology, a voice processing technology, a natural language processing technology, machine learning/deep learning and the like.
The scheme provided by the embodiment of the application relates to the technologies such as machine learning of artificial intelligence and the like, and is specifically explained by the following embodiment:
the embodiment of the present application provides a statement auditing scheme, and specifically, as shown in fig. 1a, the scheme is roughly as follows: firstly, a structured query statement to be checked, that is, a structured query statement to be checked, can be obtained, for example, a structured query statement to be checked in a target file can be obtained; after the to-be-audited structured query statement is obtained, statement preprocessing may be performed on the to-be-audited structured query statement, for example, the statement preprocessing may be to analyze the to-be-audited structured query statement, so as to obtain a syntax analysis tree corresponding to the to-be-audited structured query statement. A target execution plan corresponding to the structured query statement to be reviewed can then be determined from the syntax parse tree, analyzing the target execution plan, determining the data to be checked corresponding to the checking rule from the target execution plan, wherein the audit rules may be determined based on audit rule set operations detected in the user audit interface, and further, the data to be audited may be audited based on the audit rules to determine whether the structured query statement to be audited passes statement audit, if the structured query statement to be audited passes statement audit, online operation can be performed, i.e. publishing, if the structural query statement to be audited fails the statement audit, the structural query statement to be audited can be further classified, and optimizing the structural query statement to be audited according to the classification result, so that the optimized structural query statement to be audited can be subjected to online operation. By implementing the method, automatic statement auditing can be realized, auditing can be performed according to auditing rules set by a user, complicated manual operation which is easy to make mistakes is solved, and the working efficiency is improved.
In a specific implementation, the execution subject of the above-mentioned statement auditing scheme may be a computer device, and the computer device may be a terminal or a server. The terminal mentioned here may be a smart phone, a tablet computer, a notebook computer, a desktop computer, or other devices, and may also be an external device such as a handle, a touch screen, or other devices; the server may be an independent physical server, a server cluster or a distributed system formed by a plurality of physical servers, a cloud server providing basic cloud computing services such as cloud service, a cloud database, cloud computing, a cloud function, cloud storage, Network service, cloud communication, middleware service, domain name service, security service, Content Delivery Network (CDN), big data and an artificial intelligence platform, and the like. It should be noted that, when the computer device is a server, the embodiment of the present application provides an object identification system, as shown in fig. 1b, the statement auditing system includes at least one terminal and at least one server; the terminal can acquire the structural query statement to be audited in the target file, and upload the acquired structural query statement to be audited to the server (namely, the computer device), so that the computer device can acquire the structural query statement to be audited and analyze the structural query statement to be audited, and subsequent statement auditing is performed.
Alternatively, the above-mentioned object recognition scheme may be performed by both the terminal and the server. For example, after the terminal acquires the structural query statement to be audited in the target file, the terminal may also determine a syntax parse tree corresponding to the structural query statement to be audited, and obtain a target execution plan corresponding to the structural query statement to be audited based on the syntax parse tree. The target execution plan is then uploaded to the server. Enabling the server to perform statement review on the structural query statement to be reviewed directly based on the target execution plan and the review rule detected in the user review interface, and the like. It should be noted that, when the object identification scheme is executed by a terminal and a server together, the terminal and the server may be directly or indirectly connected through wired or wireless communication, and the embodiment of the present application is not limited herein.
Based on the statement auditing scheme provided by the embodiment of the application, the statement auditing method can be executed by the computer equipment (namely a terminal or a server); alternatively, the statement auditing method may be executed by both the terminal and the server. For convenience of explanation, the statement auditing method is executed by computer equipment in the embodiment of the application. Referring to fig. 2, the statement auditing method may include the following steps S201 to S204:
s201: and acquiring the structural query statement to be audited in the target file, and analyzing the structural query statement to be audited to obtain a syntax analysis tree corresponding to the structural query statement to be audited.
In one implementation, the target file may be obtained based on an audit request initiated by an auditor on a user audit interface. For example, a user audit request interface may be displayed on a screen of a terminal used by an auditor, and the user audit request interface may be used by the auditor to initiate an audit request, so that the computer device may perform statement audit according to the obtained audit request. The audit request may carry the target file or, the audit request carries a file path of the target file, the corresponding target file may also be found based on the file path. Then, after the target file is obtained, the structured query statement to be audited may be obtained from the target file, and subsequent statement auditing may be performed.
In an implementation manner, after the target file is obtained in the above manner, the file type of the target file may also be determined, so that the statement extraction manner corresponding to the target file may be determined according to the file type of the target file. The file type may refer to a format of a file, for example, the target file may be an xml format file, an sql format file, and other special format files. When extracting the structured query statement, the target files of different file types may have different extraction manners, and then the structured query statement may be extracted from the target file according to the statement extraction manner corresponding to the target file, and the extracted structured query statement is the structured query statement to be reviewed. The structured query statement extracted from the target file may include one or more structured query statements, and the corresponding to-be-reviewed structured query statement may also include one or more structured query statements.
In an implementation manner, after the structural query statement to be audited is obtained, the structural query statement to be audited may be parsed to obtain a syntax parse tree corresponding to the structural query statement to be audited. Optionally, preferably, lexical analysis may be performed on the structural query statement to be audited to obtain morpheme stream information corresponding to the structural query statement to be audited, and then syntax analysis may be performed on the morpheme stream information corresponding to the structural query statement to be audited to obtain a syntax analysis tree corresponding to the structural query statement to be audited. Optionally, a lexical analyzer may be used to perform lexical analysis on the structural query statement to be checked, for example, the lexical analyzer may be a Lexer lexical analyzer, and specifically, the structural query statement to be checked may be converted into morpheme stream information by a tokenizer (tokenizer).
Optionally, a specific implementation process of converting the structured query statement to be audited into morpheme flow information may be: the structural query statement to be audited is scanned from left to right, various words (Token) are identified according to the lexical rules of the structural query statement to be audited, and attribute values of the corresponding words are generated, and the words can be understood as symbols. In a specific implementation, a preset symbol list can be obtained, characters included in a structured query statement to be audited are scanned one by one from left to right, and each character in a character stream is matched with a symbol type in the symbol list according to a regular matching method so as to match a symbol type corresponding to a current character. The symbol types in the symbol list may include identifiers, operators, and the like, and may be set according to actual requirements. For example, it can be determined by lexical analysis which characters in the character stream belong to the identifier, which characters belong to the operator, which characters belong to the cutoff position of the sentence, and which characters belong to the number; such as "sum ═ 3+ 2; "the type of word (symbol) corresponding to each character after lexical analysis (vocalization) includes: identifier (sum), assignment operator (═), number (3, 2), addition operator (+), statement end (;). Optionally, when the lexical analysis is performed on the to-be-audited structured query statement, the current character may be added to the content stack, and the symbol type corresponding to the current character is synchronously added to the analysis stack. An analysis stack and a content stack may be created in advance, where the analysis stack is used to store a single symbol (symbol type) in a character stream corresponding to a structured query statement to be examined, and the content stack is used to store a value (character) corresponding to a symbol in a character stream corresponding to a structured query statement to be examined.
Optionally, when the syntax analysis is performed on the to-be-audited structured query statement, the syntax analysis may be performed according to a syntax rule of the programming language corresponding to the to-be-audited structured query statement, where the syntax rule describes a composition structure of each syntax component of the programming language, and the syntax rule of one programming language may be described exactly by using a context-free grammar or a backhaul-Naur paradigm (BNF). Wherein the context-free grammar may include: LL (1), LR (0), LR (k), LALR (1), and so forth. Each grammar has different requirements, such as LL (1) requires that the grammar be unambiguous and that there be no left recursion. In the application, the LR (1) grammar with a better grammar analysis effect can be used to describe the grammar rules of the structured query statement to be audited, so as to construct a grammar parse tree corresponding to the structured query statement to be audited. LR (1) is a bottom-up syntax parsing, i.e., in building a syntax parse tree based on morpheme stream information, the root node (top) can be reached gradually from the leaf node (bottom) up. In LR (1), "L" indicates "scan from left to right," R "indicates construction of a rightmost derivation in reverse, and" 1 "indicates looking forward at 1 input symbol when making a syntax parsing decision.
S202: and determining a target execution plan corresponding to the structured query statement to be audited according to the syntax parse tree.
The target execution plan may be understood as a performance of the structured query statement to be reviewed when executed in the database, and the target execution plan may include: the operation data may specifically refer to data generated after a structured query statement is executed, for example, how many rows are involved, which indexes are used, a running time, a cycle number, and the like. For example, when the corresponding query result is obtained for the to-be-audited structured query statement of the query class, the whole query is completed according to the corresponding target execution plan, so as to obtain the query result.
In one embodiment, one or more execution plans corresponding to the structured query statement to be reviewed may be determined according to the syntax parse tree, and a target execution plan, which is an optimal one of the one or more execution plans, may be selected from the one or more execution plans. In general, there may be multiple execution plans for a structured query statement to be reviewed. For example, there may be a wide variety of execution plans for a structured query statement to be reviewed for a query class, and multiple execution plans may eventually return the same query result. Then, an optimal execution plan may be selected from the multiple execution plans, so as to perform an audit on the performance of the structured query statement to be audited by using the execution plan, so as to ensure that the performance of the structured query statement to be audited is as optimal as possible.
In one implementation, the target execution plan may also be obtained according to a database in which the to-be-audited structured query statement is executed in a connected manner. In a specific implementation, before executing the statement audit task, relevant settings may be performed on a database to which the structured query statement is to be connected, so as to configure database information required for the structured query statement to enter the database. For example, the database information includes a domain name (URL) address of the database, a username and password into the database, and so on; and configuring a code version control mode supported by the code corresponding to the structured query statement, setting a database used by the code corresponding to the structured query statement, and the like. So that the configured information can be subsequently used to connect the structured query statement to be audited with the database in which the structured query statement to be audited is executed. When the target execution plan is obtained, the database where the to-be-audited structured query statement is located may be executed according to the database information connection, the to-be-audited structured query statement is executed in the database to obtain one or more execution plans corresponding to the to-be-audited structured query statement, and the target execution plan is determined from the one or more execution plans according to a preset selection rule. The preset selection rule may be to select an optimal execution plan from one or more execution plans.
S203: and setting operation according to the audit rule detected in the user audit interface to determine the audit rule, determining the to-be-audited data corresponding to the audit rule from the target execution plan, and auditing the to-be-audited data based on the audit rule.
In an implementation manner, when an auditor needs to perform statement audit on a structural query statement to be audited, a relevant audit rule may be set on a user audit interface output by a terminal, so that a computer device may perform statement audit on the structural query statement to be audited based on the audit rule set by the auditor. Through self-defined audit rule setting of audit personnel on a user audit interface, personalized statement audit can be achieved, corresponding audit rules are set for different business requirements through flexible audit rule setting, and an audit mode with good universality and applicability is provided. See, for example, fig. 3: the terminal used by the auditor may display a user audit interface in the terminal screen, which may include at least an audit rule setting area, labeled 301, and a confirmation control, labeled 302. If an auditor wants to perform statement audit on a structural query statement to be audited, the auditor may input a required audit rule in the audit rule setting area 301, where the number of the auditor rules that can be input may include one or more. Optionally, in the audit rule setting area 301, multiple audit rules may be configured in advance, and the audit rule to be set may be selected autonomously from the audit rule setting area 301, or the audit rule may be customized in the audit rule setting area 301. After the auditor sets the corresponding audit rule in the audit rule setting area 301, a trigger operation (such as a click operation, a press operation, and the like) may be performed on the confirmation control 302, so as to trigger a terminal used by the auditor to obtain the audit rule set in the audit rule setting area 301, and send the obtained audit rule to the computer device.
The audit rule may specifically include an audit object and an audit passing standard. For example, the audit object may be a cycle number, a running time length, and the like, for example, when the audit object is the cycle number, the corresponding audit passing criterion may be that the cycle number does not exceed a specified value, the specified value may be a value of 5, 7, and the like, and the specific value is not limited in this application. If the audit object is the run-time duration, the corresponding audit passing criterion may be that the run-time duration does not exceed a specified duration, and the specified value may be a value of 3 milliseconds, 6 milliseconds, or the like, and the specific value is not limited in the present application.
After the computer device receives the audit rule, statement audit can be performed on the to-be-audited structured query statement based on the audit rule, for example, to-be-audited data corresponding to the audit rule can be determined from the target execution plan, and the to-be-audited data is audited based on the audit rule. And auditing the data to be audited, namely performing statement audit on the structured query statement to be audited. In the auditing process, data matched with the auditing object in the auditing rule can be acquired from the target execution plan, and the acquired data is the data to be audited. For example, assuming that the auditing object in the auditing rule may be for the cycle number and the running time length as shown in fig. 3, specific data for the cycle number and specific data for the running time length may be obtained from the target execution plan. Then, after the to-be-audited data is obtained, auditing can be performed on the to-be-audited data based on the auditing passing standard in the auditing rule, and an auditing result corresponding to the to-be-audited data is determined. For example, assume that the corresponding audit pass criteria for the number of cycles are: the cycle number is not more than 5; if the data to be checked is: if the cycle number is 8, it may be determined that the audit result for the cycle number is not approved; if the data to be checked is: if the number of cycles is 4, it may be determined that the result of the audit with respect to the number of cycles is a pass audit. For another example, assume that the corresponding audit pass criteria for the run length are: the running time is not more than 10 milliseconds; if the data to be checked is: if the running time is 12 milliseconds, the auditing result of the running time can be determined to be not approved; if the data to be checked is: if the running time is 4 milliseconds, the result of the audit on the running time can be determined to be a pass audit.
S204: and if the structural query statement to be audited is determined to pass statement audit according to the audit result, outputting a statement audit passing result on a user audit interface.
In one implementation, the result of the review of the statement to be reviewed may include: and the data to be audited passes the audit or the data to be audited does not pass the audit. The number of the to-be-audited data can be one or more, statement audit passing standards corresponding to different numbers of to-be-audited statements can be different, and whether the to-be-audited structured query statement passes the statement audit is stated based on the different numbers of to-be-audited data.
And (I) under the condition that the number of the data to be audited is one, determining that the structured query statement to be audited passes statement audit according to the audit result of the data to be audited. For example, if the result of the audit is that the data to be audited passes the audit, it may be determined that the structured query statement to be audited passes the statement audit. And if the audit result is that the data to be audited is not approved, determining that the structured query statement to be audited does not pass statement audit.
(II) under the condition that the number of the data to be audited is multiple, the audit result of any data to be audited may include: and any piece of the data to be audited passes the audit, or any piece of the data to be audited does not pass the audit. Each piece of data to be audited corresponds to one audit result. In this case, whether the structural query statement to be reviewed passes the statement review may be determined based on the number of the review results, for example, it may be determined that the structural query statement to be reviewed passes the statement review if all the review results are that the data to be reviewed passes the review, or it may be determined that the structural query statement to be reviewed passes the statement review if part of the review results are that the data to be reviewed passes the review. When the number of the data to be audited is multiple, the mode of determining that the structured query statement to be audited passes statement auditing can be any one of the following modes.
The specific implementation is as follows: and counting the number of the target auditing results, wherein the target auditing results can be used for indicating the auditing results of the to-be-audited data passing the auditing. And if the number of the target audit results is equal to that of the data to be audited, namely the audit result of each piece of the data to be audited is that the data to be audited passes the audit, determining that the structured query statement to be audited passes the statement audit. On the contrary, if the number of the target audit results is not equal to the number of the data to be audited, that is, the audit result of any one or more pieces of data to be audited does not pass the audit of the data to be audited, it is determined that the structured query statement to be audited does not pass the statement audit.
The second concrete implementation: and counting the number of the target auditing results, and detecting whether the number of the target auditing results exceeds a preset number threshold value. And if the number exceeds a preset number threshold value as a detection result, determining that the structured query statement to be audited passes statement audit. If the number of the detection results does not exceed the preset number threshold, it can be determined that the structured query statement to be reviewed fails the statement review. The preset number threshold may be preset, for example, the preset number threshold is determined based on the number of data to be audited, and the preset number threshold may be 2/3 or 4/5, for example, the number of data to be audited. For example, assuming that the preset number threshold is 2/3 of the number of data to be audited and the number of data to be audited is 6, the preset number threshold is 4. That is, if the number of the target audit results exceeds 4, it may be determined that the structured query statement to be audited passes statement audit, and if the number of the target audit results does not exceed 4, it may be determined that the structured query statement to be audited does not pass statement audit.
The concrete implementation is three: whether the data to be checked corresponding to the target auditing result are all the specified data to be checked can be determined. If the data to be audited corresponding to the target audit result is the specified data to be audited, the structured query statement to be audited can pass through statement audit; if the auditing result of the specified to-be-audited data is not the target auditing result, the to-be-audited structured query statement fails statement auditing. The specified to-be-audited data may be preset by the user, for example, there are 5 to-be-audited data for the to-be-audited structured query statement, where 3 to-be-audited data are set as the specified to-be-audited data, when it is determined whether the to-be-audited structured query statement passes the statement audit, it may be determined whether the audit result corresponding to the 3 specified to-be-audited data is the target audit result, and if the audit result corresponding to the 3 specified to-be-audited data is the target audit result, it may be determined that the to-be-audited structured query statement passes the statement audit.
Then, after it is determined that the structured query statement to be reviewed passes the statement review in any of the above manners, the statement review pass result may be output on the user review interface. The corresponding statement audit pass result may be output, for example, in the result display area 303 of the user audit interface as shown in fig. 3, so that the user may perform subsequent operations based on the statement audit pass result. For example, the method is applied to the publishing of the structured query statement to be audited.
In the embodiment of the application, the structural query statement to be audited in the target file can be obtained, and the structural query statement to be audited is analyzed, so that the syntax analysis tree corresponding to the structural query statement to be audited is obtained. Then, a target execution plan corresponding to the structured query statement to be audited can be determined according to the syntax parse tree, so that the audit rule can be determined according to the audit rule setting operation detected in the user audit interface, and the to-be-audited nuclear data corresponding to the audit rule can be determined from the target execution plan. Furthermore, the data to be audited can be audited based on the audit rule, and if the structured query statement to be audited is determined to pass statement audit according to the audit result, the statement audit passing result is output on the user audit interface. The automatic statement auditing method and the system can realize automatic statement auditing and audit according to the auditing rule set by the user, solve the problem of complicated manual operation which is easy to make mistakes, and improve the working efficiency.
The embodiment of the application provides another statement auditing method, which can be executed by the computer equipment mentioned above. Referring to fig. 4, the statement auditing method may include the following steps S401 to S405:
s401: and acquiring the structural query statement to be audited in the target file, and analyzing the structural query statement to be audited to obtain a syntax analysis tree corresponding to the structural query statement to be audited.
S402: and determining a target execution plan corresponding to the structured query statement to be audited according to the syntax parse tree.
S403: and setting operation according to the audit rule detected in the user audit interface to determine the audit rule, determining the to-be-audited data corresponding to the audit rule from the target execution plan, and auditing the to-be-audited data based on the audit rule.
S404: and if the structural query statement to be audited is determined to pass statement audit according to the audit result, outputting a statement audit passing result on a user audit interface.
S405: and if the fact that the structural query statement to be audited does not pass statement audit is determined, calling a decision tree model to perform decision processing on the structural query statement to be audited to obtain an optimization strategy corresponding to the structural query statement to be audited, and outputting the optimization strategy on a user audit interface.
In an implementation manner, if it is determined that the structural query statement to be audited does not pass the statement audit, the structural query statement to be audited may be optimized, so that the optimized structural query statement to be audited may pass the statement audit, and subsequent operations such as publishing may be performed. Before optimizing the structural query statement to be audited, an optimization strategy of the structural query statement to be audited may be determined, where the optimization strategy may be used to indicate a strategy for adjusting a target execution plan of the structural query statement to be audited, so that the adjusted structural query statement to be audited passes through statement audit. Optionally, the decision tree model may be called to perform decision processing on the structural query statement to be audited, so as to obtain an optimization strategy corresponding to the structural query statement to be audited.
Then, before calling the decision tree model to perform decision processing on the structural query statement to be reviewed, the decision tree model may be constructed. In one implementation, a training execution plan for one or more training sentences may be obtained, where the training execution plan for any training sentence may include: operational data when any of the training sentences is executed in the database. Then, a corresponding training strategy type label may be added for each of the training execution plans of the one or more training sentences, so that the decision tree model may be constructed based on a training sample set, which may refer to each of the training execution plans including the added training strategy type label. The following describes a specific implementation process for constructing a decision tree model based on a training sample set.
It will be appreciated that the decision tree model may generally include a plurality of nodes, which may include a root node, a number of non-leaf nodes, and a number of leaf nodes. The root node and the non-leaf nodes in the decision tree may represent a feature or attribute (which may be referred to as node feature hereinafter) corresponding to an attribute test, and the leaf nodes represent a class corresponding to a classification result. The sample set contained by each parent node can be divided into child nodes according to the result of the attribute test. In general, the root node may contain the entire sample set, with a path from the root node to each leaf node corresponding to a decision test sequence. Then, a decision tree for performing optimization analysis on the structural query statement to be audited which does not pass the statement audit can be constructed, each node in the decision tree is used for testing the target execution plan of the structural query statement to be audited which does not pass the statement audit, so as to obtain a final classification result according to the judgment results of the root node and each non-leaf node, and the classification result is the subsequent strategy type which needs to optimize the structural query statement to be audited.
In one implementation, decision tree model construction generally refers to: a tree (decision tree) is constructed based on a given training sample set, and the most valuable features are selected from the root node to start segmenting the nodes. The whole construction process of the decision tree model can be a process of recursively selecting the optimal features and segmenting the training sample set according to the optimal features so that each training sample subset has the best classification. In the process, the division of the feature space corresponds to the construction of the decision tree.
In one implementation, a feature data set may be determined based on the operation data included in each training execution plan, where the feature data set includes one or more feature data. For example, the feature data may be a number of cycles, a duration of operation, a number of scan lines, etc. to construct nodes in the decision tree model from the feature data. During the construction process of the decision tree model, the corresponding node characteristics of the root node and each non-leaf node may be determined from the characteristic data set based on an information gain criterion, or the node characteristics may also be determined based on other criterion classes, such as an information gain rate criterion. The embodiments of the present application are mainly illustrated by the information gain criterion.
Optionally, the specific implementation process of constructing the decision tree by using the recursive principle may be: and dividing a training sample set based on the optimal feature data, calculating the feature data with the best classification capability on the basis of the training sample set, and taking the feature data with the best classification capability as the node features corresponding to the first-level nodes (namely root nodes) of the decision tree. The optimal feature data is the feature data with the best classification capability, and the quality of the classification capability of the feature data can be judged based on the information gain corresponding to the feature data, and the larger the information gain is, the better the classification capability of the feature data is. Specifically, then, the information gain of each feature data in the feature data set may be calculated, and the feature data with the largest information gain may be selected as the node feature of the root node of the decision tree model.
Then, the training sample set is divided for the first time based on the characteristic data, after the first division, second-level nodes of the decision tree are constructed based on the divided training sample set, and the characteristic data with the best classification capability is determined on the basis of the training sample set obtained after the division, so that the node characteristics corresponding to each second-level node are determined. In other words, child nodes for the root node can be established by different values of the node characteristics of the root node, and the above method is recursively invoked for the child nodes to construct a decision tree model until the information gain of all characteristic data is very small or no characteristic data can be selected, thereby finally obtaining a decision tree.
In an implementation manner, when a decision tree model is constructed based on a training sample set, an overfitting problem may occur when a decision tree model is actually predicted by using the decision tree model because a decision tree model composed of a large number of training sample sets is complex. In order to avoid the decision tree model from being overfitted, a pruning module can be introduced, namely, some subtrees or nodes are cut off from the generated decision tree model, so that the decision tree model is simplified. Pruning of decision tree models can generally be divided into two categories: pre-pruning and post-pruning. Pre-pruning refers to performing pruning operations during the generation and construction of the decision tree model. Post-pruning may be a pruning operation performed after the decision tree model is constructed. According to the method and the device, pruning operation is carried out on the constructed decision tree model by selecting the post-pruning strategy so as to prevent overfitting.
In one implementation, the specific implementation of the post-pruning strategy can be shown as an algorithm as follows:
inputting: initial decision tree T1
And (3) outputting: pruned decision tree T2
The method mainly comprises the following steps:
1. computing an initial decision tree T1Empirical entropy of each node
2. Recursively retracting upward from leaf nodes of a tree
Setting a group of decision trees with leaf nodes before and after the leaf node is retracted to the father node as TBAnd TAThe corresponding loss function value is C (T)B) And C (T)A) If C (T)A) C (T) or lessB) Then the leaf node is pruned, and the father node corresponding to the leaf node is changed into a new leaf node
3. Returning to 2 until the decision tree T after pruning can not be obtained2
Based on the algorithm shown above, the process of post-pruning can be understood as follows: and calculating the experience entropy of each node on the decision tree, and retracting any leaf node in the decision tree upwards to retract to the parent node of the leaf node. The leaf node is set as the first decision tree before retraction and the second decision tree after retraction. The loss function value C (T) corresponding to the first decision tree before retraction can be calculatedB) Loss function value C (T) corresponding to the second decision tree after retractionA). If C (T)A) Less than C (T)B) Then the leaf node is pruned and the parent node of the leaf node becomes the new leaf node. And (4) performing retraction processing on the nodes of the decision tree in a circulating manner in sequence, so that the decision tree after pruning can be obtained.
In an implementation manner, after the decision tree model is obtained by the above method, the target execution plan corresponding to the structured query statement to be audited may be input to the decision tree model for decision processing, so as to obtain the policy type of the structured query statement to be audited, and obtain the optimization policy indicated by the policy type. After the to-be-optimized strategy is obtained, the optimization strategy can be displayed on a user review interface, so that reviewers can optimize the to-be-reviewed structured query statement based on the optimization strategy displayed on the user review interface. For example, the optimization strategy corresponding to the structured query statement to be reviewed may be to reduce the number of loops in the structured query statement, or to reduce the execution time of the structured query statement, and so on.
For specific implementation of steps S401 to S405, reference may be made to the detailed description of steps S201 to S204 in the above embodiment, which is not described herein again.
In the embodiment of the application, the structural query statement to be audited in the target file can be obtained, and the structural query statement to be audited is analyzed, so that the syntax analysis tree corresponding to the structural query statement to be audited is obtained. Then, a target execution plan corresponding to the structured query statement to be audited can be determined according to the syntax parse tree, so that the audit rule can be determined according to the audit rule setting operation detected in the user audit interface, and the to-be-audited nuclear data corresponding to the audit rule can be determined from the target execution plan. Furthermore, the data to be audited can be audited based on the audit rule, and if the structured query statement to be audited is determined to pass statement audit according to the audit result, the statement audit passing result is output on the user audit interface. And if the structural query statement to be audited is determined not to pass statement audit, a decision tree model can be called to carry out decision processing on the structural query statement to be audited, an optimization strategy corresponding to the structural query statement to be audited is obtained, and the optimization strategy is output on a user audit interface. By implementing the method, the training execution plan of the training statement can be learned by means of the neural network model, so that a decision tree model which can perform decision processing on the target execution plan of the structural query statement to be audited is constructed, the optimization strategy corresponding to the structural query statement to be audited can be predicted according to the decision tree model, and the intellectualization of optimization strategy recommendation can be realized.
Referring to fig. 5, fig. 5 is a schematic structural diagram of a sentence auditing apparatus according to an embodiment of the present application. The statement auditing device comprises:
the parsing unit 501 is configured to obtain a to-be-audited structured query statement in a target file, and parse the to-be-audited structured query statement to obtain a syntax parse tree corresponding to the to-be-audited structured query statement;
a determining unit 502, configured to determine, according to the syntax parse tree, a target execution plan corresponding to the to-be-audited structured query statement, where the target execution plan includes: executing the operation data to be checked during the structured query statement in the database;
the auditing unit 503 is configured to determine an auditing rule according to auditing rule setting operation detected in a user auditing interface, determine the to-be-audited data corresponding to the auditing rule from the target execution plan, and audit the to-be-audited data based on the auditing rule;
and the output unit 504 is configured to output a statement audit passing result on the user audit interface if it is determined that the to-be-audited structured query statement passes the statement audit according to the audit result.
In an implementation manner, the parsing unit 501 is specifically configured to:
performing lexical analysis on the structural query statement to be audited to obtain morpheme flow information corresponding to the structural query statement to be audited;
and performing syntax analysis on morpheme stream information corresponding to the structural query statement to be audited to obtain a syntax analysis tree corresponding to the structural query statement to be audited.
In one implementation manner, the number of the data to be audited is multiple, and the audit result of any piece of data to be audited includes: the any to-be-examined data passes the examination and verification, or the any to-be-examined data does not pass the examination and verification; the auditing unit 503 is specifically configured to:
counting the number of target auditing results, wherein the target auditing results are used for indicating the auditing results of the to-be-audited data passing the auditing;
detecting whether the number of the target auditing results exceeds a preset number threshold value or not;
if the number exceeds the preset number threshold value, determining that the structured query statement to be audited passes statement audit;
and if the number does not exceed the preset number threshold value, determining that the structured query statement to be audited does not pass statement audit.
In an implementation manner, the apparatus further includes a decision unit 505, where the decision unit 505 is specifically configured to:
if the fact that the structural query statement to be audited does not pass statement audit is determined, a decision tree model is called to carry out decision processing on the structural query statement to be audited to obtain an optimization strategy corresponding to the structural query statement to be audited, and the optimization strategy is output on the user audit interface;
and the optimization strategy is used for indicating a strategy for adjusting the target execution plan of the structured query statement to be audited, so that the adjusted structured query statement to be audited passes statement audit.
In an implementation manner, the decision unit 505 is specifically configured to:
obtaining a training execution plan of one or more training sentences, the training execution plan of any training sentence comprising: operational data when executing the any training statement in a database;
adding a training strategy type label to each of the training execution plans of the one or more training sentences;
constructing a decision tree model based on a training sample set, wherein the training sample set comprises training execution plans added with training strategy type labels;
and inputting the target execution plan corresponding to the structural query statement to be audited into the decision tree model for decision processing to obtain the strategy type of the structural query statement to be audited, and obtaining the optimization strategy indicated by the strategy type.
In an implementation manner, the decision unit 505 is specifically configured to:
determining a feature data set based on the operation data included in each training execution plan, wherein the feature data set includes one or more feature data;
and calculating information gain corresponding to each feature data in the feature data set according to the training sample set, and constructing the decision tree model based on the information gain corresponding to each feature data.
In one implementation, the determining unit 502 is further configured to:
connecting a database where the structural query statement to be audited is executed, and executing the structural query statement to be audited in the database to obtain one or more execution plans corresponding to the structural query statement to be audited;
and determining a target execution plan from the one or more execution plans according to a preset selection rule.
It can be understood that the functions of the functional units of the statement auditing apparatus described in the embodiment of the present application may be specifically implemented according to the method in the method embodiment described in fig. 2 or fig. 4, and the specific implementation process may refer to the description related to the method embodiment of fig. 1 or fig. 4, which is not described herein again.
In the embodiment of the application, an analysis unit 501 obtains a structural query statement to be audited in a target file, and analyzes the structural query statement to be audited to obtain a syntax analysis tree corresponding to the structural query statement to be audited; the determining unit 502 determines, according to the syntax parse tree, a target execution plan corresponding to the to-be-audited structured query statement, where the target execution plan includes: executing the operation data to be checked during the structured query statement in the database; the auditing unit 503 determines an auditing rule according to auditing rule setting operation detected in a user auditing interface, determines the data to be audited corresponding to the auditing rule from the target execution plan, and audits the data to be audited based on the auditing rule; if the output unit 504 determines that the to-be-audited structured query statement passes the statement audit according to the audit result, the statement audit pass result is output on the user audit interface. Statement auditing can be automatically carried out, auditing can be carried out according to auditing rules set by a user, tedious manual operation which is easy to make mistakes is solved, and the working efficiency is improved.
Referring to fig. 6, fig. 6 is a schematic structural diagram of a computer device according to an embodiment of the present disclosure. The computer device includes: a processor 601, a memory 602, and a network interface 603. The processor 601, the memory 602, and the network interface 603 may exchange data therebetween.
The Processor 601 may be a Central Processing Unit (CPU), and may also be other general purpose processors, Digital Signal Processors (DSPs), Application Specific Integrated Circuits (ASICs), Field-Programmable Gate arrays (FPGAs) or other Programmable logic devices, discrete Gate or transistor logic devices, discrete hardware components, and the like. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
The memory 602 may include both read-only memory and random access memory, and provides program instructions and data to the processor 601. A portion of the memory 602 may also include random access memory. Wherein, the processor 601, when calling the program instruction, is configured to perform:
acquiring a structural query statement to be audited in a target file, and analyzing the structural query statement to be audited to obtain a syntax analysis tree corresponding to the structural query statement to be audited;
determining a target execution plan corresponding to the structured query statement to be audited according to the syntax parse tree, wherein the target execution plan comprises: executing the operation data to be checked during the structured query statement in the database;
setting operation according to an audit rule detected in a user audit interface to determine an audit rule, determining to-be-audited data corresponding to the audit rule from the target execution plan, and auditing the to-be-audited data based on the audit rule;
and if the structural query statement to be audited is determined to pass statement audit according to the audit result, outputting a statement audit passing result on the user audit interface.
In one implementation, the processor 601 is specifically configured to:
performing lexical analysis on the structural query statement to be audited to obtain morpheme flow information corresponding to the structural query statement to be audited;
and performing syntax analysis on morpheme stream information corresponding to the structural query statement to be audited to obtain a syntax analysis tree corresponding to the structural query statement to be audited.
In one implementation manner, the number of the data to be audited is multiple, and the audit result of any piece of data to be audited includes: the any to-be-examined data passes the examination and verification, or the any to-be-examined data does not pass the examination and verification; the processor 601 is specifically configured to:
counting the number of target auditing results, wherein the target auditing results are used for indicating the auditing results of the to-be-audited data passing the auditing;
detecting whether the number of the target auditing results exceeds a preset number threshold value or not;
if the number exceeds the preset number threshold value, determining that the structured query statement to be audited passes statement audit;
and if the number does not exceed the preset number threshold value, determining that the structured query statement to be audited does not pass statement audit.
In one implementation, the processor 601 is further configured to:
if the fact that the structural query statement to be audited does not pass statement audit is determined, a decision tree model is called to carry out decision processing on the structural query statement to be audited to obtain an optimization strategy corresponding to the structural query statement to be audited, and the optimization strategy is output on the user audit interface;
and the optimization strategy is used for indicating a strategy for adjusting the target execution plan of the structured query statement to be audited, so that the adjusted structured query statement to be audited passes statement audit.
In one implementation, the processor 601 is specifically configured to:
obtaining a training execution plan of one or more training sentences, the training execution plan of any training sentence comprising: operational data when executing the any training statement in a database;
adding a training strategy type label to each of the training execution plans of the one or more training sentences;
constructing a decision tree model based on a training sample set, wherein the training sample set comprises training execution plans added with training strategy type labels;
and inputting the target execution plan corresponding to the structural query statement to be audited into the decision tree model for decision processing to obtain the strategy type of the structural query statement to be audited, and obtaining the optimization strategy indicated by the strategy type.
In one implementation, the processor 601 is specifically configured to:
determining a feature data set based on the operation data included in each training execution plan, wherein the feature data set includes one or more feature data;
and calculating information gain corresponding to each feature data in the feature data set according to the training sample set, and constructing the decision tree model based on the information gain corresponding to each feature data.
In one implementation, the processor 601 is further configured to:
connecting a database where the structural query statement to be audited is executed, and executing the structural query statement to be audited in the database to obtain one or more execution plans corresponding to the structural query statement to be audited;
and determining a target execution plan from the one or more execution plans according to a preset selection rule.
In a specific implementation, the processor 601 and the memory 602 described in this embodiment of the present application may execute the implementation described in the statement auditing method provided in fig. 2 or fig. 4 in this embodiment of the present application, and may also execute the implementation of the statement auditing apparatus described in fig. 5 in this embodiment of the present application, which is not described herein again.
In the embodiment of the application, the processor 601 may obtain a to-be-audited structured query statement in a target file, and analyze the to-be-audited structured query statement to obtain a syntax parse tree corresponding to the to-be-audited structured query statement; determining a target execution plan corresponding to the structured query statement to be audited according to the syntax parse tree, wherein the target execution plan comprises: executing the operation data to be checked during the structured query statement in the database; setting operation according to an audit rule detected in a user audit interface to determine an audit rule, determining to-be-audited data corresponding to the audit rule from the target execution plan, and auditing the to-be-audited data based on the audit rule; and if the structural query statement to be audited is determined to pass statement audit according to the audit result, outputting a statement audit passing result on the user audit interface. Statement auditing can be automatically carried out, auditing can be carried out according to auditing rules set by a user, tedious manual operation which is easy to make mistakes is solved, and the working efficiency is improved.
The embodiment of the present application further provides a computer-readable storage medium, in which program instructions are stored, and when the program is executed, part or all of the steps of the statement auditing method in the embodiment corresponding to fig. 2 or fig. 4 may be included.
It should be noted that, for simplicity of description, the above-mentioned embodiments of the method are described as a series of acts or combinations, but those skilled in the art should understand that the present application is not limited by the order of acts described, as some steps may be performed in other orders or simultaneously according to the present application. Further, those skilled in the art should also appreciate that the embodiments described in the specification are preferred embodiments and that the acts and modules referred to are not necessarily required in this application.
Those skilled in the art will appreciate that all or part of the steps in the methods of the above embodiments may be implemented by associated hardware instructed by a program, which may be stored in a computer-readable storage medium, and the storage medium may include: flash disks, Read-Only memories (ROMs), Random Access Memories (RAMs), magnetic or optical disks, and the like.
It is emphasized that the data may also be stored in a node of a blockchain in order to further ensure the privacy and security of the data. The block chain is a novel application mode of computer technologies such as distributed data storage, point-to-point transmission, a consensus mechanism and an encryption algorithm. A block chain (Blockchain), which is essentially a decentralized database, is a series of data blocks associated by using a cryptographic method, and each data block contains information of a batch of network transactions, so as to verify the validity (anti-counterfeiting) of the information and generate a next block. The blockchain may include a blockchain underlying platform, a platform product service layer, an application service layer, and the like.
The statement auditing method, device, computer equipment and storage medium provided by the embodiments of the present application are introduced in detail, and a specific example is applied in the present application to explain the principle and implementation manner of the present application, and the description of the embodiments is only used to help understand the method and core ideas of the present application; meanwhile, for a person skilled in the art, according to the idea of the present application, there may be variations in the specific embodiments and the application scope, and in summary, the content of the present specification should not be construed as a limitation to the present application.

Claims (10)

1. A statement auditing method, comprising:
acquiring a structural query statement to be audited in a target file, and analyzing the structural query statement to be audited to obtain a syntax analysis tree corresponding to the structural query statement to be audited;
determining a target execution plan corresponding to the structured query statement to be audited according to the syntax parse tree, wherein the target execution plan comprises: executing the operation data to be checked during the structured query statement in the database;
setting operation according to an audit rule detected in a user audit interface to determine an audit rule, determining to-be-audited data corresponding to the audit rule from the target execution plan, and auditing the to-be-audited data based on the audit rule;
and if the structural query statement to be audited is determined to pass statement audit according to the audit result, outputting a statement audit passing result on the user audit interface.
2. The method of claim 1, wherein the parsing the to-be-audited structured query statement to obtain a syntax parse tree corresponding to the to-be-audited structured query statement comprises:
performing lexical analysis on the structural query statement to be audited to obtain morpheme flow information corresponding to the structural query statement to be audited;
and performing syntax analysis on morpheme stream information corresponding to the structural query statement to be audited to obtain a syntax analysis tree corresponding to the structural query statement to be audited.
3. The method according to claim 1, wherein the number of the data to be audited is plural, and the audit result of any data to be audited includes: the any to-be-examined data passes the examination and verification, or the any to-be-examined data does not pass the examination and verification; if it is determined that the to-be-audited structured query statement passes the statement audit according to the audit result, before outputting the statement audit passing result on the user audit interface, the method further includes:
counting the number of target auditing results, wherein the target auditing results are used for indicating the auditing results of the to-be-audited data passing the auditing;
detecting whether the number of the target auditing results exceeds a preset number threshold value or not;
if the number exceeds the preset number threshold value, determining that the structured query statement to be audited passes statement audit;
and if the number does not exceed the preset number threshold value, determining that the structured query statement to be audited does not pass statement audit.
4. The method of claim 3, further comprising:
if the fact that the structural query statement to be audited does not pass statement audit is determined, a decision tree model is called to carry out decision processing on the structural query statement to be audited to obtain an optimization strategy corresponding to the structural query statement to be audited, and the optimization strategy is output on the user audit interface;
and the optimization strategy is used for indicating a strategy for adjusting the target execution plan of the structured query statement to be audited, so that the adjusted structured query statement to be audited passes statement audit.
5. The method of claim 4, wherein before the invoking of the decision tree model to perform decision processing on the to-be-audited structured query statement to obtain the optimization policy corresponding to the to-be-audited structured query statement, the method includes:
obtaining a training execution plan of one or more training sentences, the training execution plan of any training sentence comprising: operational data when executing the any training statement in a database;
adding a training strategy type label to each of the training execution plans of the one or more training sentences;
constructing a decision tree model based on a training sample set, wherein the training sample set comprises training execution plans added with training strategy type labels;
the calling of the decision tree model to perform decision processing on the structural query statement to be audited to obtain an optimization strategy corresponding to the structural query statement to be audited, and the method comprises the following steps:
and inputting the target execution plan corresponding to the structural query statement to be audited into the decision tree model for decision processing to obtain the strategy type of the structural query statement to be audited, and obtaining the optimization strategy indicated by the strategy type.
6. The method of claim 5, wherein constructing a decision tree model based on a training sample set comprises:
determining a feature data set based on the operation data included in each training execution plan, wherein the feature data set includes one or more feature data;
and calculating information gain corresponding to each feature data in the feature data set according to the training sample set, and constructing the decision tree model based on the information gain corresponding to each feature data.
7. The method of claim 1, further comprising:
connecting a database where the structural query statement to be audited is executed, and executing the structural query statement to be audited in the database to obtain one or more execution plans corresponding to the structural query statement to be audited;
and determining a target execution plan from the one or more execution plans according to a preset selection rule.
8. A sentence auditing apparatus, comprising:
the parsing unit is used for acquiring a structural query statement to be audited in a target file, and parsing the structural query statement to be audited to obtain a syntax parsing tree corresponding to the structural query statement to be audited;
a determining unit, configured to determine, according to the syntax parse tree, a target execution plan corresponding to the to-be-audited structured query statement, where the target execution plan includes: executing the operation data to be checked during the structured query statement in the database;
the auditing unit is used for setting operation according to the auditing rule detected in a user auditing interface to determine an auditing rule, determining the data to be audited corresponding to the auditing rule from the target execution plan, and auditing the data to be audited based on the auditing rule;
and the output unit is used for outputting a statement audit passing result on the user audit interface if the structural query statement to be audited passes the statement audit according to the audit result.
9. A computer device comprising a processor, a memory, wherein the memory is configured to store a computer program comprising program instructions, and wherein the processor is configured to invoke the program instructions to perform the method of any of claims 1-7.
10. A computer-readable storage medium, characterized in that the computer-readable storage medium stores a computer program comprising program instructions that, when executed by a processor, cause the processor to carry out the method according to any one of claims 1-7.
CN202210039752.3A 2022-01-13 2022-01-13 Statement auditing method and device, computer equipment and storage medium Pending CN114386402A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210039752.3A CN114386402A (en) 2022-01-13 2022-01-13 Statement auditing method and device, computer equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210039752.3A CN114386402A (en) 2022-01-13 2022-01-13 Statement auditing method and device, computer equipment and storage medium

Publications (1)

Publication Number Publication Date
CN114386402A true CN114386402A (en) 2022-04-22

Family

ID=81201944

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210039752.3A Pending CN114386402A (en) 2022-01-13 2022-01-13 Statement auditing method and device, computer equipment and storage medium

Country Status (1)

Country Link
CN (1) CN114386402A (en)

Similar Documents

Publication Publication Date Title
CN108764480B (en) Information processing system
CN106293891B (en) Multidimensional investment index monitoring method
CN109857641A (en) The method and device of defects detection is carried out to program source file
CN110427188B (en) Configuration method, device, equipment and storage medium of single-test assertion program
CN112416778A (en) Test case recommendation method and device and electronic equipment
CN109285024B (en) Online feature determination method and device, electronic equipment and storage medium
CN111723192B (en) Code recommendation method and device
CN116361147A (en) Method for positioning root cause of test case, device, equipment, medium and product thereof
CN111178701B (en) Risk control method and device based on feature derivation technology and electronic equipment
CN112417852B (en) Method and device for judging importance of code segment
CN113778864A (en) Test case generation method and device, electronic equipment and storage medium
CN116383742B (en) Rule chain setting processing method, system and medium based on feature classification
CN113297251A (en) Multi-source data retrieval method, device, equipment and storage medium
CN114356744A (en) Application program interface traversal method and device based on machine learning
CN112416800A (en) Intelligent contract testing method, device, equipment and storage medium
CN112711678A (en) Data analysis method, device, equipment and storage medium
CN111475405A (en) Regression testing method and device, computer equipment and storage medium
CN114386402A (en) Statement auditing method and device, computer equipment and storage medium
CN115454702A (en) Log fault analysis method and device, storage medium and electronic equipment
CN114297057A (en) Design and use method of automatic test case
CN114880239A (en) Interface automation testing framework and method based on data driving
CN113064811A (en) Workflow-based automatic testing method and device and electronic equipment
CN115203057B (en) Low code test automation method, device, equipment and storage medium
CN116757203B (en) Natural language matching method, device, computer equipment and storage medium
CN115168399B (en) Data processing method, device and equipment based on graphical interface and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination