Intelligent data query method and system fusing metadata evidence and hierarchical verification

CN122903672APending Publication Date: 2026-10-13JIANGSU FENGYUN TECH SERVICE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611038393.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-07-13
Publication Date
2026-10-13

AI Technical Summary

Technical Problem

[0007]本发明提供的一种融合元数据证据与分层验证的智能数据查询方法,本发明的方案通过根据自然语言查询请求、融合元数据项集合、元数据证据包、查询中间表达和分层验证报告之间的关联处理,解决现有自然语言数据查询方法中查询语义约束不足、权限控制滞后、查询结果缺乏证据支撑的问题

Benefits of technology

本发明通过查询边界判断和问题拆分,将自然语言查询请求转化为查询意图数据和子查询计划,减少复杂查询问题直接生成查询表达式造成的语义偏差;通过融合元数据项集合的多维度证据筛选和访问控制过滤,生成与查询意图、用户上下文和元数据来源相匹配的元数据证据包,减少无关元数据、过期样例和无权字段对查询生成过程的干扰;进一步地,通过查询中间表达、前置分层验证报告、证据链解释数据和反馈数据之间的闭环处理,在查询执行前校验查询语义、业务口径、权限安全和表达式合法性,并在查询执行后沉淀历史样例、业务规则和元数据质量分,提高自然语言数据查询在复杂业务环境中的准确性、安全性、可解释性和持续优化能力。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122903672A_ABST
    Figure CN122903672A_ABST
Patent Text Reader

Abstract

The application provides a kind of intelligent data query method and system of fusing metadata evidence and hierarchical verification, method includes: obtaining natural language query request, current user context and fusion metadata item set;Query boundary judgment and question splitting are executed, and query intent data and subquery plan are generated;Metadata evidence package is generated by carrying out evidence screening and access control filtering to fusion metadata item set;Query intermediate expression is generated based on metadata evidence package and converted into to-be-verified query expression;Preposition hierarchical verification is executed, and query result and evidence chain interpretation data are generated after verification passes, and historical example, business rule and metadata quality division are updated based on feedback data.The application can improve the accuracy, security and explainability of natural language data query.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of artificial intelligence technology, specifically relating to an intelligent data query method and system that integrates metadata evidence and hierarchical verification. Background Technology

[0002] With the continuous development of enterprise digital transformation, data platform construction, and intelligent office applications, a large amount of structured or semi-structured business data has accumulated in scenarios such as enterprises, governments, education, healthcare, finance, and operational analysis. This data is typically distributed across relational databases, data warehouses, data lakes, reporting platforms, business system interfaces, and file-based data sources. Business personnel frequently need to perform ad-hoc queries and analyses related to sales statistics, personnel management, financial analysis, teaching management, and operational monitoring in their daily work. However, most business personnel are not familiar with database table structures, field meanings, query syntax, and underlying data models, and still rely on report developers, data analysts, or pre-set reports to retrieve data. This results in query response efficiency and flexibility that cannot meet actual business needs.

[0003] To lower the barrier to data querying, existing technologies include keyword queries, pre-defined report queries, rule-based natural language queries, natural language to SQL conversion, large-scale model query analysis, semantic layer BI, and database question-answering solutions that combine retrieval enhancement. These solutions can, to a certain extent, convert user-input natural language questions into executable query statements, or return query results based on pre-configured metrics, fields, and topic datasets, thereby improving the ease of data access for non-technical users.

[0004] However, in real-world business environments, natural language queries from users often involve abbreviated expressions, business aliases, implicit timeframes, ambiguous statistical definitions, cross-table joins, and access control boundaries. For example, the same business term may correspond to different data tables, fields, or filtering rules in different departments or statistical scenarios; a user may have partial data access permissions, but may not necessarily be allowed to view sensitive details or export data at specific granularities. Existing solutions are prone to problems such as incorrect field selection, incorrect table join paths, inconsistent statistical definitions, missing query conditions, lagging access control, uncontrollable execution costs, and a lack of interpretable data when handling complex business queries.

[0005] Furthermore, some natural language query systems primarily focus on whether the final query statement can be generated and executed, lacking continuous constraints on aspects such as whether the query question falls within the scope of processable data, whether business rules are fully covered, whether user permissions meet the current query purpose, whether the query results are reasonable, and whether the interpretation of the results is traceable. When historical examples, field descriptions, or business rules change, the system may continue to reference outdated information or erroneous examples, leading to deviations in subsequent similar queries and failing to meet the requirements of enterprise-level data queries for accuracy, security, interpretability, and continuous optimization capabilities.

[0006] Therefore, there is an urgent need for an intelligent data query method that integrates metadata evidence and hierarchical verification to improve the accuracy, security, and interpretability of natural language data queries. Summary of the Invention

[0007] This invention provides an intelligent data query method that integrates metadata evidence and hierarchical verification. The solution of this invention solves the problems of insufficient semantic constraints, lagging access control, and lack of evidence support for query results in existing natural language data query methods by processing the correlation between natural language query requests, integrated metadata item sets, metadata evidence packages, query intermediate expressions, and hierarchical verification reports.

[0008] In a first aspect, the present invention provides an intelligent data query method that integrates metadata evidence and hierarchical verification, the method comprising: Retrieve the natural language query request, the current user context, and the fused metadata item set; The natural language query request is subjected to query boundary judgment and question decomposition to generate query intent data and subquery plan; Based on the query intent data, the sub-query plan, and the current user context, multi-dimensional evidence screening and access control filtering are performed on the fused metadata item set to generate a metadata evidence package. Based on the metadata evidence package, a query intermediate expression is generated. The query intermediate expression is used to characterize the query semantics, execution constraints, and evidence association relationships corresponding to the natural language query request. The intermediate query expression is converted into a query expression to be verified. Pre-layered verification is performed on the query intent data, the metadata evidence package, the intermediate query expression, and the query expression to be verified, and a pre-layered verification report is generated. When the pre-layered verification report meets the preset pass conditions, the query expression to be verified is executed to generate an initial query result. Based on the initial query result, query results and evidence chain explanation data are generated. Historical samples, business rules, and metadata quality scores are updated according to the feedback data collected for the query results and the evidence chain explanation data.

[0009] By adopting the above scheme, the present invention provides an intelligent data query method that integrates metadata evidence and hierarchical verification. This method achieves a structured transformation of user query questions into query intent data and subquery plans by judging query boundaries and decomposing questions in natural language query requests. It also achieves evidentiary constraints and pre-emptive permission control by performing multi-dimensional evidence screening and access control filtering on the integrated metadata item set in conjunction with the current user context. Furthermore, it generates intermediate query expressions through metadata evidence packages and performs pre-emptive hierarchical verification on query intent data, metadata evidence packages, intermediate query expressions, and query expressions to be verified, achieving verification control of query semantics, execution constraints, and evidence associations before query execution. Finally, it updates historical examples, business rules, and metadata quality scores through query results, evidence chain explanation data, and feedback data, continuously optimizing the natural language data query process and improving the accuracy, security, and interpretability of intelligent data queries.

[0010] In one optional implementation, the fused metadata item set includes multiple metadata items, each metadata item including metadata identifier, metadata type, metadata name, business name, source system, data source information, association path, business rule identifier, permission policy identifier, sensitivity level, version information, validity period, quality score, and source reference; wherein, the metadata type includes table, field, indicator, business terminology, business rule, historical example, permission policy, data lineage, field value dictionary, and data quality status.

[0011] In one optional implementation, the step of performing query boundary judgment and question decomposition on the natural language query request to generate query intent data and subquery plans includes: standardizing the natural language query request to generate standardized query text; performing business domain identification, query type identification, query object identification, indicator identification, dimension identification, time range identification, and risk level identification based on the standardized query text and the fused metadata item set to generate the query intent data; determining whether the natural language query request has missing query conditions, out-of-bounds query scope, sensitive detailed query, or multi-target query based on the query intent data; and generating the subquery plan based on the dependency relationship, execution order, and merging rules between the multiple query targets when the natural language query request has multiple targets.

[0012] In one optional implementation, the step of performing multi-dimensional evidence screening and access control filtering on the fused metadata item set based on the query intent data, the subquery plan, and the current user context to generate a metadata evidence package includes: determining candidate data sources, candidate tables, candidate fields, candidate metrics, candidate business rules, and candidate historical examples from the fused metadata item set based on the query intent data and the subquery plan; performing access control filtering on the candidate data sources, candidate tables, candidate fields, candidate metrics, candidate business rules, and candidate historical examples based on the current user context to generate an allowed metadata set and an excluded metadata set; and generating the metadata evidence package based on the allowed metadata set, the excluded metadata set, the corresponding metadata version information, and source references.

[0013] In one optional implementation, generating an intermediate query expression based on the metadata evidence package includes: extracting from the metadata evidence package the query object, candidate metrics, candidate dimensions, candidate filtering conditions, candidate time ranges, candidate association paths, permission constraints, and business rule references corresponding to the natural language query request; generating the intermediate query expression based on the query object, the candidate metrics, the candidate dimensions, the candidate filtering conditions, the candidate time ranges, the candidate association paths, the permission constraints, and the business rule references; and writing the evidence reference relationships corresponding to the metadata evidence package into the intermediate query expression.

[0014] In one optional implementation, the step of converting the intermediate query expression into a query expression to be verified, and performing pre-level layered verification on the query intent data, the metadata evidence package, the intermediate query expression, and the query expression to be verified, to generate a pre-level layered verification report, includes: converting the intermediate query expression into a query expression to be verified corresponding to the target query engine; performing query boundary verification on the query intent data to generate boundary verification results; performing metadata coverage verification on the query objects, metrics, dimensions, and filtering conditions in the intermediate query expression to generate metadata coverage verification results; performing business semantic verification on the business rule references, time calibers, and organizational calibers in the intermediate query expression to generate business semantic verification results; performing permission security verification on the field references, output granularity, and access scope in the intermediate query expression and the query expression to be verified to generate permission security verification results; performing syntax, table field existence, association path, and aggregation granularity verification on the query expression to be verified to generate expression validity verification results; and generating the pre-level layered verification report based on the boundary verification results, the metadata coverage verification results, the business semantic verification results, the permission security verification results, and the expression validity verification results.

[0015] In one optional implementation, before generating the pre-layered verification report, the method further includes: performing security rewriting on the time condition, default state condition, organizational scope condition, sorting condition, pagination condition, result row count limit condition, and sensitive field processing condition in the query expression to be verified, generating a rewritten query expression; re-executing permission security verification and expression validity verification on the rewritten query expression; using the re-verified rewritten query expression as the target query expression, and using the target query expression as the query expression used for subsequent query execution.

[0016] In one optional implementation, generating query results and evidence chain explanation data based on the initial query results includes: generating a result rationality verification result based on the initial query results and the consistency checks of the number of rows in the query execution log, empty result status, abnormal values, execution resource consumption, and permission constraints; when the result rationality verification result meets preset result conditions, performing summarization, desensitization, pagination, or charting processing on the initial query results to generate the query results; and generating the evidence chain explanation data, which includes query scope, filtering conditions, time range, permission restrictions, exclusion data descriptions, and metadata sources, based on the intermediate query expression, the metadata evidence package, and the pre-layered verification report.

[0017] In one optional implementation, updating the historical examples, business rules, and metadata quality scores based on feedback data collected for the query results and the evidence chain interpretation data includes: collecting at least one of user confirmation data, user error correction data, manual review data, execution failure reason data, empty result reason data, and result anomaly reason data to generate the feedback data; determining successful examples, reference examples, pending review examples, disabled examples, and rule correction suggestions based on the feedback data; and updating the historical examples, business rules, and metadata quality scores based on the successful examples, reference examples, pending review examples, disabled examples, and rule correction suggestions.

[0018] Compared with the prior art, the beneficial effects of the present invention are as follows: This invention transforms natural language query requests into query intent data and subquery plans by judging query boundaries and decomposing questions, reducing semantic bias caused by directly generating query expressions for complex query problems. Through multi-dimensional evidence screening and access control filtering of integrated metadata item sets, it generates metadata evidence packages that match query intent, user context, and metadata sources, reducing interference from irrelevant metadata, expired samples, and unauthorized fields in the query generation process. Furthermore, through closed-loop processing between intermediate query expressions, pre-layered verification reports, evidence chain explanation data, and feedback data, it verifies query semantics, business definitions, permission security, and expression legality before query execution, and accumulates historical samples, business rules, and metadata quality scores after query execution, improving the accuracy, security, interpretability, and continuous optimization capabilities of natural language data queries in complex business environments.

[0019] Secondly, the present invention provides an intelligent data query system that integrates metadata evidence and hierarchical verification, comprising: The data acquisition module is used to acquire natural language query requests, the current user context, and a set of fused metadata items; The intent plan generation module is used to perform query boundary judgment and question decomposition on the natural language query request, and generate query intent data and subquery plans; The evidence package generation module is used to perform multi-dimensional evidence filtering and access control filtering on the fused metadata item set based on the query intent data, the sub-query plan and the current user context, and generate a metadata evidence package. The intermediate expression generation module is used to generate a query intermediate expression based on the metadata evidence package. The query intermediate expression is used to characterize the query semantics, execution constraints, and evidence association relationships corresponding to the natural language query request. The verification report generation module is used to convert the intermediate query expression into a query expression to be verified, and to perform pre-layered verification on the query intent data, the metadata evidence package, the intermediate query expression, and the query expression to be verified, and generate a pre-layered verification report. The query feedback processing module is used to execute the query expression to be verified when the pre-layered verification report meets the preset pass conditions, generate an initial query result, generate query results and evidence chain explanation data based on the initial query result, and update historical samples, business rules and metadata quality scores according to the feedback data collected for the query results and the evidence chain explanation data.

[0020] A third aspect of the present invention provides an intelligent data query device that integrates metadata evidence and hierarchical verification. The device includes a computer device, which includes a processor and a memory. The memory stores computer instructions. When the computer instructions are executed, the device implements the intelligent data query method that integrates metadata evidence and hierarchical verification.

[0021] Additional advantages, objects, and features of the invention will be set forth in part in the description which follows, and will also become apparent in part to those skilled in the art upon studying the text, or may be learned by practice of the invention. The objects and other advantages of the invention will become apparent from the description and the accompanying drawings.

[0022] Those skilled in the art will understand that the objectives and advantages achievable with the present invention are not limited to those specifically described above, and that the above and other objectives achievable with the present invention will become clearer from the following detailed description. Attached Figure Description

[0023] The accompanying drawings, which form part of this application, are used to provide a further understanding of the invention. The illustrative embodiments of the invention and their descriptions are used to explain the invention and do not constitute an improper limitation of the invention.

[0024] In the attached diagram: Figure 1 This is a flowchart illustrating an intelligent data query method that integrates metadata evidence and hierarchical verification, as provided in an embodiment of the present invention.

[0025] Figure 2 This is a schematic diagram of an intelligent data query system that integrates metadata evidence and hierarchical verification, provided as an embodiment of the present invention.

[0026] Figure 3 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention. Detailed Implementation

[0027] The present invention will now be described in detail with reference to the accompanying drawings and embodiments. It should be noted that, unless otherwise specified, the embodiments and features described in this application can be combined with each other.

[0028] The following detailed description is exemplary and intended to provide further detailed explanation of the invention. Unless otherwise specified, all technical terms used in this invention have the same meaning as commonly understood by one of ordinary skill in the art to which this application pertains. The terminology used in this invention is for the purpose of describing particular embodiments only and is not intended to limit the scope of exemplary embodiments according to the invention.

[0029] Figure 1This is a flowchart illustrating an intelligent data query method that integrates metadata evidence and hierarchical verification, provided by an embodiment of the present invention.

[0030] Example 1, as Figure 1 As shown, the present invention provides an intelligent data query method that integrates metadata evidence and hierarchical verification. The method includes the following steps: S1. Obtain the natural language query request, the current user context, and the set of fused metadata items; S2. Perform query boundary judgment and question decomposition on the natural language query request to generate query intent data and subquery plan; S3. Based on the query intent data, the sub-query plan, and the current user context, perform multi-dimensional evidence screening and access control filtering on the fused metadata item set to generate a metadata evidence package; S4. Generate a query intermediate expression based on the metadata evidence package. The query intermediate expression is used to characterize the query semantics, execution constraints, and evidence association relationships corresponding to the natural language query request. S5. Convert the intermediate query expression into a query expression to be verified, perform pre-layered verification on the query intent data, the metadata evidence package, the intermediate query expression, and the query expression to be verified, and generate a pre-layered verification report. S6. When the pre-layered verification report meets the preset pass conditions, execute the query expression to be verified, generate an initial query result, generate query results and evidence chain explanation data based on the initial query result, and update the historical samples, business rules and metadata quality scores according to the feedback data collected for the query results and the evidence chain explanation data.

[0031] By employing the above scheme, the present invention provides an intelligent data query method that integrates metadata evidence and hierarchical verification. This method performs query boundary judgment and question decomposition on natural language query requests, achieving a structured transformation of user natural language questions into query intent data and subquery plans. By combining the current user context with multi-dimensional evidence screening and access control filtering of the integrated metadata item set, it achieves evidentiary constraints on query generation basis and pre-emptive access boundary control. By generating intermediate query expressions based on metadata evidence packages and performing pre-emptive hierarchical verification on query intent data, metadata evidence packages, intermediate query expressions, and query expressions to be verified, it achieves controlled verification of query semantics, business scope, access permissions, and expression legality before query execution. Furthermore, by updating historical examples, business rules, and metadata quality scores through query results, evidence chain explanation data, and feedback data, it achieves evidence traceability and continuous optimization during the natural language data query process, significantly improving the accuracy, security, and interpretability of intelligent data queries.

[0032] In step S1, the natural language query request can be natural language text input by the user, speech-recognized text, follow-up questions in multi-turn conversations, query descriptions on business pages, or data analysis requests triggered by external business systems. The natural language query request can include business objects, statistical indicators, analysis dimensions, time conditions, output formats, sorting requirements, filtering conditions, or other query-related semantics. For example, a natural language query request could be something like, "Please check the number of students and teachers in each grade this semester, and display them grouped by college," "Look at the main reasons for the decline in sales in East China last month," or "Statistics on the distribution of reasons for abnormal orders in the past three months."

[0033] The current user context is used to limit the user, organization, role, data domain, query purpose, and output granularity of a natural language query request. The current user context can include user ID, user role, organization, tenant, accessible data domain, field access permissions, query purpose, output granularity, session ID, request source, request time, and risk level. For example, in an educational data query scenario, the current user context could indicate that the current user is a statistics staff member in the academic affairs office, allowed to view summary statistics for students and teachers, but not allowed to view sensitive details such as student ID numbers, teacher contact information, individual grades, and salaries.

[0034] The integrated metadata item set describes the data basis for intelligent data query processes to invoke, filter, verify, and interpret. The integrated metadata item set includes multiple metadata items, each containing a metadata identifier, metadata type, metadata name, business name, source system, data source information, association path, business rule identifier, permission policy identifier, sensitivity level, version information, validity period, quality score, and source reference. Metadata types include tables, fields, metrics, business terms, business rules, historical examples, permission policies, data lineage, field value dictionaries, and data quality status. By unifying table structure, field structure, metric definitions, business terms, field value dictionaries, table relationships, data lineage, permission policies, historical examples, business rules, and data quality status into metadata items, subsequent query generation processes can be executed based on identifiable, filterable, verifiable, and traceable metadata basis.

[0035] For example, a metadata item (MetadataItem) can include at least the following: metadata_id, metadata_type, name, business_name, description, source_system, database_name, table_name, field_name, data_type, value_dictionary, relation_path, business_rule_id, lineage_id, permission_policy_id, sensitivity_level, version, valid_time, quality_score, and source_ref. The metadata_type can take values ​​such as table, field, metric, term, rule, sample, permission, lineage, value_dict, and quality. The metadata_id uniquely identifies the metadata item, the version identifies the metadata item's version, the sensitivity_level identifies the sensitivity level of the metadata item, the quality_score characterizes the quality status of the metadata item, and the source_ref points to evidence of the metadata's source.

[0036] In step S2, query boundary judgment and question splitting are performed on the natural language query request to generate query intent data and subquery plan.

[0037] Specifically, the natural language query requests are first standardized to generate standardized query text. Standardization can include removing invalid characters, standardizing time representations, normalizing business aliases, completing omitted semantics, identifying consecutive follow-up questions, converting synonyms, and recognizing output formats. For example, "this semester" can be normalized to the current semester code, "number of teachers" to "number of faculty members," and "look by college" to "grouped by college."

[0038] Based on standardized query text and a fusion of metadata item sets, business domain identification, query type identification, query object identification, metric identification, dimension identification, time range identification, and risk level identification are performed to generate query intent data. Query intent data (QueryIntent) can include at least: request_id, original_question, normalized_question, query_domain, query_type, business_objects, metrics, dimensions, time_range, filters, output_format, risk_level, need_clarification, and split_required. query_domain represents the business domain to which the request belongs; query_type represents statistical queries, detailed queries, trend analysis, cause analysis, or other query types; business_objects represents the query objects; metrics represents the metrics; dimensions represents the grouping dimensions; time_range represents the time range; filters represent the filtering conditions; risk_level represents the query risk level; need_clarification represents whether clarification is needed; and split_required represents whether splitting is needed.

[0039] Furthermore, based on the query intent data, it is determined whether the natural language query request contains missing query conditions, out-of-bounds query scope, sensitive detailed queries, or multi-target queries. Missing query conditions may include a lack of necessary time range, necessary organizational scope, statistical objects, or output granularity; out-of-bounds query scope may include a request that does not belong to the current data domain, a request involving a data source that the system does not support, or a request involving non-data query content; sensitive detailed queries may include ID numbers, contact information, salary, payment accounts, personal scores, contract attachments, or other detailed data that is not allowed to be directly output; multi-target queries may include multiple statistical objects, multiple indicators, multiple analysis dimensions, or multiple processing stages in the same natural language query request.

[0040] When a natural language query request involves multiple objectives, a subquery plan is generated based on the dependencies, execution order, and merging rules among these objectives. A subquery plan (SubQueryPlan) can include at least the following: sub_query_id, parent_request_id, query_goal, required_metrics, required_dimensions, required_filters, dependency_ids, execution_order, merge_rule, and required_permissions. query_goal represents the subquery objective, dependency_ids represents the dependencies between subqueries, execution_order represents the execution order, merge_rule represents the merging method between multiple subquery results, and required_permissions represents the permissions required to execute the subquery.

[0041] For example, when a user requests, "Please help me check the number of students and teachers in each grade this semester, grouped by college," we can determine that this request belongs to the education data domain. The query type is summary statistics, the business objects include students and teachers, the indicators include the number of students and teachers, the dimensions include college and grade, the time range is this semester, and the output format is a table. Since the number of students and the number of teachers correspond to different business definitions and different data tables, the natural language query request can be split into two subqueries: Subquery A counts the number of students this semester by college and grade; Subquery B counts the number of teachers this semester by college and grade. The merging rule is to merge the results of subqueries A and B using college and grade as the joint dimension.

[0042] When there is no multi-target query, the single query target corresponding to the natural language query request is encapsulated as a subquery plan.

[0043] In step S3, based on the query intent data and subquery plan, candidate data sources, candidate tables, candidate fields, candidate metrics, candidate business rules, and candidate historical examples are determined from the fused metadata item set. Multi-dimensional evidence filtering can include table-level filtering, field-level filtering, business rule filtering, historical example filtering, association path filtering, and data quality filtering. Table-level filtering is used to determine candidate data sources and candidate tables based on business domain, query object, and subquery objective; field-level filtering is used to determine candidate fields, candidate field values, and candidate association keys based on metrics, dimensions, filtering conditions, and field value dictionaries; business rule filtering is used to determine candidate business rules based on metric caliber, default state, time caliber, organizational caliber, and output granularity; historical example filtering is used to determine available historical examples based on similarity, business domain, metadata version, permission scope, execution success rate, and manual confirmation status; association path filtering is used to determine available association paths between multiple candidate tables; and data quality filtering is used to exclude low-quality or expired metadata based on quality score, validity period, and source credibility.

[0044] Based on the current user context, access control filtering is performed on candidate data sources, candidate tables, candidate fields, candidate metrics, candidate business rules, and candidate historical examples, generating allowed metadata sets and excluded metadata sets. Access control filtering can be based on user identity, user role, organizational scope, data domain, field sensitivity level, query purpose, and output granularity. Fields without permissions, sensitive fields, unauthorized examples, detailed granularities that are not allowed to be output, and business rules that do not match the current user context are not written into the allowed metadata set but rather into the excluded metadata set, with the reason for exclusion recorded. By performing access control filtering before metadata enters the subsequent query generation process, sensitive metadata, unauthorized fields, or erroneous examples that should not be used by the current query can be prevented from entering the query context.

[0045] A metadata evidence pack is generated based on the allowed metadata set, the excluded metadata set, the corresponding metadata version information, and the source reference. The metadata evidence pack (MetadataEvidencePack) can include at least the following: request_id, sub_query_id, candidate_tables, candidate_fields, candidate_metrics, candidate_rules, candidate_samples, excluded_metadata, permission_constraints, evidence_refs, metadata_versions, and pack_hash. `candidate_tables` records allowed candidate tables, `candidate_fields` records allowed candidate fields, `candidate_metrics` records allowed candidate metrics, `candidate_rules` records allowed business rules, `candidate_samples` records historical samples allowed to enter the reference range, `excluded_metadata` records excluded metadata and the reason for exclusion, `permission_constraints` records permission constraints, `evidence_refs` records evidence sources, `metadata_versions` records metadata versions, and `pack_hash` represents the integrity verification value of the metadata evidence package.

[0046] For example, in an education data query scenario, for a subquery counting student numbers, the system can identify the following tables from the integrated metadata item set: `student_info` (student base table), `grade_info` (grade table), `college_info` (college table), `term_calendar` (semester calendar table), and fields such as `student_id`, `student_status`, `grade_id`, `college_id`, and `term_code`. For a subquery counting teacher numbers, the system can identify the following tables: `teacher_info` (teacher base table), `course_schedule` (course schedule table), `grade_info` (grade table), `college_info` (college table), `term_calendar` (semester calendar table), and fields such as `teacher_id`, `course_id`, `grade_id`, `college_id`, `term_code`, and `schedule_status`. Based on the current user context, the system excludes sensitive fields such as `id_card`, `phone`, `salary`, `score`, and `home_address`, and also excludes historical samples involving detailed data exports. The resulting metadata evidence package only contains the tables, fields, metrics, rules, association paths, and permission constraints required for this summary statistics.

[0047] In step S4, the query object, candidate metrics, candidate dimensions, candidate filtering conditions, candidate time ranges, candidate association paths, permission constraints, and business rule references corresponding to the natural language query request are extracted from the metadata evidence package. The query object represents the business object to be queried; candidate metrics represent statistical or computational metrics; candidate dimensions represent grouping, display, or comparison dimensions; candidate filtering conditions represent filtering conditions such as status, organization, object, and range; candidate time ranges represent query time boundaries; candidate association paths represent the connection relationships between candidate tables; permission constraints limit accessible fields and output granularity; and business rule references limit statistical scope and default rules.

[0048] Based on the query object, candidate metrics, candidate dimensions, candidate filtering conditions, candidate time ranges, candidate association paths, permission constraints, and business rule references, an intermediate query representation (QueryIR) is generated. The intermediate query representation QueryIR can include at least: query_ir_id, query_target, selected_tables, selected_fields, join_paths, metrics, dimensions, filters, time_range, group_by, order_by, limit_policy, permission_constraints, rule_refs, evidence_refs, and output_schema. QueryIR is not a SQL statement in a specific database dialect, but rather a structured query plan situated between the natural language query request and the specific query expression. By generating QueryIR first, the query semantics, business scope, permission constraints, and evidence references can be validated before generating specific SQL, DSL, or interface parameters.

[0049] The evidence reference relationships corresponding to the metadata evidence package are written into the intermediate query expression. These evidence reference relationships can include metadata identifiers for the selected table, metadata identifiers for the fields, business rule identifiers for the metric definitions, permission policy identifiers for permission constraints, example identifiers for historical examples, and metadata version information. This allows for tracing the source of each query basis when subsequently generating and validating query expressions and generating evidence chain explanation data.

[0050] For example, for a query request to "display the number of students and instructors in each grade this semester, grouped by college", the intermediate expression of the query can include: query_target is to count the number of students and instructors in each grade of each college this semester; metrics include student_count=count(distinct student_id) and teacher_count=count(distinct teacher_id); dimensions include college_name and grade_level; time_range is when term_code equals the current semester code; filters include student_status indicating enrollment status and schedule_status indicating valid status; permission_constraints allows only summary-level output and prohibits detailed export; rule_refs includes rules for student enrollment statistics, rules for instructor statistics, and rules for conversion this semester; evidence_refs includes evidence from student table fields, evidence from course schedule table fields, evidence from college organizational standards, and evidence of the current user's summary query permissions.

[0051] In step S5, the intermediate query expression is converted into a query expression to be verified corresponding to the target query engine. The target query engine can be a relational database, data warehouse, data lake query engine, search engine, reporting platform interface, or business system interface.

[0052] The query expression to be validated can be a Structured Query Language (SQL) statement, a Domain Specific Language (DSL) expression, an Application Programming Interface (API) parameter, JavaScript Object Notation (JSON), a search expression, or a multi-source query plan.

[0053] During the conversion process, the appropriate expression template, syntax rules, and dialect rules are selected based on the target data source type, and the generation of update, delete, table deletion, table structure modification, or other dangerous write operation statements is prohibited. Specifically, this includes: 1) Perform query boundary validation on the query intent data and generate boundary validation results. Query boundary validation is used to confirm whether the natural language query request belongs to the data domain that the system can process, whether there are any missing necessary conditions, whether it involves prohibited query content, whether clarification is required, and whether it matches the current user context.

[0054] 2) Perform metadata coverage verification on the query objects, metrics, dimensions, and filter conditions in the intermediate query expression, and generate metadata coverage verification results. Metadata coverage verification is used to determine whether the tables, fields, metrics, field values, and association paths referenced by the intermediate query expression all come from the metadata evidence package, whether there is metadata referenced outside the evidence package, whether there is metadata referenced from outdated versions, and whether any necessary fields are missing.

[0055] 3) Perform business semantic validation on business rule references, time metrics, and organizational metrics in the intermediate query expressions, and generate business semantic validation results. Business semantic validation is used to determine whether the metric metrics are covered, whether the default state filtering is included, whether the time expression is correctly converted, and whether the organizational metrics are consistent with the business rules. For example, whether the number of students only counts enrolled students, whether the number of instructors only counts instructors with valid teaching schedules in the current semester, and whether the standard organizational metrics are used when counting by college.

[0056] 4) Perform permission security verification on field references, output granularity, and access scope in the intermediate query expression and the query expression to be verified, and generate permission security verification results. Permission security verification is used to determine whether the intermediate query expression and the query expression to be verified reference unauthorized fields, sensitive fields, or detailed granularities that are not allowed to be output, and whether there are queries that cross organizational scope, cross tenant scope, or exceed the current user's purpose.

[0057] 5) Perform syntax, table field existence, join path, and aggregation granularity validations on the query expression to be validated, generating expression validity validation results. Expression validity validation can include query syntax checking, table field existence checking, path checking, aggregate function checking, integrity checking, time condition checking, result row count limit checking, and dangerous function checking. Based on boundary validation results, metadata coverage validation results, business semantic validation results, permission security validation results, and expression validity validation results, generate a pre-layered validation report.

[0058] The pre-construction layered validation report, ValidationReport, can include at least the following: report_id, request_id, sub_query_id, level, target_object, check_item, status, failure_reason, repair_action, evidence_ref, and created_at. The level can include the issue boundary validation layer, metadata coverage validation layer, business semantic validation layer, permission security validation layer, and expression validity validation layer. The status indicates whether validation passed, failed, or requires repair; failure_reason records the reason for failure; repair_action records repair suggestions or actions; and evidence_ref is used to associate evidence from the metadata evidence package.

[0059] In some optional embodiments of the present invention, before generating the pre-layered verification report, the time conditions, default status conditions, organizational scope conditions, sorting conditions, pagination conditions, result row count limits, and sensitive field processing conditions in the query expression to be verified can be securely rewritten to generate a rewritten query expression. The secure rewriting can convert "this semester" to a specific semester code, "this month" to a specific start and end date, "normal status" to the corresponding status code, supplement the default organizational scope to the organizational scope accessible to the current user, rewrite detailed output to summary output or de-identified output, and add pagination limits to queries without pagination settings. The rewritten query expression is then re-verified for both permission security and expression validity. After successful re-verification, the rewritten query expression is used as the target query expression, and the target query expression is used when executing the query expression to be verified.

[0060] For example, in educational data query scenarios, "this semester" can be rewritten as the dynamically determined code for the current semester represented by `term_calendar`, "enrolled students" can be rewritten as a condition where `student_status` is either ACTIVE or ENROLLED, and "effective teaching schedules" can be rewritten as a condition where `schedule_status` is ACTIVE. The granularity of the query output can be limited to the college and grade level. If the query expression to be verified references the `id_card`, `phone`, `salary`, or `score` fields, the permission security verification will fail, and the system will delete the violating fields, regenerate the intermediate query expression, or return a permission restriction warning.

[0061] In step S6, the preset pass conditions may include passing boundary verification, passing metadata coverage verification, passing business semantic verification, passing permission security verification, and passing expression validity verification. When the current layered verification report meets the preset pass conditions, the query expression to be verified or the target query expression obtained after security rewriting is executed to generate initial query results. The initial query results may be data tables, statistical values, aggregation results, paginated details, raw chart data, or data returned by the interface.

[0062] Based on the initial query results and the consistency checks of the number of rows in the query execution log, empty result status, abnormal values, execution resource consumption, and permission constraints, a result validity verification result is generated. The result row count check determines whether the returned results exceed a preset limit; the empty result status check determines whether empty results are caused by no data, overly narrow conditions, permission restrictions, or query anomalies; the abnormal value check determines whether there are obvious anomalies in the statistical values; the execution resource consumption check determines whether the scanned table size, execution time, memory usage, complexity, or timeout risk exceed thresholds; and the permission constraint consistency check determines whether the execution result is consistent with the current user context and output granularity.

[0063] When the result validity verification meets the preset result conditions, the initial query results are summarized, anonymized, paginated, or charted to generate the final query results. For summary and statistical queries, indicator values, dimension groupings, sorting results, and chart data can be output; for detailed queries, anonymized fields and paginated results can be output according to permission restrictions; for abnormal query results, possible reasons and conditions requiring user clarification can be output.

[0064] Based on the intermediate query representation, metadata evidence package, and pre-layered verification report, evidence chain explanation data is generated, which includes query scope, filtering conditions, time range, access restrictions, explanations of excluded data, and metadata sources. This evidence chain explanation data explains to the user which statistical definitions, filtering conditions, time ranges, access restrictions, excluded data, and metadata or business rules were used as the basis for the query. This evidence chain explanation data is not generated from scratch by the model, but rather based on the intermediate query representation, metadata evidence package, verification report, and execution logs.

[0065] Further, at least one of the following is collected: user confirmation data, user error correction data, manual review data, execution failure reason data, empty result reason data, and result anomaly reason data, to generate feedback data. Based on the feedback data, successful examples, reference examples, pending review examples, disabled examples, and rule correction suggestions are determined. For query intermediate expressions, query expressions, and evidence chain explanations that are correct and confirmed by the user, they can be written into historical examples and marked as successful examples; for examples with high similarity but not completely consistent in business domain, permission scope, or metadata version, they can be marked as reference examples; for examples where the user points out errors in caliber or manual review is not yet complete, they can be marked as pending review examples; for examples caused by execution failure, unauthorized references, expired metadata, or incorrect caliber, they can be marked as disabled examples. Based on successful examples, reference examples, pending review examples, disabled examples, and rule correction suggestions, the quality scores of historical examples, business rules, and metadata are updated.

[0066] Specifically, after the query results and evidence chain explanation data are output, feedback data for this query process is collected. This feedback data may include at least one of the following: user confirmation data, user error correction data, manual review data, execution failure reason data, empty result reason data, and result anomaly reason data. User confirmation data indicates that the user confirms the query results, query scope, and explanation content are correct; user error correction data indicates that the user points out errors in indicator scope, time range, organizational scope, field selection, or table association path; manual review data indicates the data administrator's or business administrator's review conclusion on the quality of the query examples, business rules, or metadata; execution failure reason data indicates query expression syntax errors, missing table fields, unreachable association paths, execution timeouts, or permission verification failures; empty result reason data indicates overly narrow query conditions, no data within the target time range, permission limitations leading to no visible results, or data synchronization delays; and result anomaly reason data indicates sudden increases or decreases in statistical values, abnormal null value ratios, duplicate statistics, inconsistent units, or business rule conflicts.

[0067] Based on the feedback data, successful examples, reference examples, examples awaiting review, disabled examples, and rule correction suggestions are identified. If the user confirms the query result is correct, and the pre-layered verification report, result rationality verification result, and permission constraint consistency check all pass, then the query intent data, subquery plan, metadata evidence package, query intermediate expression, query expression, and evidence chain explanation data corresponding to this query are identified as successful examples. If a historical example has similar query targets or similar indicator dimensions to the current natural language query request, but the metadata version, business domain, permission scope, or output granularity is not completely consistent with the current request, then the historical example is identified as a reference example, used only to assist in generating the metadata evidence package, and its query expression is not directly reused. If user error correction data or manual review data indicates that the business caliber still needs confirmation, then the corresponding example is identified as an example awaiting review, and rule correction suggestions are generated. If the execution failure reason data, permission verification failure data, expired metadata identifier, or incorrect caliber identifier indicates that the example is not suitable for reuse, then the corresponding example is identified as a disabled example.

[0068] Furthermore, based on the successful examples, reference examples, pending examples, disabled examples, and rule correction suggestions, the historical examples, business rules, and metadata quality scores are updated. For successful examples, they are written into the historical example library, and the metadata quality scores corresponding to the tables, fields, metrics, business rules, and associated paths referenced by the successful examples are improved. For reference examples, their query intent, intermediate query expressions, and evidence chain explanation data are retained, but their direct reuse weight is reduced. For pending examples, they are set to pending review status and are prohibited from being used as direct reuse examples before manual review is passed. For disabled examples, they are marked as disabled and prohibited from entering subsequent model contexts. For rule correction suggestions, they are written into the business rule pending review area, and after review is passed, the corresponding metric caliber, default filtering rules, time caliber, or organizational caliber are updated, and the quality scores of related metadata items are adjusted synchronously.

[0069] In a specific application scenario, this embodiment takes the intelligent query scenario of educational data as an example to illustrate the intelligent data query method that integrates metadata evidence and hierarchical verification provided by the present invention.

[0070] The user inputs a natural language query request into the system: "Please help me find the number of students and teachers in each grade this semester, and display them by college." The current user is a statistics staff member of the Academic Affairs Office. The context of the current user indicates that the user can view the summary statistics of students and teachers, but cannot view sensitive details such as student ID numbers, teacher contact information, personal grades, salaries, home addresses, etc.

[0071] For example, available data sources include: student_info (student basics table), teacher_info (teacher basics table), course_schedule (course schedule table), grade_info (grade table), college_info (college table), and term_calendar (term calendar table).

[0072] Available metadata items include student count metrics, instructor metrics, college organizational hierarchy, grade field dictionary, current semester code, data status rules, field sensitivity levels, historical query examples, and permission policies.

[0073] First, the natural language query request is standardized, identifying the query objects as students and instructors, the metrics as the number of students and instructors, the dimensions as colleges and grades, the time range as the current semester, and the output format as a grouped table. Based on the fused metadata item set, business domain identification, query type identification, query object identification, metric identification, dimension identification, time range identification, and risk level identification are performed to generate query intent data. Since this query involves two statistical targets—the number of students and the number of instructors—and these correspond to different business rules and data sources, the system splits the natural language query request into two sub-query plans: Subquery A is used to count the number of students this semester by college and grade; Subquery B is used to count the number of instructors this semester by college and grade; the merging rule for the two subqueries is to merge them based on a joint dimension of college and grade.

[0074] Subsequently, based on the query intent data and subquery plan, candidate data sources, candidate tables, candidate fields, candidate metrics, candidate business rules, and candidate historical examples are determined from the fused metadata item set. Subquery A hits student_info, grade_info, college_info, and term_calendar, with candidate fields including student_id, student_status, grade_id, college_id, term_code, college_name, and grade_level; subquery B hits teacher_info, course_schedule, grade_info, college_info, and term_calendar, with candidate fields including teacher_id, course_id, grade_id, college_id, term_code, schedule_status, college_name, and grade_level. Business rule filtering hits rules for student count statistics, number of instructors statistics, current semester conversion rules, and college organizational standards. Among them, the student number statistics rule indicates that only students currently enrolled are counted by default, excluding those on leave of absence, those who have withdrawn, and those whose student status has been cancelled; the number of instructors statistics rule indicates that only instructors with valid teaching arrangements in the current semester are counted; the semester conversion rule indicates that the current semester code is dynamically determined based on term_calendar.

[0075] Access control filtering is performed on candidate metadata based on the current user context. The system confirms that the current user can only view summary statistics and cannot export student or teacher details. Therefore, sensitive fields such as ID number, mobile phone number, home address, salary, and grades are added to the excluded metadata set, and the reasons for exclusion are recorded. Fields required for student count statistics, fields required for teacher statistics, college and grade level fields, current semester conversion rules, summary statistics permission constraints, and historical examples are added to the allowed metadata set, generating a metadata evidence package. This metadata evidence package records the metadata identifier, version information, source citation, sensitivity level, and permission constraints for each piece of metadata.

[0076] The query intermediate expression is generated based on the metadata evidence package. In the query intermediate expression, `query_target` is the number of students and instructors in each college and grade this semester; `metrics` includes `student_count = count(distinct student_id)` and `teacher_count = count(distinct teacher_id)`; `dimensions` includes `college_name` and `grade_level`; `time_range` is `term_code` equal to the current semester code; `filters` includes `student_status` indicating enrollment status and `schedule_status` indicating valid status; `permission_constraints` allows only summary-level output and prohibits detailed export; `rule_refs` includes rules for student enrollment statistics, instructor statistics, and semester conversion rules; and `evidence_refs` includes evidence from the student base table fields, course schedule table fields, college organizational hierarchy, and user summary query permissions.

[0077] Furthermore, the intermediate query expression is converted into a query expression to be validated corresponding to the target query engine. This query expression can be an SQL statement, or a DSL expression or interface parameter that other query engines can recognize. Taking an SQL statement as an example, the query expression to be validated can include the following: SELECT c.college_name AS CollegeName, g.grade_level AS grade COUNT(DISTINCT s.student_id) AS number of students COUNT(DISTINCT cs.teacher_id) AS Number of instructors FROM grade_info g JOIN college_info c ON c.college_id = g.college_id LEFT JOIN student_info s ON s.grade_id = g.grade_id AND s.student_status IN ('ACTIVE','ENROLLED') AND s.term_code = '2024-2025-1' LEFT JOIN course_schedule cs ON cs.grade_id = g.grade_id AND cs.term_code = '2024-2025-1' AND cs.schedule_status = 'ACTIVE' GROUP BY c.college_name, g.grade_level ORDER BY c.college_name, g.grade_level; The '2024-2025-1' in the above SQL statement is just an example. In actual operation, the term_calendar will dynamically determine the current semester code according to the requested date.

[0078] Perform pre-validation layered verification on the query expression to be verified. Boundary verification confirms that the user issue belongs to the education data domain and does not involve issues that the system cannot handle; metadata coverage verification confirms that the tables, fields, metrics, and join paths in the SQL all come from the metadata evidence package; business semantic verification confirms that the rules for student number statistics, teacher number statistics, and semester conversion rules are all covered; permission security verification confirms that the SQL does not reference sensitive fields such as ID card numbers, mobile phone numbers, salaries, and grades, and the output granularity is the college and grade summary granularity; expression validity verification confirms that the SQL syntax, table field existence, JOIN path, aggregate functions, and GROUP BY settings all meet the requirements. Based on the above verification results, generate a pre-validation layered verification report.

[0079] When the current hierarchical verification report meets the preset pass conditions, the query expression to be verified is executed to generate initial query results. After execution, a consistency check is performed based on the initial query results and the number of rows, empty result status, abnormal values, execution resource consumption, and permission constraints in the query execution log. If the number of result rows is within the preset range, no abnormal values ​​occur, execution resource consumption does not exceed the threshold, and the query results meet the summary output permission, the initial query results are tabulated to generate the final query results.

[0080] Simultaneously, evidence chain explanation data is generated based on the query intermediate expression, metadata evidence package, and pre-construction layered verification report. This evidence chain explanation data can explain to users: "This statistic uses the current semester as the time frame; student numbers only include students currently enrolled, and teacher numbers only include those with valid teaching schedules for the current semester. Results are grouped by college and grade, and sensitive details such as student ID numbers, teacher mobile phone numbers, salaries, and grades are not retrieved. To view detailed lists, a separate detail permission verification is required." The statistical scope, filtering conditions, time frame, permission restrictions, and excluded data explanations in the above explanation all correspond to the metadata evidence package, query intermediate expression, and pre-construction layered verification report.

[0081] If the user confirms the query results are correct, the system writes the query intent data, subquery plan, metadata evidence package, intermediate query expression, query expression to be verified, pre-level layered verification report, and evidence chain explanation data into the historical sample. Based on the successful execution status and user confirmation data, the system increases the quality score of the relevant metadata items. If the user reports that "instructors should be counted according to the college to which the course belongs, not the college to which the teacher is assigned," the system writes this user's correction data as a rule correction suggestion into the business rule review area and marks the current historical sample as a review sample. After approval, the system updates the instructor statistics business rule and the quality score of the relevant metadata. If a historical sample is deemed unusable due to metadata version changes, inconsistent permission scope, or execution failure, it is marked as a disabled sample to prevent it from entering the subsequent query generation process.

[0082] Furthermore, this embodiment can also be applied to sales and operational data query scenarios. When a user inputs "to see the main reasons for the decline in sales in East China last month," the system can first identify that the request involves sales trend analysis, regional dimension analysis, product category contribution analysis, and refund or order cancellation impact analysis, and break it down into multiple sub-query plans; then, it generates a metadata evidence package based on the sales indicator caliber, regional permissions, order status rules, and refund rules; subsequently, it generates an intermediate query expression and a query expression to be verified, and controls the business caliber, permission scope, and expression legality through pre-layered verification; after executing the query, the system outputs changes in sales, main influencing factors, caliber explanations, and traceable evidence. If the user does not have permission to view customer details, neither the evidence package nor the query expression contains sensitive fields such as customer name, mobile phone number, and contract details, and the query results only output a summary contribution and explanation of the reasons.

[0083] Compared with the prior art, the beneficial effects of the present invention are as follows: Firstly, this invention acquires natural language query requests, the current user context, and a set of fused metadata items, and performs query boundary judgment and question decomposition on the natural language query requests to generate query intent data and subquery plans. This allows the natural language questions input by the user to be converted into structured data with business domains, query objects, indicators, dimensions, time ranges, risk levels, and subquery dependencies before entering the query generation process. By identifying and decomposing missing query conditions, out-of-bounds query scopes, sensitive detailed queries, and multi-objective queries, this invention avoids the direct conversion of complex questions into query expressions, which could lead to statistical object confusion, missing query conditions, and deviations in business definitions. This improves the accuracy of natural language query request parsing and the processability of complex query tasks.

[0084] Secondly, this invention performs multi-dimensional evidence screening and access control filtering on the fused metadata item set based on query intent data, subquery plans, and the current user context to generate a metadata evidence package. This ensures that tables, fields, metrics, business rules, historical examples, and related paths entering the query generation process are all subject to restrictions based on metadata version, source reference, sensitivity level, quality score, and permission constraints. By writing unauthorized fields, sensitive fields, unauthorized examples, and mismatched business rules into the excluded metadata set, this invention prevents unauthorized metadata from entering the query context, reducing the risks of misselected fields, incorrect table associations, expired example contamination, and unauthorized queries, thereby improving the security of the intelligent data query process and the reliability of the generation basis.

[0085] Thirdly, this invention generates intermediate query expressions based on metadata evidence packages, and then performs pre-verification layered verification after converting these intermediate expressions into query expressions to be verified. This ensures that query semantics, execution constraints, evidence associations, business rule references, permission security, and expression legality are verified before query execution. After successful verification, the query expression is executed to generate query results and evidence chain explanation data. Historical examples, business rules, and metadata quality scores are updated based on feedback data, creating a closed-loop record of query results, query basis, verification process, and feedback updates. Furthermore, through data acquisition modules, intent plan generation modules, evidence package generation modules, intermediate expression generation modules, verification report generation modules, and query feedback processing modules corresponding to the method steps, modular execution and continuous optimization of the intelligent data query process are achieved, improving the interpretability, traceability, and long-term adaptability of the query results.

[0086] Figure 2 This is a schematic diagram of an intelligent data query system that integrates metadata evidence and hierarchical verification according to an embodiment of the present invention.

[0087] Example 2, as Figure 2As shown, the present invention also provides an intelligent data query system that integrates metadata evidence and hierarchical verification, including: a data acquisition module S11, an intent plan generation module S12, an evidence package generation module S13, an intermediate expression generation module S14, a verification report generation module S15, and a query feedback processing module S16.

[0088] The data acquisition module is used to acquire natural language query requests, the current user context, and a set of fused metadata items; The intent plan generation module is used to perform query boundary judgment and question decomposition on the natural language query request, and generate query intent data and subquery plans; The evidence package generation module is used to perform multi-dimensional evidence filtering and access control filtering on the fused metadata item set based on the query intent data, the sub-query plan and the current user context, and generate a metadata evidence package. The intermediate expression generation module is used to generate a query intermediate expression based on the metadata evidence package. The query intermediate expression is used to characterize the query semantics, execution constraints, and evidence association relationships corresponding to the natural language query request. The verification report generation module is used to convert the intermediate query expression into a query expression to be verified, and to perform pre-layered verification on the query intent data, the metadata evidence package, the intermediate query expression, and the query expression to be verified, and generate a pre-layered verification report. The query feedback processing module is used to execute the query expression to be verified when the pre-layered verification report meets the preset pass conditions, generate an initial query result, generate query results and evidence chain explanation data based on the initial query result, and update historical samples, business rules and metadata quality scores according to the feedback data collected for the query results and the evidence chain explanation data.

[0089] Specifically, as an optional embodiment, the system performs the following steps: Step S101: Construction of an integrated metadata management system.

[0090] The system extracts metadata from database information schemas, data dictionaries, business indicator platforms, data lineage systems, permission systems, historical SQL statements, report configurations, user feedback, and manually maintained documents to form metadata items. For each metadata item, the system records its source, version, applicable business domain, sensitivity level, quality score, and validity period. The system establishes keyword indexes, vector indexes, tag indexes, table join indexes, permission indexes, and sample indexes.

[0091] Step S102: Build the tool system.

[0092] The system includes: a data query tool, a query expression validation tool, a query expression rewriting tool, an access control tool, an execution plan evaluation tool, a result reasonableness check tool, a chart generation tool, a query interpretation tool, and a feedback collection tool. Each tool receives Query Intermediate Representation (QueryIR), Metadata Evidence Pack (MetadataEvidencePack), or query expressions through a unified interface and returns structured results.

[0093] Step S103: Hierarchical retrieval of the sample database.

[0094] After receiving a user's natural language question, the system searches for similar questions in a reference sample library. The sample library records the user's question, query intent data (QueryIntent), query intermediate representation (QueryIntermediateRepresentation, QueryIR), final query expression, metadata version, business rule version, permission scope, execution result summary, user confirmation status, and quality score. If the similarity exceeds a first similarity threshold T1, and the metadata version, permission scope, and business rules are consistent, the corresponding sample is identified as a directly reused sample, and is directly reused or lightly rewritten. If the similarity is greater than or equal to a second similarity threshold T2 and less than or equal to the first similarity threshold T1, the corresponding sample is identified as a reference reused sample, and is written into the metadata evidence package as a reference sample. If the sample is expired, has conflicting business rules, or has inconsistent permission scopes, the corresponding sample is written into the excluded metadata set, and is prohibited from entering the model context. The first similarity threshold T1 is greater than the second similarity threshold T2.

[0095] Step S104: Query boundary judgment.

[0096] The system determines whether a problem falls within its capabilities based on the QueryIntent and metadata coverage. The judgment rules include: whether the business object requested by the user exists in the business terminology database; whether the required metrics or fields exist; whether necessary time, organizational, or object conditions are missing; whether it involves sensitive details that the system prohibits from querying; whether it requires cross-data source access; and whether it is a non-data query or open chat. If the problem exceeds the limits, the system returns the reason why it cannot be processed; if conditions are missing, a clarification question is generated; if the problem is complex, it proceeds to problem breakdown.

[0097] Step S105: Problem breakdown.

[0098] The system determines whether to split tasks based on two dimensions: common-sense semantics and business semantics. Common-sense semantics is used to identify parallel tasks, sequential tasks, and multiple statistical objectives; business semantics is used to identify different statistical definitions under the same term. For example, although "non-tenured teachers" and "tenured teachers" both belong to the number of teachers, their statistical rules are different, and they should be split into different SubQueryPlans. During the splitting process, the system records the sub-problem objectives, dependencies, merging methods, and required metadata types.

[0099] Step S106: Macro metadata filtering.

[0100] At the macro level, candidate data sources and candidate tables are retrieved based on query intent data, subquery plans, and business domains. The system generates table-level candidate sets by comprehensively considering keyword matching, vector similarity, table business tags, historical query frequency, table association paths, and data quality scores. For example, queries such as "school," "grade," and "number of teachers" may recall the school table, grade table, teacher table, course assignment table, and organizational structure table.

[0101] Step S107: Micro-metadata filtering.

[0102] At the micro level, the system filters fields, field values, related keys, and necessary dictionaries within the candidate table. Candidate fields are determined based on their business names, comments, value enumerations, synonyms, historical SQL references, and association paths. For example, "number of teachers" might be associated with fields such as teacher_id, teacher_status, employment_type, school_code, and teaching_school_code.

[0103] Step S108: Business rule filtering.

[0104] The business layer retrieves the metric definitions and default rules, such as whether to exclude disabled users in the headcount statistics, whether to count by affiliated schools or teaching schools, whether to use calendar year or academic year / semester for the time frame, whether to default to pagination for detailed queries, and whether the amount includes tax. The system writes the matched business rules into the business rule references (rule_refs) field in the Query Intermediate Representation (QueryIR), and verifies whether the business rules are covered by the query expression in the second-level business semantic validation layer (Level 2, L2) of the Validation Report.

[0105] Step S109: Permissions and sensitive field filtering.

[0106] The permission layer filters metadata based on user identity, role, organizational scope, data domain, field sensitivity level, query purpose, and output granularity. The system generates permission constraint fields (permission constraints, permission_constraints) and a list of prohibited metadata (Forbidden Metadata, ForbiddenMetadata). Unauthorized fields, sensitive fields, unauthorized examples, and data whose output details are not allowed must not enter the metadata evidence pack (Metadata EvidencePack, MetadataEvidencePack) or the input context of the large language model.

[0107] Step S110: Generate a metadata evidence pack (Metadata Evidence Pack).

[0108] The system combines selected tables, fields, metrics, rules, examples, table relationships, and permission constraints into a metadata evidence pack (MetadataEvidencePack), and records the metadata identifier (metadata_id), version information (version), and source reference (source_ref) for each piece of evidence. The metadata evidence pack can be configured with a context length budget, prioritizing the retention of metadata with higher quality scores, higher relevance, belonging to the current version, matching the current business domain, and satisfying the current permission constraints.

[0109] Step S111: Generate QueryIR.

[0110] Large-scale or rule-based models generate QueryIRs based on user questions and the MetadataEvidencePack. The QueryIR must explicitly specify the query objective, selected table fields, metric calculation methods, filtering conditions, time range, grouping and sorting, access constraints, and business rule references. If the QueryIR lacks necessary fields or references metadata outside the evidence package, L1 or L2 validation will fail and trigger a remediation process.

[0111] Step S112: Verification of L0 to L3.

[0112] L0 verifies whether the issue is within the boundaries; L1 verifies whether the table fields and metrics in the QueryIR all come from the MetadataEvidencePack; L2 verifies whether the business scope, default filters, time scope, and organizational scope are correct; L3 verifies whether the QueryIR references unauthorized fields, sensitive fields, or detailed granularities that are not allowed to be output. If verification fails, the system can re-retrieve metadata, generate clarification questions, delete violating fields, or initiate manual confirmation.

[0113] Step S113: Generate the query expression.

[0114] The query expression generator converts the validated Query Intermediate Representation (QueryIR) into parameters in Structured Query Language (SQL), Domain Specific Language (DSL), or Application Programming Interface (API) that the target execution engine can recognize. For different database dialects, the system selects the appropriate template and syntax rules based on the data source type. At this stage, generating dangerous statements such as DROP, UPDATE, and DELETE statements is not allowed; if write operations are required, a separate approval process should be initiated.

[0115] Step S114: L4 query expression validation and secure rewriting.

[0116] The system validates query expressions for syntax, table field existence, JOIN paths, aggregation granularity, GROUP BY integrity, time conditions, permission conditions, result row limits, and dangerous functions. For rule-based conditions such as "this semester," "this month," "normal status," and "default organizational scope," the system uses a rewriting tool to supplement specific code or filter conditions, reducing the uncertainty of freely generated large models.

[0117] Step S115: L5 execution plan and result rationality verification.

[0118] Before execution, the system assesses the size of the scanned table, the estimated number of rows, index coverage, JOIN complexity, timeout time, and resource consumption. If the thresholds are exceeded, the user is asked to narrow down the scope or rewrite the query. After execution, the system checks whether the results are empty, abnormally large, violate statistical common sense, conflict with permission constraints, or require secondary aggregation or data anonymization.

[0119] Step S116: Result processing and interpretation generation.

[0120] The system determines the display format of the query results based on the query type, which may include tables, charts, summaries, or detailed pagination. For statistical queries, the system outputs the indicator scope, time range, filtering conditions, and grouping logic; for detailed queries, the system outputs field descriptions, anonymization instructions, and pagination restrictions; for abnormal results, the system outputs the possible reasons for the abnormal results. The explanatory content corresponding to the query results comes from the Query Intermediate Representation (QueryIR), Metadata Evidence Pack, Validation Report, and execution logs. Generating explanatory content lacking corresponding source evidence is prohibited.

[0121] Step S117: Feedback Learning.

[0122] The system collects user confirmations, error corrections, ratings, manual reviews, and reasons for execution failures. Successful and confirmed QueryIRs, query expressions, and explanations can be written into the reference sample library; reasons for failure can be written into disabled examples or rule correction suggestions; metadata quality scores are adjusted based on success rate, number of conflicts, and manual confirmation results.

[0123] The aforementioned system enables natural language query requests to no longer rely on models to freely generate query expressions, but instead complete query generation and execution within the scope of accessible, verifiable, and traceable metadata evidence, thereby improving the accuracy, security, interpretability, and continuous adaptability of enterprise-level intelligent data queries.

[0124] Example 3: The present invention also provides an intelligent data query device that integrates metadata evidence and hierarchical verification. The device includes a computer device, which includes a processor and a memory. The memory stores computer instructions. When the computer instructions are executed, the device implements the intelligent data query method that integrates metadata evidence and hierarchical verification.

[0125] Example 4, as Figure 3 As shown, the present invention also provides an electronic device 100 for implementing an intelligent data query method that integrates metadata evidence and hierarchical verification.

[0126] The electronic device 100 includes a memory 101, at least one processor 102, a computer program 103 stored in the memory 101 and executable on at least one processor 102, and at least one communication bus 104.

[0127] The memory 101 can be used to store the computer program 103. The processor 102 implements the steps of the intelligent data query method for integrating metadata evidence and hierarchical verification as described in the first aspect of the present invention by running or executing the computer program stored in the memory 101 and calling the data stored in the memory 101.

[0128] The memory 101 may primarily include a program storage area and a data storage area. The program storage area may store the operating system, application programs required for at least one function (such as sound playback function, image playback function, etc.), etc.; the data storage area may store data created based on the use of the electronic device 100 (such as audio data), etc. In addition, the memory 101 may include non-volatile memory, such as hard disk, RAM, plug-in hard disk, smart media card (SMC), secure digital (SD) card, flash card, at least one disk storage device, flash memory device, or other non-volatile solid-state storage device.

[0129] At least one processor 102 may be a Central Processing Unit (CPU), or 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, etc. Processor 102 may be a microprocessor or any conventional processor. Processor 102 is the control center of electronic device 100, connecting various parts of electronic device 100 via various interfaces and lines.

[0130] The memory 101 in the electronic device 100 stores multiple instructions to implement an intelligent data query method that integrates metadata evidence and hierarchical verification, and the processor 102 can execute multiple instructions to achieve the following: Retrieve the natural language query request, the current user context, and the fused metadata item set; The natural language query request is subjected to query boundary judgment and question decomposition to generate query intent data and subquery plan; Based on the query intent data, the sub-query plan, and the current user context, multi-dimensional evidence screening and access control filtering are performed on the fused metadata item set to generate a metadata evidence package. Based on the metadata evidence package, a query intermediate expression is generated. The query intermediate expression is used to characterize the query semantics, execution constraints, and evidence association relationships corresponding to the natural language query request. The intermediate query expression is converted into a query expression to be verified. Pre-layered verification is performed on the query intent data, the metadata evidence package, the intermediate query expression, and the query expression to be verified, and a pre-layered verification report is generated. When the pre-layered verification report meets the preset pass conditions, the query expression to be verified is executed to generate an initial query result. Based on the initial query result, query results and evidence chain explanation data are generated. Historical samples, business rules, and metadata quality scores are updated according to the feedback data collected for the query results and the evidence chain explanation data.

[0131] Example 5:

[0132] If the modules / units integrated in the electronic device 100 are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the methods of the above embodiments of the present invention can also be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. The computer-readable medium can include: any entity or device capable of carrying computer program code, recording media, USB flash drives, portable hard drives, magnetic disks, optical disks, computer memory, and read-only memory (ROM).

[0133] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, systems, or computer program products. Therefore, the present invention can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0134] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0135] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0136] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0137] In the description of this specification, references to terms such as "an embodiment," "example," "specific example," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of the invention. In this specification, illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples.

[0138] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and not to limit it. Although the present invention has been described in detail with reference to the above embodiments, those skilled in the art should understand that modifications or equivalent substitutions can still be made to the specific implementation of the present invention. Any modifications or equivalent substitutions that do not depart from the spirit and scope of the present invention should be covered within the scope of protection of the claims of the present invention.

Claims

1. An intelligent data query method integrating metadata evidence and hierarchical verification, characterized in that, The method includes: Retrieve the natural language query request, the current user context, and the fused metadata item set; The natural language query request is subjected to query boundary judgment and question decomposition to generate query intent data and subquery plan; Based on the query intent data, the sub-query plan, and the current user context, multi-dimensional evidence screening and access control filtering are performed on the fused metadata item set to generate a metadata evidence package. Based on the metadata evidence package, a query intermediate expression is generated. The query intermediate expression is used to characterize the query semantics, execution constraints, and evidence association relationships corresponding to the natural language query request. The intermediate query expression is converted into a query expression to be verified. Pre-layered verification is performed on the query intent data, the metadata evidence package, the intermediate query expression, and the query expression to be verified, and a pre-layered verification report is generated. When the pre-layered verification report meets the preset pass conditions, the query expression to be verified is executed to generate an initial query result. Based on the initial query result, query results and evidence chain explanation data are generated. Historical samples, business rules, and metadata quality scores are updated according to the feedback data collected for the query results and the evidence chain explanation data.

2. The intelligent data query method integrating metadata evidence and hierarchical verification according to claim 1, characterized in that, The fused metadata item set includes multiple metadata items, each of which includes a metadata identifier, metadata type, metadata name, business name, source system, data source information, association path, business rule identifier, permission policy identifier, sensitivity level, version information, validity period, quality score, and source reference. The metadata type includes tables, fields, metrics, business terms, business rules, historical examples, permission policies, data lineage, field value dictionary, and data quality status.

3. The intelligent data query method integrating metadata evidence and hierarchical verification according to claim 1, characterized in that, The process of performing query boundary judgment and question decomposition on the natural language query request to generate query intent data and subquery plans includes: The natural language query request is standardized to generate standardized query text; Based on the standardized query text and the fused metadata item set, business domain identification, query type identification, query object identification, indicator identification, dimension identification, time range identification, and risk level identification are performed to generate the query intent data; Based on the query intent data, determine whether the natural language query request has missing query conditions, out-of-bounds query scope, sensitive detail query, or multi-target query; When the natural language query request contains multiple target queries, the subquery plan is generated based on the dependencies, execution order, and merging rules among the multiple query targets.

4. The intelligent data query method integrating metadata evidence and hierarchical verification according to claim 1, characterized in that, Based on the query intent data, the sub-query plan, and the current user context, the fused metadata item set undergoes multi-dimensional evidence filtering and access control filtering to generate a metadata evidence package, including: Based on the query intent data and the subquery plan, candidate data sources, candidate tables, candidate fields, candidate metrics, candidate business rules, and candidate historical examples are determined from the fused metadata item set; Based on the current user context, access control filtering is performed on the candidate data source, the candidate table, the candidate field, the candidate metric, the candidate business rule, and the candidate historical sample to generate an allowed metadata set and an excluded metadata set; The metadata evidence package is generated based on the allowed metadata set, the excluded metadata set, the corresponding metadata version information, and the source reference.

5. The intelligent data query method integrating metadata evidence and hierarchical verification according to claim 1, characterized in that, The generation of the intermediate query representation based on the metadata evidence package includes: Extract the query object, candidate indicators, candidate dimensions, candidate filtering conditions, candidate time range, candidate association path, permission constraints, and business rule references corresponding to the natural language query request from the metadata evidence package; Based on the query object, the candidate indicators, the candidate dimensions, the candidate filtering conditions, the candidate time range, the candidate association path, the permission constraints, and the business rule references, the intermediate query expression is generated. The evidence reference relationship corresponding to the metadata evidence package is written into the intermediate expression of the query.

6. The intelligent data query method integrating metadata evidence and hierarchical verification according to claim 1, characterized in that, The process of converting the intermediate query expression into a query expression to be verified, performing pre-level layered verification on the query intent data, the metadata evidence package, the intermediate query expression, and the query expression to be verified, and generating a pre-level layered verification report includes: The intermediate query expression is converted into a query expression to be verified corresponding to the target query engine. Perform query boundary validation on the query intent data and generate boundary validation results; Perform metadata coverage verification on the query objects, metrics, dimensions, and filter conditions in the intermediate query expression, and generate metadata coverage verification results; Perform business semantic verification on the business rule references, time calibers, and organizational calibers in the intermediate query expression, and generate business semantic verification results; Perform permission security verification on the field references, output granularity, and access scope in the intermediate query expression and the query expression to be verified, and generate permission security verification results; Perform syntax, table field existence, association path, and aggregation granularity validations on the query expression to be validated, and generate expression validity validation results; The pre-layered verification report is generated based on the boundary verification results, the metadata coverage verification results, the business semantic verification results, the permission security verification results, and the expression validity verification results.

7. The intelligent data query method integrating metadata evidence and hierarchical verification according to claim 6, characterized in that, Before generating the aforementioned pre-layered verification report, the following is also included: The time condition, default status condition, organizational scope condition, sorting condition, pagination condition, result row count limit condition, and sensitive field processing condition in the query expression to be verified are rewritten securely to generate the rewritten query expression. The modified query expression is then re-executed for permission security verification and expression validity verification. The rewritten query expression that passes the revalidation is used as the target query expression, and the target query expression is used as the query expression for subsequent query execution.

8. The intelligent data query method integrating metadata evidence and hierarchical verification according to claim 1, characterized in that, The generation of query results and evidence chain explanation data based on the initial query results includes: Based on the initial query results and the consistency checks of the number of rows in the query execution log, empty result status, abnormal values, execution resource consumption, and permission constraints, a result rationality verification result is generated. When the result of the result rationality verification meets the preset result conditions, the initial query result is summarized, desensitized, paginated or charted to generate the query result. Based on the intermediate query expression, the metadata evidence package, and the pre-layered verification report, the evidence chain explanation data is generated, which includes query criteria, filtering conditions, time range, permission restrictions, exclusion data descriptions, and metadata sources.

9. The intelligent data query method integrating metadata evidence and hierarchical verification according to claim 1, characterized in that, The step of updating historical examples, business rules, and metadata quality scores based on feedback data collected for the query results and the evidence chain interpretation data includes: Collect at least one of the following: user confirmation data, user error correction data, manual review data, execution failure reason data, empty result reason data, and result abnormality reason data, and generate the feedback data; Based on the feedback data, successful examples, reference examples, examples pending review, disabled examples, and rule correction suggestions are determined. Based on the successful examples, the reference examples, the examples to be reviewed, the disabled examples, and the rule correction suggestions, update the historical examples, the business rules, and the metadata quality scores.

10. An intelligent data query system integrating metadata evidence and hierarchical verification, characterized in that, The system includes: The data acquisition module is used to acquire natural language query requests, the current user context, and a set of fused metadata items; The intent plan generation module is used to perform query boundary judgment and question decomposition on the natural language query request, and generate query intent data and subquery plans; The evidence package generation module is used to perform multi-dimensional evidence filtering and access control filtering on the fused metadata item set based on the query intent data, the sub-query plan and the current user context, and generate a metadata evidence package. The intermediate expression generation module is used to generate a query intermediate expression based on the metadata evidence package. The query intermediate expression is used to characterize the query semantics, execution constraints, and evidence association relationships corresponding to the natural language query request. The verification report generation module is used to convert the intermediate query expression into a query expression to be verified, and to perform pre-layered verification on the query intent data, the metadata evidence package, the intermediate query expression, and the query expression to be verified, and generate a pre-layered verification report. The query feedback processing module is used to execute the query expression to be verified when the pre-layered verification report meets the preset pass conditions, generate an initial query result, generate query results and evidence chain explanation data based on the initial query result, and update historical samples, business rules and metadata quality scores according to the feedback data collected for the query results and the evidence chain explanation data.