SQL (Structured Query Language) statement modification conflict prediction method and device, equipment and storage medium
By constructing the data blood relationship graph of SQL statements, using graph convolution network and Transformer model to extract feature information, and fusion of self-attention mechanisms, the problem of low accuracy of SQL statement modification conflict prediction in the existing technology is solved, and a higher level of prediction accuracy.
Patent Information
- Application Number
- CN202411045403.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-31
- Publication Date
- 2024-12-27
AI Technical Summary
The existing data blood conflict prediction scheme cannot update the changing dependencies in real time, and cannot effectively understand the semantic feature information of complex SQL statements, resulting in low prediction accuracy.
By constructing a data blood relationship graph of SQL statements, the graph convolution network and the Transformer model are used to extract structural feature information and semantic feature information respectively, and feature fusion is performed through the self-attention mechanism, dynamically adjust the weight of different feature information to improve prediction accuracy.
It significantly improves the prediction accuracy of whether SQL statement modification can cause conflicts, and can more accurately judge the impact of SQL statement modification on the database structure.
Smart Images

Figure CN119201967A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing, and in particular to a method, device, equipment and storage medium for predicting SQL statement modification conflicts. Background Art
[0002] In the work of database data analysis, it is often necessary to modify some query operations to adapt to changes in the database structure. After modifying the database structure, it is often necessary to modify all query statements at the same time. In an environment with a large number of query statements, it is very complicated to handle such modifications. In addition, changing a database structure may have a chain reaction on the entire data flow and cause some security issues, so an automated method is needed to solve it. Summary of the invention
[0003] The present application provides a method, apparatus, device and storage medium for predicting SQL statement modification conflicts.
[0004] An embodiment of the present application provides, on one hand, a method for predicting SQL statement modification conflicts, the method comprising:
[0005] Construct a data lineage graph for SQL statements;
[0006] Based on the data lineage graph, using a first model to determine structural feature information of the SQL statement;
[0007] Based on the SQL statement, determining semantic feature information of the SQL statement using a second model;
[0008] The structural feature information and the semantic feature information of the SQL statement are fused through a self-attention mechanism to obtain fused feature information of the SQL statement;
[0009] Based on the fused feature information of the SQL statement, a prediction result corresponding to the SQL statement is obtained, where the prediction result represents a probability that modifying the SQL statement will cause a conflict.
[0010] The data lineage graph includes at least two nodes and one edge of the SQL statement, and determining the semantic feature information of the SQL statement by using the second model based on the SQL statement includes:
[0011] Determine, from the SQL statement, a SQL statement fragment corresponding to the node and the edge;
[0012] Feature extraction is performed on the SQL statement fragment to obtain semantic feature information represented by the node and the edge.
[0013] The data lineage graph includes at least two nodes and one edge of the SQL statement, and determining the structural feature information of the SQL statement based on the data lineage graph using the first model includes:
[0014] Extracting features from the data lineage graph to obtain initial structural feature information of the node representation and structural feature information of the edge representation;
[0015] Determine an adjacency matrix of the node based on initial structural feature information represented by the node and neighboring nodes of the node;
[0016] The initial structural feature information represented by the node is updated based on the adjacency matrix of the node to obtain the structural feature information of the node.
[0017] The step of extracting features from the SQL statement fragment to obtain semantic feature information of the node representation includes:
[0018] Splitting the SQL statement fragment of the node into multiple sub-fragments;
[0019] converting the sub-segment into a feature vector;
[0020] Determining a position code of the sub-segment;
[0021] Determining semantic feature information of the node representation based on the feature vector and position encoding of the sub-segment;
[0022] Accordingly, the feature extraction of the SQL statement fragment to obtain the semantic feature information of the edge representation includes:
[0023] Splitting the SQL statement fragment of the edge into multiple sub-fragments;
[0024] converting the sub-segment into a feature vector;
[0025] Determining a position code of the sub-segment;
[0026] Semantic feature information of the edge representation is determined based on the feature vector and position encoding of the sub-segment.
[0027] The determining of the semantic feature information of the node representation based on the feature vector and position coding of the sub-segment, or the determining of the semantic feature information of the edge representation based on the feature vector and position coding of the sub-segment, includes:
[0028] Determine an attention score corresponding to the feature vector through a self-attention mechanism based on the feature vector and the position encoding of the sub-segment;
[0029] Determine candidate semantic feature information of the node or the edge based on feature vectors of the multiple sub-segments of the node or the edge and attention scores corresponding to the feature vectors;
[0030] Splitting the candidate semantic feature information into a preset number of candidate sub-semantic feature information;
[0031] The preset number of candidate sub-semantic feature information are fused through a multi-head self-attention mechanism to obtain the semantic feature information of the node or the edge.
[0032] The step of performing prediction based on the fused feature information of the SQL statement to obtain a prediction result of the SQL statement includes:
[0033] Inputting the fused feature information into a preset number of fully connected layers to obtain a candidate prediction result;
[0034] The prediction result of the SQL statement is determined based on the candidate prediction results through an activation function.
[0035] The structural feature information of the node representation at least includes type information, attribute information and / or degree information of the node;
[0036] The structural feature information of the edge representation at least includes the type information and attribute information of the edge.
[0037] Another aspect of the present application embodiment provides a device for predicting SQL statement modification conflicts, the device comprising:
[0038] Processing module, used to build the data lineage graph of SQL statements;
[0039] A computing module, configured to determine the structural feature information of the SQL statement using a first model based on the data lineage graph; determine the semantic feature information of the SQL statement using a second model based on the SQL statement; and fuse the structural feature information and the semantic feature information of the SQL statement through a self-attention mechanism to obtain fused feature information of the SQL statement;
[0040] The prediction module is used to obtain a prediction result corresponding to the SQL statement based on the fused feature information of the SQL statement, wherein the prediction result represents the probability that modifying the SQL statement will cause a conflict.
[0041] Another aspect of the present invention provides an electronic device, comprising: a processor
[0042] The processor constructs a data lineage graph of the SQL statement; determines the structural feature information of the SQL statement using a first model based on the data lineage graph; determines the semantic feature information of the SQL statement using a second model based on the SQL statement; performs feature fusion of the structural feature information and the semantic feature information of the SQL statement through a self-attention mechanism to obtain fused feature information of the SQL statement; and obtains a prediction result corresponding to the SQL statement based on the fused feature information of the SQL statement. .
[0043] On the other hand, the present invention provides a computer-readable storage medium, which stores a computer program, wherein the computer program is used to construct a data lineage graph for SQL statements; determine structural feature information of the SQL statement using a first model based on the data lineage graph; determine semantic feature information of the SQL statement using a second model based on the SQL statement; fuse the structural feature information and semantic feature information of the SQL statement through a self-attention mechanism to obtain fused feature information of the SQL statement; and obtain a prediction result corresponding to the SQL statement based on the fused feature information of the SQL statement.
[0044] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present application, nor is it intended to limit the scope of the present application. Other features of the present application will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] By reading the detailed description below with reference to the accompanying drawings, the above and other purposes, features and advantages of the exemplary embodiments of the present application will become readily understood. In the accompanying drawings, several embodiments of the present application are shown in an exemplary and non-limiting manner, wherein:
[0046] In the drawings, the same or corresponding reference numerals represent the same or corresponding parts.
[0047] Figure 1 A flowchart of a method for predicting SQL statement modification conflicts according to an embodiment of the present application is shown;
[0048] Figure 2 A flowchart of a method for predicting SQL statement modification conflicts according to another embodiment of the present application is shown;
[0049] Figure 3 A flowchart of a method for predicting SQL statement modification conflicts according to another embodiment of the present application is shown;
[0050] Figure 4 A flowchart of a method for predicting SQL statement modification conflicts according to another embodiment of the present application is shown;
[0051] Figure 5 A flowchart of a method for predicting SQL statement modification conflicts according to another embodiment of the present application is shown;
[0052] Figure 6 A flowchart of a method for predicting SQL statement modification conflicts according to another embodiment of the present application is shown;
[0053] Figure 7 A flowchart of a method for predicting SQL statement modification conflicts according to another embodiment of the present application is shown;
[0054] Figure 8 A schematic diagram of the structure of a device for predicting SQL statement modification conflicts according to an embodiment of the present application is shown;
[0055] Fig. 9 A schematic diagram of the structure of an electronic device according to an embodiment of the present application is shown. DETAILED DESCRIPTION
[0056] In order to make the purpose, features, and advantages of the present application more obvious and easy to understand, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present application.
[0057] The current solution for predicting data lineage conflicts is unable to update the changing dependencies in real time and cannot understand the complex semantic feature information of SQL statements, so the prediction accuracy is low. In order to simultaneously consider the structural feature information and semantic feature information of SQL statements, and thus improve the accuracy of predicting whether SQL statement modification will cause conflicts, an embodiment of the present application provides a method for predicting SQL statement modification conflicts, such as Figure 1 As shown, the method includes:
[0058] Step 101, construct a data lineage graph of SQL statements.
[0059] Parse the input SQL statements and build a syntax tree for each SQL statement, where each node in the syntax tree represents a table, field, or operation in the SQL statement. Use the DFS (depth-first search) algorithm to traverse the syntax tree of each SQL statement and identify dependencies at the table and field levels. Create nodes in the data lineage graph based on each table, field, function definition, and result set to build a data lineage graph for SQL statements.
[0060] Step 102: Based on the data lineage graph, use a first model to determine structural feature information of the SQL statement.
[0061] In this embodiment, the first model may use a graph convolutional network.
[0062] Step 103: Based on the SQL statement, determine the semantic feature information of the SQL statement using the second model.
[0063] In this embodiment, the second model may be a transformer model.
[0064] Step 104: Fusing the structural feature information and the semantic feature information of the SQL statement through a self-attention mechanism to obtain fused feature information of the SQL statement.
[0065] The structural feature information of the SQL statement output by the first model and the semantic feature information of the SQL statement output by the second model are fused. Since structural feature information and semantic feature information are two different types of feature information, simple feature concatenation methods cannot fuse these two types of feature information, so feature fusion needs to be performed through a self-attention mechanism.
[0066] Step 105: obtaining a prediction result corresponding to the SQL statement based on the fused feature information of the SQL statement, wherein the prediction result represents a probability that a conflict will be caused by modifying the SQL statement.
[0067] The probability that a conflict will occur if the SQL statement is modified is calculated based on the fused feature information of the SQL statement, that is, the prediction result corresponding to the SQL statement is obtained.
[0068] In the above scheme, by constructing the data lineage graph of SQL statements, more accurate structural feature information and semantic feature information can be extracted from SQL statements based on the first model and the second model. By fusion of the structural feature information and semantic feature information of SQL statements through the self-attention mechanism, the weights of different feature information can be dynamically adjusted during the feature fusion process, and higher weights can be set for relatively important feature information, thereby significantly improving the effect of feature fusion and the accuracy of prediction.
[0069] In an example of the present application, a method for predicting SQL statement modification conflicts is also provided. Figure 2 As shown, the data lineage graph includes at least two nodes and one edge of the SQL statement, and the determining the semantic feature information of the SQL statement based on the SQL statement using the second model includes:
[0070] When constructing a data lineage graph of an SQL statement, it is necessary to determine at least two nodes and one edge of the SQL statement.
[0071] Step 201: Determine, from the SQL statement, the SQL statement fragments corresponding to the node and the edge.
[0072] Determine the SQL statement fragment corresponding to each node and each edge from the SQL statement.
[0073] Step 202: extract features from the SQL statement fragment to obtain semantic feature information represented by the node and the edge.
[0074] Feature extraction is performed on the SQL statement fragment corresponding to each node and the SQL statement fragment corresponding to each edge to obtain the semantic feature information corresponding to each node and the semantic feature information represented by each edge.
[0075] In the above solution, by determining the SQL statement fragments corresponding to the nodes and edges of the SQL statement in the SQL statement, the semantic feature information represented by the nodes and edges of the SQL statement can be further extracted.
[0076] It should be noted that in this embodiment, the second model uses a converter model. Since the converter model can understand the overall intent of the SQL statement and the interactions between its components, even if there are multiple variations of SQL syntax, the converter model can effectively parse its semantics by learning the patterns and structures of different SQL statements. This improves the accuracy of predicting whether SQL statement modifications will cause conflicts based on the semantic feature information of the SQL statement.
[0077] In an example of the present application, a method for predicting SQL statement modification conflicts is also provided. Figure 3 As shown, the data lineage graph includes at least two nodes and one edge of the SQL statement, and the determining the structural feature information of the SQL statement based on the data lineage graph using the first model includes:
[0078] When constructing a data lineage graph of an SQL statement, it is necessary to determine at least two nodes and one edge of the SQL statement.
[0079] Step 301, extracting features from the data lineage graph to obtain initial structural feature information of the node representation and structural feature information of the edge representation.
[0080] The first model is used to extract features from the data lineage graph to obtain initial structural feature information representing each node and structural feature information representing each edge. Since the extracted node feature information needs to be further processed, the node representation here is the initial structural feature information.
[0081] Step 302: determine the adjacency matrix of the node based on initial structural feature information represented by the node and its neighboring nodes.
[0082] For each node, the structural feature information represented by its neighboring nodes is aggregated to determine the adjacency matrix of the node.
[0083] Step 303: Update the initial structural feature information represented by the node based on the adjacency matrix of the node to obtain the structural feature information of the node.
[0084] For each node, the initial structural feature information represented by the node is updated based on the adjacency matrix of the node to obtain the structural feature information of the node.
[0085] It should be noted that step 302 and step 303 are the processing process of one graph convolution layer, which can be repeated multiple times, and the number of processing times is determined by the number of graph convolution layers in the first model.
[0086] In the above scheme, the initial structural feature information of each node representation and the structural feature information of each edge representation are obtained by extracting the mechanical energy features of the data bloodline graph. Then, the adjacency matrix of the node is determined based on the initial structural feature information of each node and the initial structural feature information of the neighboring nodes of the node, and then the initial structural feature information of the node representation is updated based on the adjacency matrix of the node. After at least one update, the structural feature information of the node representation can be integrated with the structural feature information of the neighboring node representation, thereby improving the accuracy of the obtained structural feature information of the node representation, and then improving the accuracy of predicting whether the modification of the SQL statement will cause a conflict.
[0087] In an example of the present application, a method for predicting SQL statement modification conflicts is also provided. Figure 4 As shown, the feature extraction of the SQL statement fragment to obtain the semantic feature information of the node representation includes:
[0088] Step 401: split the SQL statement segment of the node into multiple sub-segments.
[0089] The SQL statement fragment corresponding to each node is divided into multiple sub-fragments, and the sub-fragments can be based on words as the smallest unit.
[0090] Step 402: convert the sub-segment into a feature vector.
[0091] Convert each sub-segment into a feature vector.
[0092] Step 403: determine the position code of the sub-segment.
[0093] For each sub-segment. Since the second model usually does not have the ability to process sequence data, it is necessary to add a position code to the feature vector of each sub-segment. The position code can be calculated by sine and cosine functions, where each dimension corresponds to a sine or cosine wave of different frequencies. Specifically, the position code PE(pos,i) of the feature vector can be determined by the following formula:
[0094]
[0095]
[0096] Among them, pos is the position index, i is the dimension index, and d model is the dimension of the feature vector.
[0097] Step 404: Determine semantic feature information of the node representation based on the feature vector and position code of the sub-segment.
[0098] The semantic feature information represented by the node is determined based on the feature vectors and position codes of multiple sub-segments of the node.
[0099] Correspondingly, such as Figure 5 As shown, the feature extraction of the SQL statement fragment to obtain the semantic feature information of the edge representation includes:
[0100] Step 501: split the SQL statement segment of the edge into multiple sub-segments.
[0101] Similarly, the SQL statement fragment corresponding to each edge is divided into multiple sub-fragments, and the sub-fragments can be based on words as the smallest unit.
[0102] Step 502: convert the sub-segment into a feature vector.
[0103] Convert each sub-segment into a feature vector.
[0104] Step 503: determine the position code of the sub-segment.
[0105] For each sub-segment. Since the second model usually does not have the ability to process sequence data, it is necessary to add a position code to the feature vector of each sub-segment. The position code can be calculated by sine and cosine functions, where each dimension corresponds to a sine or cosine wave of different frequencies. Specifically, the position code PE(pos,i) of the feature vector can be determined by the following formula:
[0106]
[0107]
[0108] Among them, pos is the position index, i is the dimension index, and d model is the dimension of the feature vector.
[0109] Step 504: Determine semantic feature information of the edge representation based on the feature vector and position code of the sub-segment.
[0110] The semantic feature information represented by the edge is determined based on the feature vectors and position encodings of multiple sub-segments of the edge.
[0111] In the above scheme, the SQL statement fragments corresponding to the nodes and edges are decomposed into multiple sub-fragments and converted into feature vectors. Then, the position code of each feature vector is determined. Thus, the semantic feature information represented by the node or edge can be determined based on the feature vectors and position codes of the multiple sub-fragments.
[0112] In an example of the present application, a method for predicting SQL statement modification conflicts is also provided. Figure 6 As shown, the determining of the semantic feature information of the node representation based on the feature vector and position coding of the sub-segment, or the determining of the semantic feature information of the edge representation based on the feature vector and position coding of the sub-segment, includes:
[0113] Step 601, based on the feature vector and position encoding of the sub-segment, determine the attention score corresponding to the feature vector through a self-attention mechanism.
[0114] The feature vector and position encoding of the sub-fragment are passed through the self-attention mechanism to calculate the attention score between it and the feature vectors of other sub-fragments in the SQL statement fragment.
[0115] Step 602: Determine candidate semantic feature information of the node or the edge based on the feature vectors of the multiple sub-segments of the node or the edge and the attention scores corresponding to the feature vectors.
[0116] Based on the feature vectors of multiple sub-fragments of the node or edge and the attention scores corresponding to each feature vector, the candidate semantic feature information representing the node or edge is obtained.
[0117] Step 603: segment the candidate semantic feature information into a preset number of candidate sub-semantic feature information.
[0118] The preset number is the same as the number of attention heads in the multi-head self-attention mechanism layer.
[0119] Step 604: feature fusion of the preset number of candidate sub-semantic feature information through a multi-head self-attention mechanism to obtain the semantic feature information of the node or the edge.
[0120] Through the multi-head self-attention mechanism, a preset number of candidate sub-semantic feature information is input into different attention heads and the self-attention mechanism is applied, and then the results are spliced to obtain the initial semantic feature information. Next, based on the initial semantic feature information, residual calculation is used to perform multi-layer stacking to ensure that the result after multi-head is at least not weaker than the result of a single self-attention, and finally the semantic feature information represented by the node or edge is obtained through decoding.
[0121] In the above scheme, the feature vectors of multiple sub-fragments of a node or edge are fused by using a self-attention mechanism, which can fully fuse the grammatical and semantic information in the SQL statement fragment corresponding to the node or edge, obtain more accurate semantic feature information, and thus improve the accuracy of the prediction. Then, the candidate semantic feature information represented by the node or edge is divided into a preset number of candidate sub-semantic feature information, and the preset number of candidate sub-semantic feature information is input into different attention heads respectively and the self-attention mechanism is applied, and then feature fusion is performed, which can fully fuse the overall intention of the SQL statement fragment and the interaction between the components, further improve the accuracy of the semantic feature information, and further improve the accuracy of the prediction judgment of whether the SQL statement modification can cause a conflict.
[0122] In an example of the present application, a method for predicting SQL statement modification conflicts is also provided, wherein the structural feature information and the semantic feature information of the SQL statement are fused by a self-attention mechanism to obtain fused feature information of the SQL statement, including:
[0123] Determine the attention scores of the structural feature information and the semantic feature information of the SQL statement.
[0124] Specifically, the attention scores of the structural feature information and semantic feature information of the SQL statement can be determined based on the following formula:
[0125] attention=softmax((h1*h2) T )
[0126] Among them, h1 is the structural feature information of the SQL statement, h2 is the semantic feature information of the SQL statement, attention is the attention score of the structural feature information, and (1-attention) is the attention score of the semantic feature information.
[0127] The fused feature information of the SQL statement is determined based on the structural feature information, the semantic feature information, and the attention score of the structural feature information and the semantic feature information of the SQL statement.
[0128] Specifically, the fusion feature information h3 of the SQL statement can be determined based on the following formula:
[0129] h3=attention*h1+(1-attention)*h2
[0130] Among them, h3 is the fusion feature information of the SQL statement.
[0131] In an example of the present application, a method for predicting SQL statement modification conflicts is also provided. Figure 7 As shown, the prediction is performed based on the fused feature information of the SQL statement to obtain the prediction result of the SQL statement, including:
[0132] Step 701: input the fused feature information into a preset number of fully connected layers to obtain candidate prediction results.
[0133] For example, if the preset number of layers is k, the processing of step 701 can be expressed by the following formula:
[0134] h 3,1 =ReLU(W1*h3+b1) ...
[0136] h 3,k =eLU(W k *h 3,k-1 +b k )
[0137] Among them, h3 is the fusion feature information, h 3,1 is the output of the first fully connected layer, and the output of the previous fully connected layer is used as the input of the next fully connected layer. 3,k-1 is the output of the k-1th fully connected layer and the input of the kth fully connected layer. 3,k is the output of the kth fully connected layer, that is, the candidate prediction result, W1,...,W k is the weight of the first to the kth fully connected layer, b1,...,b k is the bias of the 1st to the kth fully connected layer.
[0138] Step 702: Determine the prediction result of the SQL statement based on the candidate prediction result through an activation function.
[0139] Specifically, the predicted result P of the SQL statement can be determined based on the following formula:
[0140] P = Sigmoid(W out *h 3,k + out )
[0141] Among them, h 3,k is the output of the kth fully connected layer, that is, the candidate prediction result, W out is the weight of the output layer, b outis the bias of the output layer, and Sigmoid is the activation function.
[0142] In an example of the present application, a method for predicting SQL statement modification conflicts is also provided, wherein the structural feature information of the node representation at least includes type information, attribute information and / or degree information of the node;
[0143] The type information of a node may be a table, view, field, etc. The attribute information of a node may be a data type, data size, etc. The degree information of a node may be the number of all in-degrees, out-degrees, and total degrees of the node.
[0144] The structural feature information of the edge representation at least includes type information and attribute information of the edge.
[0145] The edge type information can be data type, such as "INSERT (add operation)", "UPDATE (update operation)", etc., or dependency type, such as direct, indirect, etc. The edge attribute information can be the edge dependency direction, whether it is bidirectional dependency, and the strength of edge dependency.
[0146] In order to implement the above SQL statement modification conflict prediction method, Figure 8 As shown, an example of the present application provides a SQL statement modification conflict prediction device, including:
[0147] Processing module 10, used to construct a data lineage graph of SQL statements;
[0148] The computing module 20 is used to determine the structural feature information of the SQL statement using the first model based on the data lineage graph; determine the semantic feature information of the SQL statement using the second model based on the SQL statement; and fuse the structural feature information and the semantic feature information of the SQL statement through a self-attention mechanism to obtain the fused feature information of the SQL statement;
[0149] The prediction module 30 is used to obtain a prediction result corresponding to the SQL statement based on the fused feature information of the SQL statement, wherein the prediction result represents the probability that modifying the SQL statement will cause a conflict.
[0150] The processing module 10 is further used to determine the SQL statement fragments corresponding to the nodes and the edges from the SQL statement; and to perform feature extraction on the SQL statement fragments to obtain semantic feature information representing the nodes and the edges.
[0151] The processing module 10 is further used to extract features from the data lineage graph to obtain initial structural feature information of the node representation and structural feature information of the edge representation;
[0152] The calculation module 20 is also used to determine the adjacency matrix of the node based on the initial structural feature information represented by the node and its neighboring nodes; and to update the initial structural feature information represented by the node based on the adjacency matrix of the node to obtain the structural feature information of the node.
[0153] Wherein, the processing module 10 is further used to divide the SQL statement fragment of the node into multiple sub-fragments;
[0154] The calculation module 20 is further used to convert the sub-segment into a feature vector; determine the position code of the sub-segment; and determine the semantic feature information of the node representation based on the feature vector and the position code of the sub-segment;
[0155] Correspondingly, the processing module 10 is further used to divide the SQL statement fragment of the edge into multiple sub-fragments;
[0156] The calculation module 20 is further configured to convert the sub-segment into a feature vector; determine a position code of the sub-segment; and determine semantic feature information of the edge representation based on the feature vector and the position code of the sub-segment.
[0157] Among them, the calculation module 20 is also used to determine the attention score corresponding to the feature vector through a self-attention mechanism based on the feature vector and position coding of the sub-segment; determine the candidate semantic feature information of the node or the edge based on the feature vectors of the multiple sub-segments of the node or the edge and the attention scores corresponding to the feature vectors; divide the candidate semantic feature information into a preset number of candidate sub-semantic feature information; and perform feature fusion on the preset number of candidate sub-semantic feature information through a multi-head self-attention mechanism to obtain the semantic feature information of the node or the edge.
[0158] The prediction module 30 is further used to input the fused feature information into a preset number of fully connected layers to obtain candidate prediction results; and determine the prediction result of the SQL statement through an activation function based on the candidate prediction results.
[0159] Among them, the processing module 10 is also used to extract at least the type information, attribute information and / or degree information of the node contained in the structural feature information of the node representation; and to extract at least the type information and attribute information of the edge contained in the structural feature information of the edge representation.
[0160] According to an embodiment of the present disclosure, the present disclosure also provides an electronic device and a readable storage medium.
[0161] Fig. 9A schematic block diagram of an example electronic device 800 that can be used to implement an embodiment of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or required herein.
[0162] like Fig. 9 As shown, the electronic device 800 includes a processor 801;
[0163] The processor 801 constructs a data lineage graph for SQL statements; determines structural feature information of the SQL statements using a first model based on the data lineage graph; determines semantic feature information of the SQL statements using a second model based on the SQL statements; fuses the structural feature information and semantic feature information of the SQL statements through a self-attention mechanism to obtain fused feature information of the SQL statements; and obtains a prediction result corresponding to the SQL statements based on the fused feature information of the SQL statements.
[0164] The processor 801 determines the SQL statement fragments corresponding to the nodes and the edges from the SQL statement; and performs feature extraction on the SQL statement fragments to obtain semantic feature information represented by the nodes and the edges.
[0165] Among them, the processor 801 performs feature extraction on the data lineage graph to obtain initial structural feature information representing the node and structural feature information representing the edge; determines the adjacency matrix of the node based on the initial structural feature information representing the node and the node's neighboring nodes; and updates the initial structural feature information representing the node based on the node's adjacency matrix to obtain the structural feature information of the node.
[0166] The processor 801 divides the SQL statement fragment of the node into multiple sub-fragments; converts the sub-fragments into feature vectors; determines the position codes of the sub-fragments; and determines the semantic feature information represented by the node based on the feature vectors and position codes of the sub-fragments;
[0167] Correspondingly, the processor 801 divides the SQL statement fragment of the edge into multiple sub-fragments; converts the sub-fragments into feature vectors; determines the position codes of the sub-fragments; and determines the semantic feature information represented by the edge based on the feature vectors and position codes of the sub-fragments.
[0168] Among them, the processor 801 determines the attention score corresponding to the feature vector through a self-attention mechanism based on the feature vector and position code of the sub-segment; determines the candidate semantic feature information of the node or the edge based on the feature vectors of the multiple sub-segments of the node or the edge and the attention scores corresponding to the feature vectors; divides the candidate semantic feature information into a preset number of candidate sub-semantic feature information; and performs feature fusion on the preset number of candidate sub-semantic feature information through a multi-head self-attention mechanism to obtain the semantic feature information of the node or the edge.
[0169] The processor 801 inputs the fused feature information into a preset number of fully connected layers to obtain candidate prediction results; and determines the prediction result of the SQL statement through an activation function based on the candidate prediction results.
[0170] The processor 801 extracts at least the type information, attribute information and / or degree information of the node contained in the structural feature information of the node representation; and extracts at least the type information and attribute information of the edge contained in the structural feature information of the edge representation.
[0171] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), integrated systems on a chip (SOCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0172] The program code for implementing the method of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that the program code, when executed by the processor or controller, enables the functions / operations specified in the flow chart and / or block diagram to be implemented. The program code may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0173] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0174] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0175] The systems and techniques described herein may be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), and the Internet.
[0176] A computer system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The relationship of client and server is generated by computer programs running on respective computers and having a client-server relationship with each other. The server may be a cloud server, a server of a distributed system, or a server combined with a blockchain.
[0177] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this disclosure can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved, and this document does not limit this.
[0178] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one of the features. In the description of the present disclosure, the meaning of "plurality" is two or more, unless otherwise clearly and specifically defined.
[0179] The above is only a specific embodiment of the present disclosure, but the protection scope of the present disclosure is not limited thereto. Any person skilled in the art who is familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present disclosure, which should be included in the protection scope of the present disclosure. Therefore, the protection scope of the present disclosure should be based on the protection scope of the claims.
Claims
1. A method for predicting SQL statement modification conflicts, the method comprising: Construct a data lineage graph for SQL statements; Based on the data lineage graph, using a first model to determine structural feature information of the SQL statement; Based on the SQL statement, determining semantic feature information of the SQL statement using a second model; The structural feature information and the semantic feature information of the SQL statement are fused through a self-attention mechanism to obtain fused feature information of the SQL statement; Based on the fused feature information of the SQL statement, a prediction result corresponding to the SQL statement is obtained, where the prediction result represents a probability that modifying the SQL statement will cause a conflict.
2. According to the method of claim 1, the data lineage graph includes at least two nodes and one edge of the SQL statement, and the determining the semantic feature information of the SQL statement based on the SQL statement using the second model comprises: Determine, from the SQL statement, a SQL statement fragment corresponding to the node and the edge; Feature extraction is performed on the SQL statement fragment to obtain semantic feature information represented by the node and the edge.
3. The method according to claim 1, wherein the data lineage graph includes at least two nodes and one edge of the SQL statement, and the determining the structural feature information of the SQL statement based on the data lineage graph using the first model comprises: Performing feature extraction on the data lineage graph to obtain initial structural feature information of the node representation and structural feature information of the edge representation; Determine an adjacency matrix of the node based on initial structural feature information represented by the node and neighboring nodes of the node; The initial structural feature information represented by the node is updated based on the adjacency matrix of the node to obtain the structural feature information of the node.
4. According to the method of claim 2, the step of extracting features from the SQL statement fragment to obtain semantic feature information of the node representation comprises: Splitting the SQL statement fragment of the node into multiple sub-fragments; converting the sub-segment into a feature vector; Determining a position code of the sub-segment; Determining semantic feature information of the node representation based on the feature vector and position encoding of the sub-segment; Accordingly, the feature extraction of the SQL statement fragment to obtain the semantic feature information of the edge representation includes: Splitting the SQL statement fragment of the edge into multiple sub-fragments; converting the sub-segment into a feature vector; Determining a position code of the sub-segment; Semantic feature information of the edge representation is determined based on the feature vector and position encoding of the sub-segment.
5. The method according to claim 4, wherein determining the semantic feature information of the node representation based on the feature vector and position coding of the sub-segment, or determining the semantic feature information of the edge representation based on the feature vector and position coding of the sub-segment, comprises: Determine an attention score corresponding to the feature vector through a self-attention mechanism based on the feature vector and the position encoding of the sub-segment; Determine candidate semantic feature information of the node or the edge based on feature vectors of the multiple sub-segments of the node or the edge and attention scores corresponding to the feature vectors; Splitting the candidate semantic feature information into a preset number of candidate sub-semantic feature information; The preset number of candidate sub-semantic feature information are fused through a multi-head self-attention mechanism to obtain the semantic feature information of the node or the edge.
6. The method according to claim 1, wherein the step of performing prediction based on the fused feature information of the SQL statement to obtain the prediction result of the SQL statement comprises: Inputting the fused feature information into a preset number of fully connected layers to obtain a candidate prediction result; The prediction result of the SQL statement is determined based on the candidate prediction results through an activation function.
7. According to the method of claim 3, the structural feature information of the node representation at least includes type information, attribute information and / or degree information of the node; The structural feature information of the edge representation at least includes type information and attribute information of the edge.
8. A device for predicting SQL statement modification conflicts, the device comprising: Processing module, used to build the data lineage graph of SQL statements; A calculation module, used for determining structural feature information of the SQL statement based on the data lineage graph using a first model; Determine semantic feature information of the SQL statement using a second model based on the SQL statement; And fusing the structural feature information and the semantic feature information of the SQL statement through a self-attention mechanism to obtain fused feature information of the SQL statement; The prediction module is used to obtain a prediction result corresponding to the SQL statement based on the fused feature information of the SQL statement, wherein the prediction result represents the probability that modifying the SQL statement will cause a conflict.
9. An electronic device, comprising: processor The processor constructs a data lineage graph of the SQL statement; based on the data lineage graph, the first model is used to determine the structural feature information of the SQL statement; Determine semantic feature information of the SQL statement using a second model based on the SQL statement; The structural feature information and the semantic feature information of the SQL statement are fused through a self-attention mechanism to obtain fused feature information of the SQL statement; And based on the fused feature information of the SQL statement, a prediction result corresponding to the SQL statement is obtained.
10. A computer-readable storage medium storing a computer program, wherein the computer program is used to construct a data lineage graph of an SQL statement; and to determine structural feature information of the SQL statement using a first model based on the data lineage graph; Determine semantic feature information of the SQL statement using a second model based on the SQL statement; The structural feature information and the semantic feature information of the SQL statement are fused through a self-attention mechanism to obtain fused feature information of the SQL statement; And based on the fused feature information of the SQL statement, a prediction result corresponding to the SQL statement is obtained.
Citation Information
Patent Citations
Automatic code defect positioning and repairing method
CN114416421A
Long composite statement event extraction method and device based on dependency analysis and Longform
CN116629255A
Transform-based micro-service performance anomaly detection method and system
CN116776270A
SQL-based blood relationship influence analysis method and system
CN117056569A
Knowledge graph-based few-sample multi-hop reasoning optimization method
CN118095445A
