Data query method, electronic equipment and storage medium

By constructing a directed acyclic graph and validating input parameters before each tool execution unit, the problems of high user skill requirements and unreliable results in traditional data query methods are solved, realizing a transparent data query process and improving user trust and the convenience of anomaly analysis.

CN121387947APending Publication Date: 2026-01-23ZHEJIANG LAB
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202511939859.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-22
Publication Date
2026-01-23

AI Technical Summary

Technical Problem

Traditional data query methods require users to master SQL knowledge, and the black-box nature of the query process leads to low user trust in the query results and makes anomaly analysis difficult.

Method used

Construct a directed acyclic graph, with nodes corresponding to tool execution units. Execute operations in topological order, validate input parameters before each tool execution unit, generate database query instructions, and return the tool identifier, input parameters, and execution results to make the process transparent.

Benefits of technology

It lowers the threshold for data queries, increases users' trust in query results, and reduces the difficulty of anomaly analysis.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121387947A_ABST
    Figure CN121387947A_ABST
Patent Text Reader

Abstract

The invention provides a data query method, electronic equipment and a storage medium, and relates to the field of data query. Constructing a directed acyclic graph according to data query information input by a user; nodes of the directed acyclic graph correspond to tool execution units. According to the topological sequence of the directed acyclic graph, tool execution units corresponding to all the nodes are triggered in sequence to execute corresponding operations till a database query instruction is obtained. The input parameters are verified before the tool execution unit executes the corresponding operation, so that the target input parameters are obtained according to the verification result, and the reliability of the data query instruction is improved. At least one of the tool identifier of the tool called by executing the corresponding operation, the target input parameter and the execution result is returned to the client, so that a user can conveniently judge the logic rationality of generating the database query instruction, the necessity of tool calling and the accuracy of each execution result, the process of generating the database query instruction is transparent, and the user experience is improved. The credibility of the user on the target data is improved, and the anomaly analysis difficulty is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the field of data query, and in particular to a data query method, an electronic device and a storage medium. BACKGROUND

[0002] As an important data storage tool, databases have been widely used in various fields. Traditional data query methods require users to master SQL (Structured Query Language) and related knowledge of data storage, and the query threshold is high. At present, although methods supporting users to query target data from databases in the form of natural language have appeared. However, the data query process of such methods is black-boxed, and it is difficult to evaluate the data query accuracy, which leads to low trust of users on the data query results, and it is difficult to determine the abnormal reason when the data query result is abnormal.

[0003] Therefore, it is urgent to provide a data query method to ensure data query accuracy, improve user trust in data query results, optimize data query experience, and reduce the difficulty of analyzing abnormal reasons. SUMMARY

[0004] Therefore, the present application provides a data query method, which comprises: According to the data query information input by the user, a directed acyclic graph is constructed; the nodes of the directed acyclic graph correspond to tool execution units; According to the topological order of the directed acyclic graph, the tool execution units corresponding to each node are triggered in turn to perform corresponding operations, until the tool execution unit corresponding to the last node performs the corresponding operation, and a database query instruction is obtained; Before each tool execution unit performs the corresponding operation, the input parameters of the current tool execution unit are verified to obtain the target input parameters of the current tool execution unit according to the verification result; After each tool execution unit performs the corresponding operation, specified information is returned to the client; the specified information includes at least one of the tool identifier of the tool called by the execution of the corresponding operation, the target input parameter, and the execution result obtained after the execution of the corresponding operation; Target data is queried from the database based on the database query instruction.

[0005] Optionally, before the directed acyclic graph is constructed according to the data query information input by the user, the method further comprises: The first large model constructed in advance is used to perform specified verification of query elements on the data query information; the specified verification includes at least one of missing verification and ambiguity verification; the query elements include at least one of data entities, attribute fields and data filtering conditions; if the result of the specified check represents that the data query information lacks the query element, generating prompt information for prompting to supplement the missing query element; if the result of the specified check represents that there is an ambiguous query element in the data query information, generating prompt information for prompting to correct the query element with ambiguity; returning the prompt information to the client to obtain new data query information, and entering the step of constructing a directed acyclic graph according to the user-input data query information.

[0006] Optionally, the input parameter of the current tool execution unit is checked to obtain a target input parameter of the current tool execution unit according to a check result, including: determining a target input parameter check condition of the current tool execution unit based on a pre-constructed mapping relationship; the mapping relationship is a corresponding relationship between a tool execution unit and an input parameter check condition; judging whether the input parameter meets the target input parameter check condition; if yes, taking the input parameter as the target input parameter; if no, generating correction prompt information for prompting to correct the input parameter; returning the correction prompt information to the client to obtain user-input input parameter correction information; and taking the input parameter correction information as the target input parameter.

[0007] Optionally, the target data is queried from the database based on the database query instruction, including: generating a unique instruction identifier for the database query instruction; generating a result viewing link containing the instruction identifier, and returning the result viewing link to the client; if the result viewing link is triggered, calling the database query instruction based on the instruction identifier to initiate a data query request to obtain the target data.

[0008] Optionally, after the target data is obtained by calling the database query instruction based on the instruction identifier to initiate a data query request, the method further includes: selecting preview data from the target data; generating a preview pop-up window for displaying the preview data, and displaying the preview pop-up window on the client; the preview pop-up window includes a trigger node for indicating to query complete data; if the trigger node is triggered, returning the target data to the client.

[0009] Optionally, the directed acyclic graph is constructed according to the user-input data query information, including: The second large model is pre-built, a tool information library is called, and task description information for building the directed acyclic graph is generated based on the data query information; the tool information library is used to store tool information of an initial tool; the tool information at least includes tool identification, input parameter structure information, output parameter structure information, a function body, meta information, and tool dependency; the meta information at least includes function description information of the initial tool; and the tool dependency is used to represent a data dependency between the current initial tool and other initial tools; The directed acyclic graph is built by using a specified workflow orchestration framework according to the task description information; and an edge between adjacent nodes in the directed acyclic graph represents a dependency between adjacent tool execution units.

[0010] Optionally, the initial tool includes a meta information query tool, a filtering instruction generation tool, a query instruction generation tool, and an instruction verification tool. The meta information query tool is used to query meta information of a data entity in the data query information. The filtering instruction generation tool is used to obtain filtering conditions extracted from the data query information and a logical relationship between the filtering conditions; initial filtering instructions are generated according to the filtering conditions; and data filtering instructions are generated by combining the initial filtering instructions according to the logical relationship. The query instruction generation tool is used to generate the database query instruction based on the obtained data query information, the meta information, and the data filtering instructions. The instruction verification tool is used to perform syntax verification on the obtained database query instruction, and determine a final database query instruction based on a result of the syntax verification.

[0011] Optionally, in the process of sequentially triggering the tool execution units corresponding to the nodes to perform corresponding operations, the method further includes: determining whether the current tool execution unit is successfully executed; if not, re-triggering the current tool execution unit every interval of a preset time length; if a number of re-triggering times does not reach a preset number of times, entering the step of determining whether the current tool execution unit is successfully executed; and if the number of times reaches the preset number of times, ending; if yes, triggering the tool execution unit corresponding to a directly downstream node to perform a corresponding operation.

[0012] The application further provides an electronic device, including: a memory configured to store a computer program; a processor configured to execute the computer program to implement the steps of the data query method of any one of the above.

[0013] This application also provides a storage medium storing a computer program, which, when executed by a processor, implements the steps of any of the above data query methods.

[0014] In summary, this application provides a data query method, an electronic device, and a storage medium. A directed acyclic graph (DAG) is constructed based on user-inputted data query information; each node in the DAG corresponds to a tool execution unit. Following the topological order of the DAG, the tool execution units corresponding to each node are triggered sequentially to perform their respective operations until a database query instruction is obtained. Based on the database query instruction, the target data can be retrieved from the database. Users only need to provide data query information to retrieve the target data from the database, lowering the barrier to data querying.

[0015] Furthermore, before the tool execution unit performs the corresponding operation, the input parameters of the current tool execution unit are validated to obtain the target input parameters based on the validation results, ensuring the reliability of the generated data query instructions and enhancing the user's trust in the target data retrieved based on the data query instructions.

[0016] After the tool execution unit performs the corresponding operation, it returns at least one of the following to the client: the tool identifier of the tool called to perform the corresponding operation, the target input parameters, and the execution result. This makes it easier for users to judge the logical rationality of the generated database query command, the necessity of the tool call, and the accuracy of each execution result. It makes the process of generating the database query command transparent, increases the user's trust in the target data, and reduces the difficulty of anomaly analysis. Attached Figure Description

[0017] Figure 1 A first flowchart illustrating a data query method provided in this application; Figure 2 This application provides a directed acyclic graph; Figure 3 A schematic diagram of a dialog interface displayed on a client side, provided for the purposes of this application; Figure 4 A second flowchart illustrating a data query method provided in this application; Figure 5 A schematic diagram of the third process of a data query method provided in this application; Figure 6 A schematic diagram illustrating the principle of data delivery in a data query method provided in this application; Figure 7 A preview pop-up window diagram provided for this application; Figure 8 This is a schematic diagram of tool information corresponding to an initial tool provided in this application. DETAILED DESCRIPTION

[0018] The terminology used in this application is for the purpose of describing particular embodiments only and is not intended to be limiting. As used in this application and the appended claims, the singular forms "a," "an" and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It will also be understood that the term "and / or" as used herein refers to and encompasses any and all possible combinations of one or more of the associated listed items.

[0019] It will be understood that, although the terms first, second, third, etc. can be used herein to describe various information, these terms are not intended to denote a temporal or chronological order. Rather, these terms are used solely to distinguish one from another only. For example, a first information can be termed a second information, and similarly, a second information can also be termed a first information, without departing from the scope of the present application. Depending on the context, the word "if' as used herein can be interpreted to mean "when" or "in response to determining" or "in response to ascertaining."

[0020] Reference will now be made to the following description taken in conjunction with the accompanying drawings. Figure 1 , Figure 1 A first flowchart of a data query method provided by the present application is shown in FIG. 1. The method comprises the following steps: S1. Constructing a directed acyclic graph according to data query information input by a user; the nodes of the directed acyclic graph correspond to tool execution units.

[0021] The data query information input by the user includes, but is not limited to, characters, audio or pictures input in natural language form, etc. The present application does not make special limitations on this.

[0022] After obtaining the data query information input by the user, a directed acyclic graph for generating a data query instruction is constructed according to the data query information input by the user. The nodes in the directed acyclic graph correspond to tool execution units. The tool execution units execute corresponding operations by calling corresponding tools, such as querying meta information of a data entity, generating a data filtering instruction and generating a data query instruction, etc. The edges between adjacent nodes in the directed acyclic graph represent the dependency relationship between adjacent tool execution units, which determines the order of executing corresponding operations by the tool execution units. The specific implementation of constructing the directed acyclic graph will be illustrated in subsequent embodiments, which will not be described here in detail.

[0023] S2. Triggering the tool execution units corresponding to the nodes to execute corresponding operations in topological order of the directed acyclic graph, until the tool execution unit corresponding to the last node executes corresponding operations, and a database query instruction is obtained.

[0024] The tool execution unit corresponding to the current triggered node is taken as the current tool execution unit. After the current tool execution unit is triggered, upstream execution results are first received to perform corresponding operations based on the upstream execution results; the upstream execution results are execution results generated by a tool execution unit corresponding to a direct upstream node of the current triggered node. Please refer to Figure 2 , Figure 2 A directed acyclic graph is provided in the present application. In Figure 2 , node 2 is taken as the current triggered node, and the tool execution unit corresponding to node 2 is taken as the current tool execution unit. After the current tool execution unit is triggered, upstream execution results generated by node 1 (i.e., a direct upstream node of node 2) are first received, and then corresponding operations are performed based on the upstream execution results.

[0025] After the current tool execution unit performs corresponding operations to generate current execution results, the current execution results are encapsulated and transmitted to tool execution units corresponding to direct downstream nodes. Again, in Figure 2 , node 2 is taken as the current triggered node, and the tool execution unit corresponding to node 2 is taken as the current tool execution unit. After the current tool execution unit generates current execution results, the encapsulated current execution results are transmitted to nodes 5 and 7 (i.e., direct downstream nodes of node 2).

[0026] According to the above process, tool execution units corresponding to nodes in the directed acyclic graph are triggered in turn to perform corresponding operations, until a tool execution unit corresponding to the last node performs corresponding operations, thereby obtaining a database query instruction and realizing conversion from data query information to a database query instruction.

[0027] S3、Before each tool execution unit performs corresponding operations, input parameters of the current tool execution unit are verified to obtain target input parameters of the current tool execution unit according to verification results.

[0028] Different tool execution units correspond to different input parameters, so input parameter verification conditions can be set for each tool execution unit in advance to verify input parameters of the tool execution unit by using the input parameter verification conditions. The process of input parameter verification will be described in detail in subsequent embodiments, which will not be described here.

[0029] After the verification result is obtained, target input parameters of the current tool execution unit are obtained according to the verification result. The target input parameters refer to input parameters that can successfully pass the verification. For example, when the verification result indicates that the verification passes, the input parameters are directly taken as the target input parameters; when the verification result indicates that the verification fails, corrected input parameters provided by a user are obtained through interaction with the user, and the corrected input parameters are taken as the target input parameters.

[0030] In summary, by checking the input parameters of the current tool execution unit, the reliability of the target input parameters input to the current tool execution unit is ensured, and the reliability of the execution result generated by the current tool execution unit is ensured, so as to obtain an accurate data query instruction and improve the trust of the user on the data query result.

[0031] S4, after each tool execution unit executes the corresponding operation, return the specified information to the client; the specified information includes at least one of the tool identifier of the tool called by the execution of the corresponding operation, the target input parameter, and the execution result obtained after the execution of the corresponding operation.

[0032] As described above, the present application obtains a data query instruction by triggering each node in the directed acyclic graph to execute the corresponding operation of the tool execution unit. Each tool execution unit executes the corresponding operation by calling the corresponding tool. Therefore, the present application returns the specified information to the client after each tool execution unit executes the corresponding operation, so as to transparentize the generation process of the data query instruction and improve the trust of the user. Specifically, the specified information includes at least one of the tool identifier of the tool called by the execution of the corresponding operation, the target input parameter, and the execution result. The tool identifier includes but is not limited to the tool name of the called tool.

[0033] Please refer to Figure 3 , Figure 3 for a display interface provided by the present application.

[0034] As Figure 3 shown, the tool execution unit corresponding to step 4 executes the meta information query operation by calling the meta information query tool. After the execution of the meta information query operation is completed, the tool name of the called meta information query tool is returned to the client as the tool identifier; the data entity table-id input to the current tool execution unit is returned to the client as the target input parameter; and the meta information of the data entity table-id found by the meta information query tool is returned to the client as the execution result.

[0035] As Figure 3 shown, the tool execution unit corresponding to step 5 executes the data query operation by the data query tool to query the target data from the data entity based on the filter condition in the data query instruction. After the execution of the data query operation is completed, the tool name of the called data query tool is returned to the client as the tool identifier; and the data query instruction input to the current tool execution unit is returned to the client as the target input parameter. As for the query result of the data query tool, i.e., the target data, it will be delivered through the result viewing link shown in Figure 3 , which will be described in detail later, and will not be described here.

[0036] By returning the specified information to the client, the user can understand the tool called by the data query instruction and the intermediate result (i.e., the target input parameter and the execution result), and thus can determine the logical rationality of the generation process of the data query instruction, the necessity of calling the tool, and the accuracy of the intermediate result, thereby improving the user's trust in the finally generated data query instruction.

[0037] In addition, since the intermediate process of generating the data query instruction is displayed, when the data query result is abnormal, it can be determined whether the intermediate process is abnormal, the abnormal point can be accurately located, and the difficulty of abnormal analysis is reduced.

[0038] S5, querying the target data from the database based on the database query instruction.

[0039] For the specific implementation of querying the target data from the database by using the database query instruction, the present application does not make special limitations.

[0040] For example, the database query instruction is input as an input parameter to a pre-constructed data query tool, and the data query tool is triggered. After the data query tool is triggered, the corresponding connector is loaded according to the type of the database to establish a connection with the database through the connector; the database query instruction is executed to query the target data from the database; and after the target data is processed, such as paging, sorting, and format conversion (including but not limited to JSON array or CSV file format), the final target data is obtained.

[0041] At this point, the purpose of querying the target data from the database according to the data query information input by the user is achieved. In the entire data query process, the user only needs to provide the data query information, which greatly reduces the data query threshold.

[0042] On the one hand, the input parameter of the current tool execution unit is verified before the tool execution unit executes the corresponding operation, so as to obtain the target input parameter according to the verification result, ensure that the accurate data query instruction is generated, and improve the user's trust in the data query result.

[0043] On the other hand, after the tool execution unit executes the corresponding operation, the specified information, i.e., at least one of the tool identifier of the tool called by the corresponding operation, the target input parameter, and the execution result, is returned to the client, which is convenient for the user to determine the logical rationality of the generation process of the data query instruction, the necessity of calling the tool, and the accuracy of the intermediate result, thereby further improving the user's trust in the data query result.

[0044] Further, the operation of returning the specified information to the client makes the intermediate process of generating the database query instruction transparent. Based on this, when the data query result is abnormal, it can be checked whether each intermediate process is abnormal, thereby accurately locating the abnormal point and reducing the difficulty of abnormal analysis.

[0045] On the basis of the above-mentioned embodiments: Please refer to Figure 4 , Figure 4 A second flowchart of a data query method provided in the present application. As an optional embodiment, before constructing the directed acyclic graph according to the data query information input by the user, it further includes: S601, performing specified verification of query elements on the data query information by the first large model constructed in advance; the specified verification includes at least one of missing verification and ambiguity verification; the query elements include at least one of data entity, attribute field and data filtering condition; S602, if the result of the specified verification represents that the data query information is missing query elements, generating prompt information for prompting to supplement the missing query elements; if the result of the specified verification represents that there are ambiguous query elements in the data query information, generating prompt information for prompting to correct the ambiguous query elements; S603, returning the prompt information to the client to obtain new data query information, and entering step S1.

[0046] Considering that the data query information input by the user may have problems such as semantic ambiguity or missing information required for performing the data query operation, in the present embodiment, the data query information is first verified, and when the verification fails, new data query information is obtained through interaction with the user, so as to ensure that accurate data query instructions are generated and the reliability of the data query result is improved.

[0047] Specifically, in the present embodiment, the first large model is constructed in advance, and the query elements in the data query information input by the user are extracted through semantic analysis. The query elements include at least one of data entity, attribute field and data filtering condition. Among them, the data entity is used to locate the query object, that is, to locate the table to be queried in the database. The attribute field is used to further locate the column to be queried in the data entity. The filtering condition is used to further filter the target data required by the user from the column to be queried. Based on the above-mentioned query elements, the data query information can be converted into database query instructions corresponding to SQL, Cypher and SPARQL query languages, and data query can be realized. Therefore, it is necessary to perform specified verification on the query elements.

[0048] Based on this, the first large model pre-constructed is used to specify and check the query elements of the data query information. The specified check includes at least one of the missing check and the ambiguity check. Specifically, the first large model performs semantic analysis on the data query information to extract the query elements in the data query information. If the query elements are not extracted, it is considered that the missing check fails, and a check result representing that the data query information is missing the query elements is generated. If the query elements are extracted, and the data entity does not exist in the database, or the attribute field does not exist in the data entity, or the filter value and the filter operator do not exist in the filter condition, it is considered that the missing check fails, and a check result representing that the data query information is missing the query elements is generated. If the query elements are extracted, and there are multiple data entities in the database, or there are multiple attribute fields in the data entity, or the filter condition semantics are ambiguous, it is considered that the ambiguity check fails, and a check result representing that there are ambiguous query elements in the data query information is generated.

[0049] When the specified check fails, that is, the result of the specified check represents that the data query information is missing the query elements, or that there are ambiguous query elements in the data query information, corresponding prompt information is generated, and the prompt information is returned to the client to accurately prompt the user to provide the data query information after supplementing or correcting the query elements. After obtaining the new data query information provided by the user, a directed acyclic graph is constructed based on the new data query information to ensure that an accurate data query instruction is generated, and the reliability of the data query result is improved.

[0050] As an optional embodiment, the input parameters of the current tool execution unit are checked to obtain the target input parameters of the current tool execution unit according to the check result, including: Based on the pre-constructed mapping relationship, the target input parameter check condition of the current tool execution unit is determined; the mapping relationship is the corresponding relationship between the tool execution unit and the input parameter check condition; It is judged whether the input parameters meet the target input parameter check condition; If it is met, the input parameters are used as the target input parameters; If it is not met, correction prompt information for prompting the correction of the input parameters is generated; the correction prompt information is returned to the client to obtain the input parameter correction information of the user; and the input parameter correction information is used as the target input parameters.

[0051] Considering that different tool execution units correspond to different input parameters, the embodiment is pre-constructed with a mapping relationship, which is the correspondence between the tool execution unit and the input parameter verification condition. For example, the current tool execution unit is used to query the meta information of the data entity, and its input parameter is the data entity extracted from the data query information, and its input parameter verification condition is whether the data entity exists in the database. For another example, the current tool execution unit is used to generate a data filtering instruction according to a filtering condition, and its input parameter is the filtering condition extracted from the data query information, and its input parameter verification condition is whether the filtering field name, filtering value and filtering operator exist in the filtering condition. In short, according to the input parameters of each tool execution unit, the input parameter verification condition is set to ensure the reliability of the input parameters of the current tool execution unit.

[0052] Based on the above mapping relationship, the target input parameter verification condition of the current tool execution unit is determined. If the input parameter of the current tool execution unit meets the target input parameter verification condition, the input parameter is directly taken as the target input parameter. If the input parameter does not meet the target input parameter verification condition, correction prompt information for prompting correction of the input parameter is generated, and the correction prompt information is returned to the client; through interaction with the user, the input parameter correction information is obtained, and the input parameter correction information is taken as the target input parameter.

[0053] In addition, the input parameter verification function in the embodiment can be realized by calling the pre-constructed verification intelligent agent. The mapping relationship is pre-stored in the verification intelligent agent, and the target input parameter verification condition of the current tool execution unit is automatically determined according to the mapping relationship; the input parameter verification is performed based on the obtained input parameter and the target input parameter verification condition. After the target input parameter is determined, the current tool execution unit is triggered to perform the corresponding operation.

[0054] In summary, the embodiment uses the pre-constructed mapping relationship to verify the input parameter, ensures the reliability of the input parameter, guarantees the reliability of the execution result generated by the current tool execution unit, and then obtains an accurate data query instruction, thereby improving the trust degree of the user to the data query result.

[0055] Please refer to Figure 5 , Figure 5 A third flowchart of a data query method provided in the present application. As an optional embodiment, the target data is queried from the database based on the database query instruction, comprising: S501, generating a unique instruction identifier for the database query instruction; S502, generating a result viewing link containing the instruction identifier, and returning the result viewing link to the client; S503, if the result viewing link is triggered, calling the database query instruction based on the instruction identifier to initiate a data query request, and obtaining the target data.

[0056] Considering returning the complete target data directly to the client, it can cause Token redundancy, serious delay of dialogue response speed, and exceeding the carrying capacity of the dialogue box provided by the client. If only part of the target data is returned, it cannot meet the user's verification demand for data query results, and the data delivery experience is poor.

[0057] Please refer to Figure 6 , Figure 6 A principle diagram of data delivery in a data query method provided by the present application is shown in the following figure. In this embodiment, after obtaining the database query instruction, a unique instruction identifier is generated for the database query instruction. As shown in the following figure, the database query instruction and the corresponding instruction identifier can also be stored as an instruction pair in the instruction database, so as to subsequently find the corresponding database query instruction according to the instruction identifier. Figure 6

[0058] After obtaining the instruction identifier, a result viewing link containing the instruction identifier is generated, and the result viewing link is returned to the client. As shown in the following figure, the result viewing link is presented in the form of a clickable link in the client, and a prompt information “completed conditional retrieval, you can view the results through the following link” is displayed, which can not only intuitively prompt the user that there is data query result to be viewed, but also reduce the dialogue context load, avoid the problems of Token redundancy, delay of dialogue response speed, and exceeding the carrying capacity of the dialogue box, and improve the data delivery experience. Figure 3

[0059] If it is detected that the result viewing link is triggered, the instruction identifier contained in the result viewing link is extracted, and the database query instruction corresponding to the instruction identifier is found from the instruction database, as shown in the following figure. Subsequently, the database query instruction is called to initiate a data query request to the database, obtain the target data, and meet the user's verification demand for data query results. Figure 6

[0060] In addition, as described above, the process of calling the database query instruction to initiate the data query request can be implemented by triggering the pre-constructed data query tool in the backend. The input parameter of the data acquisition tool is the database query instruction. After the data acquisition tool is triggered, the corresponding connector is loaded according to the type of the database to establish a connection with the database through the connector; the database query instruction is executed to query the target data from the database; and after the target data is processed by paging, sorting, and format conversion (including but not limited to JSON array or CSV file format, etc.), the final target data is obtained.

[0061] ​​​In summary, the embodiment presents a result viewing link on the client, and the complete target data is obtained after detecting the result viewing link, which can reduce the dialogue context load, avoid the problems of token redundancy, slow dialogue response speed, and exceeding the upper limit of the dialogue box, meet the user's verification demand for data query results, and improve the data delivery experience.

[0062] As an optional embodiment, after calling the database query instruction based on the instruction identifier to initiate the data query request and obtaining the target data, the method further includes: selecting preview data from the target data; generating a preview pop-up window for displaying the preview data, and displaying the preview pop-up window on the client; the preview pop-up window includes a trigger node for indicating to query complete data; if the trigger node is triggered, the target data is returned to the client.

[0063] In the embodiment, a bidirectional data delivery scheme of target data preview and on-demand downloading of complete data is further designed. Specifically, after calling the database query instruction based on the instruction identifier to initiate the data query request and obtaining the target data, the preview data is first selected from the target data. For example, a preset number of data with high ranking is obtained from the target data as the preview data. Then, a preview pop-up window for displaying the preview data is rendered, and the preview pop-up window includes a trigger node for indicating to query complete data. The trigger node can be presented in the form of a function option of “downloading complete data”, which is not particularly limited in the embodiment. The preview pop-up window is displayed on the client to allow the user to verify whether the preview data meets the demand.

[0064] When the user determines that the preview data meets the demand, the trigger node is triggered. If it is detected that the trigger node is triggered, the complete target data is returned to the client, and the user can download the complete target data in common formats such as CSV, Excel, and JSON, thereby realizing an efficient data delivery scheme of “verifying first and then obtaining”.

[0065] Please refer to Figure 7 , Figure 7 for a preview pop-up window schematic diagram provided by the present application. After obtaining the target data, the preview data is displayed on the client through the preview pop-up window shown in Figure 7 . After the user confirms that the preview data meets the demand, the user can download the complete target data by clicking the “download” option provided on the preview pop-up window.

[0066] In summary, the application balances data delivery efficiency and data delivery integrity by presenting a result viewing link, previewing data in a preview pop-up window, and viewing complete data.

[0067] As an optional embodiment, in the process of triggering the tool execution units corresponding to the nodes to perform the corresponding operations in sequence, the method further comprises: determining whether the current tool execution unit performs successfully; if not, triggering the current tool execution unit again every preset time interval, and if the number of times of triggering again does not reach a preset number of times, entering the step of determining whether the current tool execution unit performs successfully, and if the number of times reaches the preset number of times, ending; if yes, triggering the tool execution units corresponding to the directly downstream nodes to perform the corresponding operations.

[0068] In the embodiment, in the process of specifying the corresponding operations by the tool execution units, it is further determined whether the current tool execution unit performs successfully. The judgment standard for successful execution can be set according to actual needs, for example, whether an execution result is obtained within a specified time interval after triggering the tool execution unit.

[0069] For the current tool execution unit that fails to execute, a retry mechanism is supported. Specifically, if it is determined that the current tool execution unit fails to execute, the current tool execution unit is triggered again every preset time interval, and the number of times of triggering again is determined. If the number of times of triggering again does not reach a preset number of times, the step of determining whether the current tool execution unit performs successfully is entered again. If the number of times of triggering again reaches the preset number of times, the retry is ended. The preset time interval and the preset number of times can be set according to actual needs, and the application does not make special limitations thereon.

[0070] For the current tool execution unit that successfully executes, the tool execution units corresponding to the directly downstream nodes are triggered to perform the corresponding operations according to the topological order of the directed acyclic graph. For the case where there are multiple directly downstream nodes, since the directly downstream nodes are triggered synchronously, the tool execution units corresponding to the directly downstream nodes can perform the corresponding operations in parallel, thereby improving the efficiency of data query. As shown in FIG. 5, if the currently triggered node is node 2, after the current tool execution unit corresponding to node 2 successfully executes, node 5 and node 7 are triggered at the same time, so that the tool execution units corresponding to node 5 and node 7 perform the corresponding operations in parallel, thereby improving the efficiency of data query. Figure 2

[0071] ​In summary, in the embodiment, whether the corresponding operation is successfully executed is detected in the process that the tool execution unit specifies the operation, limited number of retries is supported for the unit that fails to execute, so as to ensure the realizability and reliability of the generated data query instruction.

[0072] The specific implementation of constructing the directed acyclic graph according to the data query information will be described below.

[0073] As an optional embodiment, the directed acyclic graph is constructed according to the data query information input by the user, and the method comprises the following steps: The second large model is constructed in advance, the tool information library is called, the task description information for constructing the directed acyclic graph is generated based on the data query information, the tool information library is used for storing tool information of initial tools, and the tool information at least comprises tool identification, input parameter structure information, output parameter structure information, a function body, meta information and tool dependency relationship; the meta information at least comprises function description information of the initial tools; and the tool dependency relationship is used for representing data dependency relationship between the current initial tool and other initial tools. The specified workflow orchestration framework is used to construct the directed acyclic graph according to the task description information, and the edge between adjacent nodes in the directed acyclic graph represents the dependency relationship between adjacent tool execution units.

[0074] In the embodiment, the initial tools for generating the database query instruction are constructed in advance. For example, a query tool for querying meta information of a data entity, a tool for generating a data filtering instruction, a tool for generating a final database query instruction, and the like. The initial tools will be introduced in subsequent embodiments, and will not be described here.

[0075] Please refer to Figure 8 , Figure 8 A tool information diagram corresponding to an initial tool provided in the application is shown. Each initial tool corresponds to its own tool information, and the tool information at least comprises tool identification, input parameter structure information, output parameter structure information, a function body, meta information and tool dependency relationship. The tool information of each initial tool is stored in the tool information library.

[0076] The tool identifier can be a tool name of the initial tool. The input parameter structure information includes input parameters required for calling the initial tool, data types of the input parameters, and description information for characterizing the meanings of the input parameters, etc. The output parameter structure information includes output parameters obtained after the initial tool performs the corresponding operation, data types of the output parameters, and description information for characterizing the meanings of the output parameters, etc. The function body is a specific business implementation of the tool, and can be a code, a function, or a service for performing a specified operation, etc. The meta information at least includes function description information of the initial tool, so that the second large model understands the function of the initial tool, determines whether the initial tool needs to be called to generate the data query instruction, and determines the timing of calling the initial tool. The tool dependency relationship is used to represent the data dependency relationship between the current initial tool and other initial tools, so as to facilitate the determination of whether other initial tools need to be called by the second large model.

[0077] When constructing the directed acyclic graph, the second large model first performs semantic understanding on the data query information, identifies the data query intent, and disassembles the data query intent into multiple data query steps. Then, the tool information library is called to obtain tool information of each initial tool to understand the functions of each initial tool, determine target tools required to complete the above data query steps, and generate task description information for constructing the directed acyclic graph. The task description information at least includes the following key information: target tools called to implement each data query step, input parameter structure information of each target tool, output parameter structure information, and conditional branch information generated according to the tool dependency relationship, etc.

[0078] The specified workflow orchestration framework constructs the directed acyclic graph according to the above task description information. The embodiment does not particularly limit the specific process of the specified workflow orchestration framework for constructing the directed acyclic graph. For example, according to the target tools called to implement each data query step, nodes of the directed acyclic graph are created; according to the input parameter structure information and the output parameter structure information of each target tool, input parameters and execution results of tool execution units corresponding to each node in the directed acyclic graph are specified, so as to facilitate data transmission between the tool execution units; and according to the conditional branch information, parallel nodes in the directed acyclic graph are determined, and directed edges between the nodes are determined.

[0079] In addition, the embodiment does not particularly limit the specific type of the specified workflow orchestration framework, for example, LangGraph, Apache Airflow, and Dagster, etc. The specific type can be selected according to the implementation requirements.

[0080] In summary, in the embodiment, the reasoning capability of the second large model is used to convert the data query information input by the user into task description information; and the specified workflow orchestration framework is used to generate a reliable directed acyclic graph according to the task description information, so as to complete the rapid construction of the directed acyclic graph.

[0081] The following describes the pre-constructed initial tools.

[0082] As an optional embodiment, the initial tools include a meta information query tool, a filter instruction generation tool, a query instruction generation tool, and an instruction verification tool. The meta information query tool is configured to query meta information of a data entity in the data query information. The filter instruction generation tool is configured to obtain filter conditions extracted from the data query information and logical relationships between the filter conditions; generate initial filter instructions according to the filter conditions; and combine the initial filter instructions according to the logical relationships to generate data filter instructions. The query instruction generation tool is configured to generate a database query instruction based on the obtained data query information, meta information, and data filter instructions. The instruction verification tool is configured to perform syntax verification on the obtained database query instruction and determine a final database query instruction based on a result of the syntax verification.

[0083] As described above, the second large model for constructing a directed acyclic graph splits the data query information input by a user into multiple data query steps and selects target tools required to implement the data query steps from the initial tools. In this embodiment, the pre-constructed initial tools include a meta information query tool, a filter instruction generation tool, a query instruction generation tool, and an instruction verification tool, which are described in detail as follows.

[0084] The meta information query tool is configured to query meta information of a data entity to establish complete data awareness in an early stage of data query, improve data discoverability and understandability, and lay a foundation for subsequent data query. The data entity is a data entity extracted from the data query information. The meta information query tool can query the meta information of the data entity from a meta database, which is a pre-constructed database for storing meta information of data entities in a database.

[0085] On this basis, the meta information query tool can be further divided into an upstream and downstream information query tool, a business information query tool, a table structure information query tool, and an access information query tool according to different meta information.

[0086] The upstream and downstream information query tool is configured to query upstream data entities (representing data sources of the data entity) and downstream data entities (representing data destinations of the data entity) of the data entity, thereby clarifying the data flow link of the data entity. As described above, the upstream and downstream information query tool can query the upstream data entities and the downstream data entities from the meta database and output the upstream and downstream data entities after sorting according to update frequencies of the upstream and downstream data entities in a specified time period.

[0087] The business information query tool is used to query the business information of the data entity, reflecting the business background of the data entity. The business information includes the business domain to which the data entity belongs, the entity business description information used to describe the business meaning of the target data entity, the field business description information used to describe the business meaning of each field in the target data entity, and the information such as the person in charge of the data entity. The business information query tool can also query the business information through the meta database, for example, first querying the business domain, the entity business description information, and the basic business information such as the person in charge from the meta database; then determining the field business dictionary table corresponding to the data entity, the field business dictionary table being used to record the field business description information corresponding to each field in the data entity; and querying the field business description information corresponding to each field in the data entity from the field business dictionary table.

[0088] The table structure information query tool is used to query the table structure information of the data entity, and can support the verification of the syntax rationality of the data query instruction. The table structure information includes at least one of the name of the database to which the target data entity belongs, the storage engine, the character set, and the field meta information list; and the field meta information list at least includes the field name and the data type of each field in the target data entity.

[0089] The access information query tool is used to query the access information of the data entity, so as to clarify the accessibility of the data entity. The access information includes the access permission of the target data entity, and the access times of the target data entity in a specified time period, the access peak time period, and the like.

[0090] The filter instruction generation tool is used to obtain the filter conditions extracted from the data query information and the logical relationship (for example, AND or OR) between the filter conditions; generate an initial filter instruction according to the filter field name, the filter value, and the filter operator in the filter condition; and combine each initial filter instruction according to the logical relationship to generate a final data filter instruction, for example, the WHERE statement in the structured query language.

[0091] The query instruction generation tool is used to generate a database query instruction based on the obtained data query information, the meta information, and the data filter instruction. The specific generation process of the database query instruction is not particularly limited in the embodiment. For example, the query instruction generation tool extracts the data entity and the attribute field from the data query information, so as to determine the data query object; combines the meta information to verify the legality of the data query object; and constructs a complete database query instruction based on the data entity, the attribute field, and the data filter instruction after the legality verification, according to the specified database query language template.

[0092] The instruction checking tool is configured to perform syntax checking on the obtained database query instruction, and determine a final database query instruction based on a result of the syntax checking. The specific manner of the syntax checking is not particularly limited in the embodiment. In addition, the instruction checking tool can generate an error prompt information when the database query instruction fails the syntax checking, so as to timely adjust the database query instruction.

[0093] In summary, the embodiment pre-constructs each initial tool, lays a foundation for subsequent construction of a directed acyclic graph, and gradually generates a database query instruction according to the directed acyclic graph, and has significant advantages in flexibility, maintainability, reusability, and visualization of the generated instruction.

[0094] The application further provides an electronic device, comprising: a memory configured to store a computer program; a processor configured to execute the computer program to implement the steps of the data query method of any one of the above.

[0095] For detailed introduction of the electronic device provided by the application, please refer to the embodiments of the data query method described above, which will not be repeated here.

[0096] The application further provides a storage medium, and the storage medium stores a computer program. When the computer program is executed by a processor, the steps of the data query method of any one of the above are implemented.

[0097] The storage medium includes all forms of non-volatile memory, media and memory devices, such as semiconductor memory devices (e.g., EPROM, EEPROM, and flash memory devices), magnetic disks (e.g., internal hard disks or removable disks), magneto-optical disks, and CD ROM and DVD-ROM disks.

[0098] For detailed introduction of the storage medium provided by the application, please refer to the embodiments of the data query method described above, which will not be repeated here.

[0099] Although this specification contains many specific implementation details, these should not be construed as limiting the scope or the range of any invention, but merely as describing features that are specific to certain embodiments. Some of the features described in the specification in the context of separate embodiments can also be implemented in combination in a single embodiment. Conversely, various features that are described in the context of a single embodiment can also be implemented or practiced separately or in any suitable sub-combination. Moreover, although features can be described above as acting in certain combinations and even initially claimed as such, one or more features from a claimed combination can in some cases be excised from the combination and the claimed combination can be directed to a sub-combination or variation of a sub-combination.

[0100] Similarly, while operations are depicted in the drawings in a particular order, this should not be understood as requiring such an order, or that all illustrated operations be performed, to accomplish the desired results. In certain circumstances, multitasking and parallel processing can be advantageous. Moreover, the separation of various system modules and components in the embodiments described above should not be understood as requiring such separation in all embodiments, and it should be understood that the described program components and systems can generally be integrated together in a single software product or packaged into multiple software products.

Claims

1. A data query method, characterized in that, The method includes: Based on the data query information input by the user, a directed acyclic graph is constructed; the nodes of the directed acyclic graph correspond to tool execution units; According to the topological order of the directed acyclic graph, the tool execution unit corresponding to each node is triggered to perform the corresponding operation in sequence until the tool execution unit corresponding to the last node performs the corresponding operation, and then the database query instruction is obtained. Before each of the tool execution units performs its corresponding operation, the input parameters of the current tool execution unit are validated so as to obtain the target input parameters of the current tool execution unit based on the validation result. After each of the tool execution units performs its corresponding operation, specified information is returned to the client; the specified information includes at least one of the following: the tool identifier of the tool invoked to perform the corresponding operation, the target input parameters, and the execution result obtained after performing the corresponding operation. The target data is retrieved from the database based on the database query command.

2. The data query method as described in claim 1, characterized in that, Before constructing the directed acyclic graph based on the data input by the user, the following steps are also included: Using a pre-built first large model, the data query information is subjected to specified validation of query elements; the specified validation includes at least one of missing data validation and ambiguity validation; the query elements include at least one of data entities, attribute fields, and data filtering conditions; If the result of the specified verification indicates that the data query information is missing the query element, then a prompt message is generated to suggest supplementing the missing query element. If the result of the specified verification indicates that there are ambiguous query elements in the data query information, then a prompt message is generated to prompt for correction of the ambiguous query elements. The prompt information is returned to the client to obtain new data query information, and then the process proceeds to the step of constructing a directed acyclic graph based on the data query information input by the user.

3. The data query method as described in claim 1, characterized in that, The step of validating the input parameters of the current tool execution unit, so as to obtain the target input parameters of the current tool execution unit based on the validation result, includes: Based on a pre-built mapping relationship, the target input parameter verification conditions of the current tool execution unit are determined; the mapping relationship is the correspondence between the tool execution unit and the input parameter verification conditions. Determine whether the input parameters meet the target input parameter verification conditions; If satisfied, the input parameters are used as the target input parameters; If the condition is not met, a correction prompt is generated to prompt for correction of the input parameters; the correction prompt is returned to the client to obtain the user-inputted input parameter correction information; and the input parameter correction information is used as the target input parameter.

4. The data query method as described in claim 1, characterized in that, The step of retrieving target data from the database based on the database query instruction includes: Generate a unique instruction identifier for the database query instruction; Generate a result viewing link containing the instruction identifier, and return the result viewing link to the client; If the result viewing link is triggered, the database query instruction is invoked based on the instruction identifier to initiate a data query request and obtain the target data.

5. The data query method as described in claim 4, characterized in that, After invoking the database query instruction based on the instruction identifier to initiate a data query request and obtain the target data, the method further includes: Select preview data from the target data; A preview pop-up window is generated to display the preview data, and the preview pop-up window is displayed on the client; the preview pop-up window includes a trigger node for indicating that the complete data can be queried. If the trigger node is triggered, the target data will be returned to the client.

6. The data query method as described in claim 1, characterized in that, The step of querying information based on user-input data and constructing a directed acyclic graph includes: Using a pre-built second model, a tool information repository is invoked, and task description information for constructing the directed acyclic graph is generated based on the data query information. The tool information repository stores tool information for the initial tools. This tool information includes at least a tool identifier, input parameter structure information, output parameter structure information, functional body, meta-information, and tool dependencies. The meta-information includes at least a functional description of the initial tool. The tool dependencies characterize the data dependencies between the current initial tool and other initial tools. Using a specified workflow orchestration framework, the directed acyclic graph is constructed according to the task description information; the edges between adjacent nodes in the directed acyclic graph represent the dependencies between adjacent tool execution units.

7. The data query method as described in claim 6, characterized in that, The initial tools include a metadata query tool, a filter instruction generation tool, a query instruction generation tool, and an instruction verification tool; The metadata query tool is used to query the metadata of data entities in the data query information; The filtering instruction generation tool is used to obtain the filtering conditions extracted from the data query information and the logical relationships between the filtering conditions. Generate initial filtering instructions based on the filtering conditions; The initial filtering instructions are combined according to the logical relationship to generate data filtering instructions; The query instruction generation tool is used to generate the database query instruction based on the obtained data query information, the metadata, and the data filtering instruction; The instruction verification tool is used to perform syntax verification on the obtained database query instructions, and determine the final database query instructions based on the results of the syntax verification.

8. The data query method as described in claim 1, characterized in that, During the process of sequentially triggering the tool execution unit corresponding to each of the nodes to perform the corresponding operation, the method further includes: Determine whether the current tool execution unit has executed successfully; If it fails, the current tool execution unit will be retried at preset intervals; if the number of retried attempts does not reach the preset number, the process will proceed to the step of determining whether the current tool execution unit has executed successfully; if the number of attempts reaches the preset number, the process will end. If successful, the tool execution unit corresponding to the direct downstream node will be triggered to perform the corresponding operation.

9. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor, configured to implement the steps of the data query method as described in any one of claims 1 to 8 when executing the computer program.

10. A storage medium, characterized in that, The storage medium stores a computer program, which, when executed by a processor, implements the steps of the data query method as described in any one of claims 1 to 8.

Citation Information

Patent Citations

  • SQL (Structured Query Language) statement generation method and device, equipment, storage medium and product

    CN119691008A

  • Data query method and device, equipment, storage medium and program product

    CN120780724A

  • Enterprise number asking system and method based on combination of large language model and NL2SQL

    CN121166718A