Abstract Syntax Tree Query Similarity Detection
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Existing methods for detecting similarity between structured query statements require database execution, leading to high detection costs.
Innovation Solution
A method and apparatus for detecting similarity between structured query statements by constructing abstract syntax trees and traversing nodes to determine matching results without the need for database execution.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Measurement precision
If structured query statements are executed with database to determine similarity, then measurement precision is improved, but loss of energy and loss of time increase due to high detection cost
Solution Approach 1:
The patent segments the structured query statement into an abstract syntax tree with hierarchical nodes, where each node represents a semantic component. This segmentation enables partial matching and comparison without executing the entire query against a database, reducing detection cost while maintaining precision through structured semantic analysis.
Solution Approach 2:
The patent introduces an abstract syntax tree as an intermediary representation between the structured query statement and the database. This intermediary allows similarity detection to be performed on the syntactic structure alone, eliminating the need for actual database execution while preserving semantic meaning for accurate comparison.
2Measurement precision
If structured query statements are executed with database to determine similarity, then measurement precision is improved, but productivity decreases due to high detection cost
Solution Approach 1:
The patent segments the structured query statement into an abstract syntax tree with hierarchical nodes, where each node represents a semantic component. This segmentation enables partial matching and comparison without executing the entire query against a database, reducing detection cost while maintaining precision through structured semantic analysis.
Solution Approach 2:
The patent introduces an abstract syntax tree as an intermediary representation between the structured query statement and the database. This intermediary allows similarity detection to be performed on the syntactic structure alone, eliminating the need for actual database execution while preserving semantic meaning for accurate comparison.
Data Source
AI summary
A structured query statement similarity detection method, a device and a medium are provided. The method includes: acquiring first and second structured query statements, and constructing corresponding first and second abstract syntax trees, a correlation degree between the root node in the abstract syntax tree and the query result of the statement being higher than a correlation degree between other nodes and the query result of the statement; traversing a node in the first abstract syntax tree, matching the traversed node with a node at a same level in the second abstract syntax tree, and obtaining a matching result of the node; and determining a statement similarity between the first structured query statement and the second structured query statement based on a matching result of a root node in the first abstract syntax tree, a matching result of a child node of the root node, and their corresponding weights.


