Query semantic representation method and system based on tree structure
By using a tree-structure-based query semantic representation method, DSL, VSL, and NLQ are converted into a tree representation model to generate SQL queries. This solves the problems of high communication costs and poor reusability of query logic in traditional data analysis, and improves the compatibility and execution efficiency of the data analysis system.
Patent Information
- Application Number
- CN202510987315.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-17
- Publication Date
- 2025-10-31
AI Technical Summary
Traditional data analysis suffers from high communication costs between business and technical personnel, difficulty in accurately expressing complex query requirements, poor reusability of query logic, and untraceable query process.
A tree-based query semantic representation method is adopted. Through multiple input methods such as DSL, VSL and NLQ, the query semantic representation is parsed and converted into a tree representation model, generating SQL query language and executing it.
It improves the compatibility, scalability, and execution efficiency of the data analysis system, and enables intelligent optimization of multimodal queries.
Smart Images

Figure CN120873003A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of data analysis technology, and more specifically, to a query semantic representation method and system based on a tree structure. Background Technology
[0002] One of the core requirements in the field of data analysis is "data retrieval." Efficient data retrieval capabilities directly determine the agility and accuracy of business decisions. In data analysis, "data retrieval" is the most basic and frequent operation. Traditional data retrieval methods suffer from the following pain points:
[0003] First, communication costs between business and technical personnel are high; second, complex query requirements are difficult to express accurately; third, query logic has poor reusability; and fourth, the query process is not traceable. Therefore, there is an urgent need to propose a query semantic representation method and system based on a tree structure to solve these problems. Summary of the Invention
[0004] To address the problems existing in the prior art, the present invention aims to provide a query semantic representation method and system based on a tree structure, which performs efficient query optimization based on the tree structure, and significantly improves the compatibility, scalability and execution efficiency of the data analysis system.
[0005] To achieve the above objectives, the present invention adopts the following technical solution;
[0006] A query semantic representation method based on a tree structure includes;
[0007] S1. Data retrieval scenario input: The user queries the data to be retrieved. The query method is as follows:
[0008] Queries are performed using simple expressions input via a domain-specific analysis language (DSL).
[0009] Input queries using the Visual Query Language (VSL), such as by dragging and dropping, configure reports, and retrieve data based on the reports;
[0010] Queries can be performed using natural language (NL) input, such as NL queries using Chinese, i.e., NLQ.
[0011] S2. The query input in S1 is transformed into one or more tree representation models through a parsing and transformation process. The single tree representation model includes query nodes, column nodes, filter group nodes, sorting nodes and other calculation nodes.
[0012] S3. Generate the engine layer query language SQL based on one or more tree representation models;
[0013] S4. Execute the query language at the engine layer and return the results.
[0014] As a further description of the above technical solution:
[0015] The parsing and conversion process in step S2 varies depending on the input query method. Specifically, inputs in Domain Specific Language (DSL) are converted through syntax parsing; inputs in Visual Query Language (VSL) are converted through logical semantic parsing; and inputs in Natural Language (NL) are converted through semantic parsing.
[0016] The parsed tree structure preserves the complete semantics of the query, including the query target, filtering conditions, aggregation calculations, sorting, and multi-query relationships.
[0017] As a further description of the above technical solution:
[0018] The query node represents a complete query unit, which includes attributes such as: whether to return detailed data, which determines whether to use GROUP BY; whether to only parse without execution; and whether to involve intersection, union, and difference operations.
[0019] As a further description of the above technical solution:
[0020] The column nodes include ordinary column nodes and computed column nodes. Ordinary column nodes are used to describe the columns involved in the query, including attributes such as column name, aggregate function and time granularity. Computed column nodes are arithmetic computed column nodes.
[0021] As a further description of the above technical solution:
[0022] The filter group nodes have connection relationship attributes, support logical relationships AND / OR, and the filter types are divided into ordinary filter and table filter. Ordinary filter includes LEFT, OP and RIGHT; in table filter, the query node can be used as the filter item of the filter group node.
[0023] As a further description of the above technical solution:
[0024] The sorting node, as a child node of the query node, is used to mark the sorting information representation for the current query, including the sequence to be sorted and the sorting attribute.
[0025] As a further description of the above technical solution:
[0026] The other computing nodes include iterative calculations and algorithm calls.
[0027] As a further description of the above technical solution:
[0028] The multi-tree representation model is used to describe multi-round distributed analysis scenarios, and the multi-round analysis context is related; the tree representation models are context-related, and the relationship is either a sequential progressive relationship or a parallel relationship.
[0029] This invention also employs:
[0030] A query semantic representation system based on a tree structure includes:
[0031] The input module includes a DSL editor, a visual builder, and an NLQ chat box for inputting queries;
[0032] The parsing and transformation module is used to process the query input through a parsing and transformation process, converting it into one or more tree representation models;
[0033] An SQL generator that generates the engine-level query language SQL based on one or more tree representation models;
[0034] An execution engine that receives the query language SQL from the SQL generator and executes it to return the results.
[0035] Compared with the prior art, the advantages of this invention are:
[0036] This solution optimizes queries efficiently based on a tree structure, ultimately generating a high-performance target query language. This design significantly improves the compatibility, scalability, and execution efficiency of data analysis systems. At the same time, it provides a unified semantic layer for natural language interaction, visualization construction, and code-based queries, making it an ideal solution for modern data platforms to achieve multimodal queries and intelligent optimization. Attached Figure Description
[0037] Figure 1 This is a flowchart illustrating the semantic representation method for querying according to the present invention;
[0038] Figure 2 This is a flowchart illustrating the semantic query process of the present invention;
[0039] Figure 3 This is a schematic diagram illustrating the principle of the query semantic representation system of the present invention. Detailed Implementation
[0040] The technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention;
[0041] Please see Figure 1-3 The present invention provides Embodiment 1:
[0042] A query semantic representation method based on a tree structure includes;
[0043] S1. Data retrieval scenario input: The user queries the data to be retrieved. Query methods include, but are not limited to:
[0044] Queries are performed using simple expressions input via a domain-specific analysis language (DSL).
[0045] Enter your query using the Visual Query Language (VSL);
[0046] Query via natural language input (NL);
[0047] S2. The query input in S1 is transformed into one or more tree representation models through a parsing and transformation process. The single tree representation model includes query nodes, column nodes, filter group nodes, sorting nodes and other calculation nodes.
[0048] S3. Generate the engine layer query language SQL based on one or more tree representation models;
[0049] S4. Execute the query language at the engine layer and return the results;
[0050] It provides a standardized and scalable query semantic representation method that supports both traditional SQL-like queries and more complex analysis needs, making it an ideal intermediate representation for multimodal data analysis systems.
[0051] In step S2, the parsing and conversion process varies depending on the input query method. Specifically, inputs in Domain Specific Language (DSL) are converted through syntax parsing; inputs in Visual Query Language (VSL) are converted through logical semantic parsing; and inputs in Natural Language (NL) are converted through semantic parsing.
[0052] The parsed tree structure preserves the complete semantics of the query, including the query target, filtering conditions, aggregation calculations, sorting, and multi-query relationships. Voice input can also be used, and the input is converted into text and then converted through semantic parsing.
[0053] The query node represents a complete query unit, which includes attributes such as: whether to return detailed data, which determines whether to use GROUP BY; whether to only parse without execution; whether to involve intersection, union, and difference operations; and whether the subquery relationship of the query node supports set operations such as UNION, INTERSECT, and EXCEPT.
[0054] The column nodes include ordinary column nodes and calculated column nodes. Ordinary column nodes are used to describe the columns involved in the query, including attributes: column name, aggregation function, and time granularity. The presence or absence of an aggregation function determines whether the current column is a dimension or a measure. Calculated column nodes are arithmetic calculated column nodes, which form a tree structure. Because arithmetic operations are inherently arithmetic operation tree structure, the operation item nodes can be query nodes or values, such as the percentage of transaction amount in each city.
[0055] The filter group nodes have connection relationship attributes, support logical relationships AND / OR, and the filter types are divided into ordinary filter and table filter. Ordinary filter includes LEFT, OP and RIGHT; in table filter, the query node can be used as the filter item of the filter group node.
[0056] The term RIGHT includes, but is not limited to:
[0057] It can be value information, such as strings, times, numbers, etc.
[0058] It could also be a list of information, such as students whose Chinese scores are higher than their math scores;
[0059] It could also be a query node, such as a student whose Chinese language score is higher than Xiaoming's.
[0060] The sorting node, as a child node of the query node, is used to mark the sorting information representation for the current query, including the sequence to be sorted and the sorting attribute.
[0061] Describe the ORDER BY logic:
[0062] Sort or calculate columns;
[0063] Forward sorting or reverse sorting.
[0064] The other computing nodes include iterative calculations and algorithm calls.
[0065] The multi-tree representation model is used to describe multi-round distributed analysis scenarios, and the multi-round analysis context is related; the tree representation models are context-related, and the relationship is either a sequential progressive relationship or a parallel relationship;
[0066] Some complex queries require the collaboration of multiple tree models. When there are multiple tree representation models, a set of contexts is designed to maintain the relationship between the multiple tree representation models.
[0067] Please see Figure 1 and Figure 2 Based on Example 1, the present invention also provides Example 2:
[0068] A query semantic representation system based on a tree structure includes:
[0069] The input module includes a DSL editor, a visual builder, and an NLQ chat box for inputting queries;
[0070] The parsing and transformation module is used to process the query input through a parsing and transformation process, converting it into one or more tree representation models;
[0071] An SQL generator that generates the engine-level query language SQL based on one or more tree representation models;
[0072] An execution engine that receives the query language SQL from the SQL generator and executes it to return the results.
[0073] This tree-structure design method unifies the parsing of various query inputs such as DSL, VSL, and NLQ, transforming them into a standardized tree representation model. This not only enables flexible expression of complex query semantics (supporting advanced functions such as intersection, union, difference operations, four arithmetic operations, and multi-round contextual analysis), but also allows for efficient query optimization based on the tree structure (such as predicate pushdown and constant folding). Ultimately, it generates a high-performance target query language (such as SQL). This design significantly improves the compatibility, scalability, and execution efficiency of data analysis systems, while providing a unified semantic layer for natural language interaction, visualization construction, and code-based queries. It is an ideal solution for modern data platforms to achieve multimodal querying and intelligent optimization.
[0074] The above description is merely a preferred embodiment of the present invention; however, the scope of protection of the present invention is not limited thereto. Any equivalent substitutions or modifications made by those skilled in the art within the scope of the technology disclosed in the present invention, based on the technical solution and its improved concepts, should be covered within the scope of protection of the present invention.
Claims
1. A query semantic representation method based on a tree structure, characterized in that, include; S1. Data retrieval scenario input: The user queries the data to be retrieved. The query method is as follows: Queries are performed using simple expressions input via a domain-specific analysis language (DSL). Enter your query using the Visual Query Language (VSL); Query via natural language input (NL); S2. The query input in S1 is transformed into one or more tree representation models through a parsing and transformation process. The single tree representation model includes query nodes, column nodes, filter group nodes, sorting nodes and other calculation nodes. S3. Generate the engine layer query language SQL based on one or more tree representation models; S4. Execute the query language at the engine layer and return the results.
2. The query semantic representation method based on tree structure according to claim 1, characterized in that: The parsing and conversion process in step S2 varies depending on the input query method. Specifically, inputs in Domain Specific Language (DSL) are converted through syntax parsing; inputs in Visual Query Language (VSL) are converted through logical semantic parsing; and inputs in Natural Language (NL) are converted through semantic parsing. The parsed tree structure preserves the complete semantics of the query, including the query target, filtering conditions, aggregation calculations, sorting, and multi-query relationships.
3. The query semantic representation method based on tree structure according to claim 1, characterized in that: The query node represents a complete query unit, which includes attributes: whether to return detailed data, which determines whether to use GROUP BY; and whether to only parse without executing. Does it involve intersection, union, or difference operations? 4. The query semantic representation method based on a tree structure according to claim 1, characterized in that: The column nodes include ordinary column nodes and computed column nodes. The ordinary column nodes are used to describe the columns involved in the query, including attributes such as column name, aggregate function, and time granularity. The computed column node is a four-calculation computed column node.
5. The query semantic representation method based on a tree structure according to claim 1, characterized in that: The filter group node has a connection relationship attribute, supports logical relationships AND / OR, and the filter types are divided into ordinary filter and table filter, among which ordinary filter includes LEFT, OP and RIGHT; In table filtering, query nodes can be used as filter items for filter group nodes.
6. The query semantic representation method based on tree structure according to claim 1, characterized in that: The sorting node, as a child node of the query node, is used to mark the sorting information representation for the current query, including the sequence to be sorted and the sorting attribute.
7. The query semantic representation method based on tree structure according to claim 1, characterized in that: The other computing nodes include iterative calculations and algorithm calls.
8. The query semantic representation method based on tree structure according to claim 1, characterized in that: The multi-tree representation model is used to describe multi-round distributed analysis scenarios, and the multi-round analysis context is relevant; The tree representation models are context-dependent, and the correlation is either a sequential or parallel relationship.
9. A query semantic representation system based on a tree structure, characterized in that, include: The input module includes a DSL editor, a visual builder, and an NLQ chat box for inputting queries; The parsing and transformation module is used to process the query input through a parsing and transformation process, converting it into one or more tree representation models; An SQL generator that generates the engine-level query language SQL based on one or more tree representation models; An execution engine that receives the query language SQL from the SQL generator and executes it to return the results.