Data query method, system and device

By analyzing and displaying key elements in SQL query statements, a visual query feedback interface is provided, which solves the inefficiency and accuracy problems caused by SQL query complexity, and improves the ability of users to independently verify query results.

CN119311747APending Publication Date: 2025-01-14HANGZHOU HIKVISION SYST TECH CO LTD

Patent Information

Application Number
CN202411847238.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-13
Publication Date
2025-01-14

AI Technical Summary

Technical Problem

The complex syntax and logic of the SQL query system make it difficult for users to construct correct query statements on their own, resulting in low query efficiency and inaccurate results, and it is difficult for users to verify the accuracy of query results.

Method used

By analyzing grouping, aggregation, sorting and filtering operators in SQL query statements, identifying key elements and displaying detailed query processes, providing a visual query feedback interface, allowing users to intuitively verify the accuracy of query results.

Benefits of technology

Improve the efficiency and accuracy of data query, and users can clearly understand the query process and verify the accuracy of the results, reducing their dependence on professional and technical personnel.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119311747A_ABST
    Figure CN119311747A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a data query method, system and device, and the method comprises the steps: analyzing a grouping operator, an aggregation operator, a sorting operator and a filtering operator in a first query statement, accurately recognizing key elements in a query operation, including a field of a grouping basis, a field and type of an aggregation operation, a field of a sorting basis and an arrangement sequence, according to the method, the key elements in the query operation and the fields and specific conditions related to the filtering conditions are obtained, and the interface containing the detailed key elements in the query operation and the query result is displayed after the query result is obtained based on the key elements in the query operation, so that a user can intuitively see the whole process of the query operation, including specific details of grouping, aggregation, sorting and filtering, and the user experience is improved. Therefore, whether the query result meets own requirements can be verified more easily. The visual query feedback mechanism not only enables the user to clearly see the query result, but also can deeply understand the query process, so that the accuracy of the query result is effectively verified, and the efficiency and accuracy of data query are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of data analysis, and in particular to a data query method, system and device. Background Art

[0002] SQL (Structured Query Language) is a database query language. Although SQL query systems based on SQL provide data retrieval capabilities, its syntax and logic may be complex and abstract for non-professional technicians. When users try to construct SQL query statements by themselves, they often fail to create them correctly due to unfamiliarity with professional domain knowledge, database structure or SQL syntax, which not only reduces query efficiency, but may also lead to inaccurate query results or complete failure to obtain the required data.

[0003] To solve this problem, users often need to rely on people with professional technical backgrounds, such as database administrators or data analysts, to assist them in completing SQL queries. With their in-depth understanding of database structure, data model, and SQL language, these professional technicians can write corresponding SQL query statements based on the user's description and needs. However, there are problems of information asymmetry and communication barriers in this process.

[0004] On the one hand, when describing their needs, users may not be able to accurately convey the data content and format they really want to query due to lack of professional terminology or limited expression ability. On the other hand, when writing SQL query statements, professional technicians may also write query statements that do not meet user expectations due to misunderstanding of user needs or unfamiliarity with data background. This information asymmetry may cause deviations between query results and actual user needs, or even completely inconsistent. In this process, users need to communicate with professional technicians many times to write query statements and obtain query results based on the query statements, resulting in low data query efficiency and inaccurate query results.

[0005] In addition, even if the SQL query statements written by professional technicians are syntactically correct and can be successfully executed in the database, it is still difficult for users to directly verify whether the query results fully meet their needs, that is, it is impossible to verify the accuracy of the query results. Summary of the invention

[0006] The purpose of the embodiments of the present application is to provide a data query method, system and device to verify the accuracy of the query results and improve the efficiency and accuracy of the data query. The specific technical solution is as follows:

[0007] In a first aspect, an embodiment of the present application provides a data query method, the method comprising:

[0008] Obtaining a first query statement input for a preset data table, and parsing to obtain a grouping operator, an aggregation operator, a sorting operator, and a filtering operator included in the first query statement;

[0009] For the grouping operator obtained by parsing, determine, from the fields included in the preset data table, a field used as a grouping basis in the grouping operation represented by the grouping operator as a first field;

[0010] For the aggregation operator obtained by parsing, determine, from the fields included in the preset data table, the field aggregated in the aggregation operation represented by the aggregation operator as the second field; and determine the type of the aggregation operation as the first type;

[0011] For the sorting operator obtained by the analysis, determine, among the fields included in the preset data table, a field used as a sorting basis in the sorting operation represented by the sorting operator as a third field; and determine an arrangement order in the sorting operation as a first arrangement order;

[0012] For the filter operator obtained by the analysis, among the fields included in the preset data table, a field used for judging whether the filter condition is satisfied in the filter operation represented by the filter operator is determined as a fourth field; and the filter condition used in the filter operation is determined as a first filter condition;

[0013] Obtaining a first query result obtained by querying the preset data table in a first query manner, wherein the first query manner is a query manner represented by the first query statement;

[0014] A first display interface is displayed, wherein the first display interface displays the first query result, and correspondingly displays the first information for indicating grouping, the first field, and correspondingly displays the second information for indicating aggregation, the second field, and the first type, and correspondingly displays the third information for indicating sorting, the third field, and the first arrangement order, and correspondingly displays the fourth information for indicating filtering, the fourth field, and the first filtering condition.

[0015] In a possible implementation, the method further includes:

[0016] In response to an add operation input to the first display interface, determining a target operator indicated by the add operation;

[0017] Obtaining a second query result obtained by querying the preset data table according to a second query method, wherein the second query method is a query method formed by adding a target operation on the basis of the first query method, and the target operation is an operation represented by the target operator;

[0018] A second display interface is displayed, wherein the result display interface displays the second query result, and when the target operator is the grouping operator, the second display interface also displays the first information and the fifth field, and the fifth field is the field used as the basis for grouping in the grouping operation represented by the target operator; when the target operator is the aggregation operator, the second display interface also displays the second information, the second field, the first type, the sixth field and the second type, and the sixth field is the field aggregated in the aggregation operation represented by the target operator, and the second type is the type of the aggregation operation represented by the target operator; when the target operator is the sorting operator, the second The display interface also displays the third information, the third field, the first arrangement order, the sixth field and the second arrangement order accordingly, the sixth field is the field used as the sorting basis in the sorting operation represented by the target operator, and the second arrangement order is the arrangement order in the sorting operation represented by the target operator; when the target operator is the filtering operator, the second display interface also displays the fourth information, the fourth field, the first filtering condition, the seventh field and the second filtering condition accordingly, the seventh field is the field used to determine whether the filtering condition is met in the filtering operation represented by the target operator, and the second filtering condition is the filtering condition used in the filtering operation represented by the target operator.

[0019] In a possible implementation manner, the first display interface further displays an add control;

[0020] In response to a trigger operation for the adding control, displaying a third display interface, wherein the third display interface includes all fields included in the preset data table;

[0021] In response to a first selection operation inputted to the third display interface, determining a field indicated by the first selection operation; and displaying a fourth display interface, wherein the fourth display interface includes at least one preset function;

[0022] The step of determining, in response to an add operation input to the first display interface, a target operator indicated by the add operation includes:

[0023] In response to a second selection operation inputted on the fourth display interface, determining a function indicated by the second selection operation;

[0024] According to the determined function and field, an operator for executing the function on the field is determined.

[0025] In a possible implementation, the second query result is obtained by querying in the following manner, including:

[0026] Generate a first syntax tree for representing the first query mode according to the first query statement, wherein the first syntax tree includes a plurality of nodes, each node corresponding to each step in the process of executing the first query statement;

[0027] In the first syntax tree, determine a node whose operation type is the same as the operation type represented by the target operator as the target node;

[0028] In the first syntax tree, adding the operation represented by the target operator to the operation represented by the target node to obtain a second syntax tree;

[0029] Starting from the root node of the second syntax tree, each node of the first syntax tree is traversed to obtain a second query result.

[0030] In a possible implementation, the obtaining a first query result obtained by querying the preset data table in a first query manner includes:

[0031] Sending the first query statement and the empty operator list to a preset query device, so that the preset query device determines and executes a first query mode represented by the first query statement in response to the operator list being empty, obtains a first query result and feeds back the result;

[0032] Receive a first query result fed back by the preset query device;

[0033] The obtaining of a second query result obtained by querying the preset data table in a second query manner includes:

[0034] The first query statement and the operator list for recording the target operator are sent to a preset query device, so that the preset query device determines the first query mode represented by the first query statement and the operation represented by the target operator recorded in the operator list in response to the operator list being not empty, and adds the target operation on the basis of the first query mode, obtains the second query mode and executes it, obtains the second query result and feeds back;

[0035] Receive a second query result fed back by the preset query device.

[0036] In a second aspect, an embodiment of the present application provides a data query system, the system comprising a platform device and a preset query device:

[0037] The platform device is used to obtain a first query statement input for a preset data table, and parse the grouping operator, aggregation operator, sorting operator and filtering operator included in the first query statement; for the grouping operator obtained by the analysis, determine the field used as the grouping basis in the grouping operation represented by the grouping operator in the fields included in the preset data table as the first field; for the aggregation operator obtained by the analysis, determine the field aggregated in the aggregation operation represented by the aggregation operator in the fields included in the preset data table as the second field; and determine the type of the aggregation operation as the first type; for the sorting operator obtained by the analysis, determine the field used as the sorting basis in the sorting operation represented by the sorting operator in the fields included in the preset data table as the third field; and determine the arrangement order in the sorting operation as the first arrangement order; for the filtering operator obtained by the analysis, determine the field used as the sorting basis in the sorting operation represented by the sorting operator in the fields included in the preset data table as the third field; and determine the arrangement order in the sorting operation as the first arrangement order. , determine the field used to judge whether the filtering condition is satisfied in the filtering operation represented by the filtering operator as the fourth field; and determine the filtering condition used in the filtering operation as the first filtering condition; send the first query statement to the preset query device; obtain the first query result obtained by querying the preset data table according to the first query method, wherein the first query method is the query method represented by the first query statement; display a first display interface, wherein the first display interface displays the first query result, and correspondingly displays the first information for indicating grouping and the first field, and correspondingly displays the second information for indicating aggregation, the second field and the first type, and correspondingly displays the third information for indicating sorting, the third field and the first arrangement order, and correspondingly displays the fourth information for indicating filtering, the fourth field and the first filtering condition;

[0038] The preset query device is used to query the preset data table according to the first query statement sent by the platform device to obtain the first query result and feed back.

[0039] In a third aspect, an embodiment of the present application provides a data query device, the device comprising:

[0040] A first acquisition module, used to acquire a first query statement input for a preset data table, and parse to obtain a grouping operator, an aggregation operator, a sorting operator, and a filtering operator included in the first query statement;

[0041] A first parsing module is used to determine, for the parsed grouping operator, a field used as a grouping basis in the grouping operation represented by the grouping operator from among the fields included in the preset data table, as a first field;

[0042] A second parsing module is used to determine, for the parsed aggregation operator, from the fields included in the preset data table, the field aggregated in the aggregation operation represented by the aggregation operator as the second field; and determine the type of the aggregation operation as the first type;

[0043] A third parsing module is used to determine, for the parsed sorting operator, from the fields included in the preset data table, a field used as a sorting basis in the sorting operation represented by the sorting operator as a third field; and determine an arrangement order in the sorting operation as a first arrangement order;

[0044] A fourth parsing module is used to determine, for the filter operator obtained by the analysis, a field in the fields included in the preset data table, which is used to judge whether the filter condition is satisfied in the filter operation represented by the filter operator as a fourth field; and determine the filter condition used in the filter operation as the first filter condition;

[0045] A second acquisition module, configured to acquire a first query result obtained by querying the preset data table in a first query manner, wherein the first query manner is a query manner represented by the first query statement;

[0046] A first display module is used to display a first display interface, wherein the first display interface displays the first query result, and correspondingly displays the first information for indicating grouping, the first field, and correspondingly displays the second information for indicating aggregation, the second field, and the first type, and correspondingly displays the third information for indicating sorting, the third field, and the first arrangement order, and correspondingly displays the fourth information for indicating filtering, the fourth field, and the first filtering condition.

[0047] In a possible implementation, the device further includes:

[0048] A first response module, configured to respond to an add operation input to the first display interface and determine a target operator indicated by the add operation;

[0049] A third acquisition module is used to obtain a second query result obtained by querying the preset data table according to a second query method, wherein the second query method is a query method formed by adding a target operation on the basis of the first query method, and the target operation is an operation represented by the target operator;

[0050] a second display module, for displaying a second display interface, wherein the second display interface displays the second query result, and when the target operator is the grouping operator, the second display interface also displays the first information and the fifth field, and the fifth field is the field used as the basis for grouping in the grouping operation represented by the target operator; when the target operator is the aggregation operator, the second display interface also displays the second information, the second field, the first type, the sixth field and the second type, and the sixth field is the field aggregated in the aggregation operation represented by the target operator, and the second type is the type of the aggregation operation represented by the target operator; when the target operator is the sorting operator, The second display interface also displays the third information, the third field, the first arrangement order, the sixth field and the second arrangement order, the sixth field is the field used as the sorting basis in the sorting operation represented by the target operator, and the second arrangement order is the arrangement order in the sorting operation represented by the target operator; when the target operator is the filtering operator, the second display interface also displays the fourth information, the fourth field, the first filtering condition, the seventh field and the second filtering condition, the seventh field is the field used to determine whether the filtering condition is met in the filtering operation represented by the target operator, and the second filtering condition is the filtering condition used in the filtering operation represented by the target operator.

[0051] In a possible implementation manner, the first display interface further displays an add control;

[0052] A third display module, configured to display a third display interface in response to a trigger operation on the adding control, wherein the third display interface includes all fields included in the preset data table;

[0053] a second response module, configured to respond to a first selection operation inputted to the third display interface, determine a field indicated by the first selection operation; and display a fourth display interface, wherein the fourth display interface includes at least one preset function;

[0054] The first response module includes:

[0055] A first response submodule, configured to respond to a second selection operation inputted to the fourth display interface and determine a function indicated by the second selection operation;

[0056] The response second submodule is used to determine an operator for executing the function on the field according to the determined function and field.

[0057] In a possible implementation, the second query result is obtained by querying in the following manner, including:

[0058] Generate a first syntax tree for representing the first query mode according to the first query statement, wherein the first syntax tree includes a plurality of nodes, each node corresponding to each step in the process of executing the first query statement;

[0059] In the first syntax tree, determine a node whose operation type is the same as the operation type represented by the target operator as the target node;

[0060] In the first syntax tree, adding the operation represented by the target operator to the operation represented by the target node to obtain a second syntax tree;

[0061] Starting from the root node of the second syntax tree, each node of the second syntax tree is traversed to obtain a second query result.

[0062] In a possible implementation manner, the second acquisition module includes:

[0063] Obtain a first submodule, which is used to send the first query statement and an empty operator list to a preset query device, so that the preset query device determines and executes a first query mode represented by the first query statement in response to the operator list being empty, obtains a first query result and feeds back the result;

[0064] Obtain a second submodule, which is used to receive the first query result fed back by the preset query device;

[0065] The third acquisition module includes:

[0066] Obtain a third submodule, which is used to send the first query statement and the operator list for recording the target operator to a preset query device, so that the preset query device determines the first query mode represented by the first query statement and the operation represented by the target operator recorded in the operator list in response to the operator list being not empty, and adds the target operation on the basis of the first query mode, obtains and executes the second query mode, obtains and feeds back the second query result;

[0067] The fourth submodule is obtained, which is used to receive the second query result fed back by the preset query device.

[0068] In a fourth aspect, an embodiment of the present application provides an electronic device, including:

[0069] Memory, used to store computer programs;

[0070] The processor is used to implement any of the above-mentioned data query methods when executing the program stored in the memory.

[0071] In a fifth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, any of the above-mentioned data query methods is implemented.

[0072] In a sixth aspect, an embodiment of the present application provides an embodiment of the present application further provides a computer program product comprising instructions, which, when executed on a computer, enables the computer to execute any of the above-described data query methods.

[0073] Beneficial effects of the embodiments of the present application:

[0074] The data query method, system and device provided in the embodiment of the present application accurately identify the key elements in the query operation, including the fields for grouping, the fields and types of aggregation operations, the fields for sorting and the order of arrangement, and the fields and specific conditions involved in the filtering conditions, by parsing the grouping operator, aggregation operator, sorting operator and filtering operator in the first query statement, and after obtaining the query results based on the key elements in the query operation, display an interface containing detailed key elements and query results in the query operation, so that users can intuitively see the entire process of the query operation, including the specific details of grouping, aggregation, sorting and filtering, so that it is easier to verify whether the query results meet their own needs. This visual query feedback mechanism not only enables users to clearly see the query results, but also deeply understand the query process, thereby effectively verifying the accuracy of the query results and improving the efficiency and accuracy of data queries.

[0075] Of course, implementing any product or method of the present application does not necessarily require achieving all of the advantages described above at the same time. BRIEF DESCRIPTION OF THE DRAWINGS

[0076] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application, and for ordinary technicians in this field, other embodiments can also be obtained based on these drawings.

[0077] Figure 1 A first flow chart of a data query method provided in an embodiment of the present application;

[0078] Figure 2 A schematic diagram of the structure of a data query system provided in an embodiment of the present application;

[0079] Figure 3 A first schematic diagram of a first display interface provided in an embodiment of the present application;

[0080] Figure 4A second schematic diagram of the first display interface provided in an embodiment of the present application;

[0081] Figure 5 A second flow chart of the data query method provided in the embodiment of the present application;

[0082] Figure 6 A schematic diagram of a second display interface provided in an embodiment of the present application;

[0083] Figure 7 A schematic diagram of the process of adding an operator provided in an embodiment of the present application;

[0084] Figure 8 A first schematic diagram of adding an operator provided in an embodiment of the present application;

[0085] Fig. 9 A second schematic diagram of adding an operator provided in an embodiment of the present application;

[0086] Fig.10 A third schematic diagram of adding an operator provided in an embodiment of the present application;

[0087] Fig.11 A third flow chart of the data query method provided in the embodiment of the present application;

[0088] Fig.12 A fourth flow chart of the data query method provided in the embodiment of the present application;

[0089] Fig.13 A schematic diagram of the structure of a data query hardware device provided in an embodiment of the present application;

[0090] Fig.14 A fifth flow chart of the data query method provided in the embodiment of the present application;

[0091] Fig.15 A schematic diagram of a process for registering a custom function provided in an embodiment of the present application;

[0092] Fig.16 A schematic diagram of the flow of the injection operator provided in an embodiment of the present application;

[0093] Fig.17 A schematic diagram of the structure of a data query device provided in an embodiment of the present application;

[0094] Fig.18 A schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0095] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field based on the present application belong to the scope of protection of the present application.

[0096] In order to more clearly explain the data query method provided by this application, the relevant terms involved in this article are explained below:

[0097] SQL: The full name is Structured Query Language, which is a standard programming language specifically used to manage and operate databases. It allows users to perform operations such as querying, updating, and managing data.

[0098] SQL execution plan: After receiving the SQL query statement, the database management system will generate a detailed execution step based on the content of the SQL query statement. This step is called the SQL execution plan. The SQL execution plan is the core of guiding the database management system to perform data query, update and management operations, and determines the efficiency and performance of the query.

[0099] SQL operator: In SQL, SQL operator refers to a keyword or symbol used to perform specific operations. It is the basis for building complex SQL queries. Operators include but are not limited to aggregation functions, grouping, filtering, sorting, etc.

[0100] Syntax tree: A syntax tree is a tree-like data structure that parses the source code according to specific syntactic and lexical rules, obtains the parsing results, and represents the parsing results in the form of a tree.

[0101] ChatBI: ChatBI is a tool that combines chatbots and business intelligence (BI) technology. It uses natural language processing technology to enable users to interact with data through chat, thereby simplifying the complexity of data analysis.

[0102] NL2SQL: Natural Language to SQL, also known as Text2SQL, is an artificial intelligence technology that can understand and parse natural language text input by users. Natural language describes user needs. NL2SQL technology can automatically generate SQL query statements that meet user needs, thereby greatly simplifying the data query process.

[0103] NL2API: Natural Language to API, is a method for converting natural language text descriptions into API (Application Programming Interface, a set of definitions, programs and protocols) calls. It allows users to describe the operations they want to perform or the data they want to obtain in natural language, and then automatically converts these descriptions into corresponding API call requests.

[0104] Large Language Model (LLM) is a deep learning technology that aims to understand and generate natural language. It is trained on a large amount of text data and can perform a wide range of tasks such as text summarization, mixed text classification, open generation, etc. LLM has good generalization capabilities, and its common application scenarios include creating text content, searching, and code generation. In the field of data analysis, BI tools can also integrate NL2SQL or NL2API of large language models, launch products such as ChatBI, support users to enter natural language for data query, and greatly reduce the threshold for data query.

[0105] Taking a user question-and-answer interaction in the ChatBI system that supports NL2SQL as an example, assume that there is currently a data table with fields including course number, course name, student ID, student name, and student course score. The course number field includes numbers such as 1, 2, 3, 4, and 5. The course name field includes course names such as Chinese, mathematics, English, and geography. The student ID field includes student IDs such as 202411301, 202411302, and 202411303. The student name field includes names such as Xiao Ming, Xiao Hong, and Xiao Mei. The student course score field includes scores such as 99, 98, and 100. The name of the data table is class_detail (see Table 1 below for specific field information). The table fields in Table 1 (hereinafter referred to as fields) mean the field of course number, and the corresponding table field physical name is class_id (course number). The field means the field of course name, and the corresponding table field physical name is class_name (course name). The field means the field of student ID, and the corresponding table field physical name is student_id (student ID). The field means the field of student name, and the corresponding table field physical name is score (score).

[0106] At this time, the user enters the text "What is the name of the course with the most students enrolled?" The big model in the ChatBI system completes the reasoning and generates the SQL statement "SELECT class_name, COUNT(student_id) AS CNT FROM class_detail GROUP BY class_name ORDER BY CNT DESC LIMIT 1". After the ChatBI system executes this SQL statement, it returns the query results to the user. Table 1 is as follows:

[0107] In view of the above scenario, data query based on ChatBI system has the following two problems:

[0108] Problem 1: The calculation and analysis process of SQL statements has a certain understanding threshold. For users who are not familiar with SQL, the SQL statements on which the query results are based are not easy to understand and intuitive enough. Users cannot understand the query process and thus cannot verify whether the query results are correct.

[0109] Question 2: After obtaining the query results, if the user wants to query the query results again (i.e., secondary query), the user can only complete the secondary analysis by asking again or re-editing the SQL statement. The accuracy of the query results obtained by the former depends on the LLM capability, and the latter requires the user to have certain SQL knowledge, which has a certain threshold for users.

[0110] Based on this, the present application embodiment provides a data query method, see Figure 1 , Figure 1 A first flow chart of a data query method provided in an embodiment of the present application, the method comprising:

[0111] S101, obtaining a first query statement input for a preset data table, and parsing to obtain a grouping operator, an aggregation operator, a sorting operator, and a filtering operator included in the first query statement.

[0112] S102: for the grouping operator obtained by parsing, determine, from the fields included in the preset data table, a field used as a grouping basis in the grouping operation represented by the grouping operator as a first field.

[0113] S103, for the aggregation operator obtained by the analysis, determine, from the fields included in the preset data table, the field aggregated in the aggregation operation represented by the aggregation operator as the second field; and determine the type of the aggregation operation as the first type.

[0114] S104, for the sorting operator obtained by the analysis, determine the field used as the sorting basis in the sorting operation represented by the sorting operator from the fields included in the preset data table as the third field; and determine the sorting order in the sorting operation as the first sorting order.

[0115] S105, for the filter operator obtained by the analysis, determine, from the fields included in the preset data table, a field used to determine whether the filter condition is met in the filter operation represented by the filter operator as the fourth field; and determine the filter condition used in the filter operation as the first filter condition.

[0116] S106: Obtain a first query result obtained by querying a preset data table in a first query manner.

[0117] The first query method is a query method represented by a first query statement.

[0118] S107, displaying a first display interface.

[0119] Among them, the first display interface displays the first query result, and correspondingly displays the first information and the first field for indicating grouping, and correspondingly displays the second information, the second field and the first type for indicating aggregation, and correspondingly displays the third information, the third field and the first arrangement order for indicating sorting, and correspondingly displays the fourth information, the fourth field and the first filtering condition for indicating filtering.

[0120] By applying the above embodiment, by parsing the grouping operator, aggregation operator, sorting operator and filtering operator in the first query statement, the key elements in the query operation are accurately identified, including the field for grouping, the field and type of the aggregation operation, the field for sorting and the arrangement order, and the fields and specific conditions involved in the filtering conditions. After obtaining the query results based on the key elements in the query operation, an interface containing detailed key elements and query results in the query operation is displayed, and the user can intuitively see the entire process of the query operation, including the specific details of grouping, aggregation, sorting and filtering, so that it is easier to verify whether the query results meet their own needs. This visual query feedback mechanism not only enables users to clearly see the query results, but also deeply understand the query process, thereby effectively verifying the accuracy of the query results, improving the efficiency and accuracy of data queries, and solving the aforementioned problem one.

[0121] In order to more clearly explain the data query method, the following first describes the data query system for executing the data query method provided by the embodiment of the present application, see Figure 2 , Figure 2This is a structural diagram of a data query system provided in an embodiment of the present application. The data query system 200 includes a platform device 201 and a preset query device 202. A communication connection is established between the platform device 201 and the preset query device 202.

[0122] The platform device 201 is used to execute the aforementioned steps S101 to S107 , and send the first query statement to the preset query device 202 .

[0123] The preset query device 202 is used to query the preset data table according to the first query statement sent by the platform device 201 to obtain the first query result and feedback it.

[0124] The platform device is any device that supports user input of query statements and various instructions, including but not limited to smart phones, computers, etc. The preset query device is any device that can query the data table according to the query statement to obtain the query result, including but not limited to database servers, IoT devices, etc., which are not specifically limited here. In this article, supporting user input of query statements can be supporting users to directly input SQL query statements, or supporting users to input natural language text, and then the platform device generates SQL query statements based on the natural language text input by the user.

[0125] In step S101, the preset data table may be pre-stored in the platform device, may be pre-stored in the preset query device, or may be pre-stored in other devices except the platform device and the preset query device.

[0126] In the case where the preset data table is stored in the platform device, when the platform device sends the first query statement to the preset query device, it will also send the preset data table to the preset query device, so that the preset query device queries the preset data table based on the first query statement to obtain the first query result.

[0127] In the case where the preset data table is stored in the preset query device, when the user needs to perform a data query, the platform device can obtain the preset data table from the preset query device, and then input the first query statement based on the preset data table. When the query operation needs to be performed, the platform device does not need to send the preset data table additionally when sending the first query statement to the preset query device. The preset query device has already stored the required preset data table, so the preset query device can directly query the locally stored preset data table based on the received first query statement, thereby obtaining the first query result.

[0128] For the case where the preset data table is stored in other devices, that is, the data table is neither in the platform device nor in the preset query device, but is stored in an independent, remote or dedicated data storage device. When the user needs to query data, the platform device requests to obtain the preset data table from other devices, and then inputs the first query statement based on the preset data table. When the query operation needs to be performed, the preset query device can obtain the preset data table requested by the platform device from other devices before or after receiving the first query statement sent by the platform device, and the preset data table is the same as the preset data table obtained by the platform device. After obtaining the preset data table, the preset query device queries the preset data table based on the received first query statement to obtain the first query result.

[0129] Parsing the first query statement may obtain at least one of the grouping operator, aggregation operator, sorting operator and filtering operator, and may also obtain other operators except the grouping operator, aggregation operator, sorting operator and filtering operator, such as scanning operator, projection operator and the like.

[0130] In step S102 , a grouping operator is used to group data according to the value of a specific column so as to apply an aggregation operator to each group for summary calculation. The grouping operator includes a GROUP BY clause (grouping).

[0131] In the grouping operation, the field used as the basis for grouping is called the first field. The representation of the first field is not unique. It can be represented by the semantic name of the field (i.e., the meaning of the field) or by the physical name of the field (i.e., the physical name of the field). In addition, the first field can also be represented by any other information that can uniquely identify the field, such as the index number of the field, the alias of the field, etc. For example, taking the aforementioned Table 1 as an example, if the course number is used as the basis for grouping in the grouping operation, the first field can be represented by "course number", "class_id", or "course program number". In this article, there is no specific limitation on the specific representation of the first field, as long as it can accurately point to the field used as the basis for grouping.

[0132] In step S103, an aggregation operator is used to operate on a set of values ​​and aggregate them into one or more values, including a SUM clause (sum), an AVG clause (average), a MIN clause (minimum value), a MAX clause (maximum value), a COUNT clause (count), etc.

[0133] In the aggregation operation, the aggregated field is called the second field. The second field can be represented by any one of the field name, the physical name of the field, the index number of the field, and the field alias. The field name, the physical name of the field, the index number of the field, and the field alias have been explained in the previous text and will not be repeated here. The representation of the second field can be the same as the representation of the first field, or it can be different, and no specific limitation is made here. The first type is a specific type of aggregation operation, covering a variety of statistical and calculation methods, including but not limited to sum, average, minimum, maximum, count, etc. In practical applications, the aggregation operation can use any of the above types alone, or it can use multiple types in combination according to needs. Among them, the representation of the first type is diverse. It can use semantic descriptions with clear meanings, such as "sum", "average", etc., or it can use clause names or identifiers, such as "SUM", "AVG", etc., which are not specifically limited here.

[0134] In step S104, the sorting operator is used to sort a set of data, including an ORDER BY clause (sorting). Taking the sorting operator as an ORDER BY clause as an example, the ORDER BY clause can specify one or more columns as the basis for sorting, and at the same time specify the ascending and descending order of sorting, where ascending is ASC and descending is DESC. If not specified, the default is ascending. For example, in an SQL query, if the preset data includes two fields, name and phone number, we can use the ORDER BY clause to sort by name in ascending order or phone number in descending order.

[0135] In the sorting operation, the field used as the basis for sorting is called the third field. The third field can be represented by any one of the field name, the physical name of the field, the index number of the field, and the field alias. The field name, the physical name of the field, the index number of the field, and the field alias have been explained in the previous article and will not be repeated here. The representation of the third field can be the same as the representation of the first field and the second field, or it can be different, and no specific limitation is made here. The first arrangement order is the arrangement order in the sorting operation, that is, ascending or descending. The first arrangement order can be displayed in a variety of forms. Specifically, it can be a semantic description with a clear meaning, such as "ascending" and "descending", or it can be described using professional terms, such as "ASC" and "DESC", which are not specifically limited here.

[0136] In step S105 , the filtering operator is used to perform a screening operation on the aggregation result after the aggregation operator is executed, including HAVING (filtering).

[0137] In the filtering operation, the field used to determine whether the filtering condition is met is called the fourth field. The fourth field can be represented by any one of the field name, the physical name of the field, the index number of the field, and the field alias. The field name, the physical name of the field, the index number of the field, and the field alias have been explained in the previous text and will not be repeated here. The representation of the fourth field can be the same as the representation of the aforementioned first field, second field, and third field, or it can be different, and no specific limitation is made here. The first filtering condition is the filtering condition used in the filtering operation, that is, the filtering condition is a pre-set rule or standard based on filtering the fourth field. For example, if the fourth field is "age", the first filtering condition is "age greater than 30".

[0138] In step S106, the first query method is a query method represented by a first query statement, and a preset query device queries a preset data table based on the first query method to obtain a first query result.

[0139] In step S107, the first query result and the query basis for obtaining the first query result are displayed in the first display interface. That is, the first information and the first field representing the grouping, the second information, the second field and the first type representing the aggregation, the third information, the third field and the first arrangement order representing the sorting, and the fourth information, the fourth field and the first filtering condition representing the filtering are displayed at the same time. For example, the first display interface is shown in Figure 3 ,about Figure 3 This will be explained below and will not be repeated here.

[0140] The first information is used to indicate the grouping. The first information may be displayed in a manner that is a semantic description with a clear meaning, such as "grouping", or in a manner that is pre-agreed on to indicate the grouping. For example, the pre-agreed grouping may be indicated by a special symbol, such as "X", ", etc. It can also be displayed in other ways, which are not specifically limited here. The display method of the second information, the third information and the fourth information is the same as the display method of the first information, which will not be repeated here.

[0141] For example, the preset data table is the aforementioned Table 1, and the first query statement input is the aforementioned "SELECT class_name, COUNT(student_id) AS CNT FROM class_detail GROUP BY class_name ORDER BYCNT DESC LIMIT 1". The first query statement is parsed, and the obtained grouping operator is "GROUP BYclass_name", the aggregation operator is "COUNT student_id", and the sorting operator is "ORDER BY CNT". The above SQL statement does not include a filtering operator. The data query is performed on Table 1, and the first query result obtained by the query is that the course with the largest number of students is mathematics, with 35 students.

[0142] See also Figure 3 , Figure 3 This is a first schematic diagram of the first display interface provided in an embodiment of the present application. Figure 3 In the first display interface, the left half is used to display the query basis for obtaining the first query result, and the right half is used to display the first query result.

[0143] The left half shows the query basis for the first query result. The first information is "grouping", the first field is "course number", the second information is "aggregation", the second field is "student number", the first type is "count", the third information is "sort", the third field is "count value", the first sorting order is "descending", and the fourth information is "filter". Because the filter operator is not parsed in the first query statement, the fourth field and the first filter condition are "none". Among them, the first type and the first sorting order can also be marked with specific symbols, and "underline" is used to mark them in the figure.

[0144] The right half shows the first query result. The first query result is that the course with the largest number of students enrolled (i.e. the course name in the figure) is mathematics, and the number of students (i.e. the student number count in the figure) is 35.

[0145] See also Figure 4 , Figure 4 This is a second schematic diagram of the first display interface provided in the embodiment of the present application. Figure 4 In the present invention, the upper part of the first display interface is used to display the query basis for obtaining the first query result, and the lower part is used to display the first query result. Any display interface in this article can also display the user's question content (that is, the user's natural language used to express the first query statement), the data table name (the preset data table name), etc., and the display location area can be any location area. Figure 4In the example, only the top of the first display interface displays the user's question content, and the user's question content is "What is the name of the course with the most students enrolled?"

[0146] The upper part shows the query basis for obtaining the first query result. The first information is " ", the first field is "Course Number", the second information is "+", the second field is "Student Number", the first type is "Count", and the third information is " ", the third field is "count value", the first sorting order is "descending", and the fourth information is " ", because the filtering operator is not parsed in the above first query statement, the fourth field and the first filtering condition are "None".

[0147] The lower part shows the first query result. The first query result is that the course with the largest number of students enrolled (i.e. the course name in the figure) is mathematics, and the number of students (i.e. the student number count in the figure) is 35.

[0148] Figure 3 as well as Figure 4 The above is only a possible example of the first display interface. In other embodiments, the first display interface may also be in other forms, which is not specifically limited herein.

[0149] The above has described how to query the preset data table according to the first query statement to obtain the first query result, and display the first query result and the query basis for obtaining the first query result. In some scenarios, after obtaining the first query result, the user may need to perform a secondary analysis on the data.

[0150] Based on this, in a possible embodiment, the preset data table can also be analyzed again by adding an operator, see Figure 5 , Figure 5 A second flow chart of a data query method provided in an embodiment of the present application, the method comprising:

[0151] S501: In response to an adding operation input to a first display interface, determine a target operator indicated by the adding operation.

[0152] S502: Obtain a second query result obtained by querying a preset data table in a second query manner.

[0153] The second query method is a query method formed by adding a target operation on the basis of the first query method, and the target operation is an operation represented by the target operator.

[0154] S503, displaying a second display interface.

[0155] Among them, the result display interface displays the second query result, and when the target operator is a grouping operator, the second display interface also displays the first information and the fifth field, and the fifth field is the field used as the basis for grouping in the grouping operation represented by the target operator; when the target operator is an aggregation operator, the second display interface also displays the second information, the second field, the first type, the sixth field and the second type, and the sixth field is the field aggregated in the aggregation operation represented by the target operator, and the second type is the type of the aggregation operation represented by the target operator; when the target operator is a sorting operator, the second display interface also displays The third information, the third field, the first sorting order, the sixth field and the second sorting order are displayed. The sixth field is the field used as the sorting basis in the sorting operation represented by the target operator, and the second sorting order is the sorting order in the sorting operation represented by the target operator. When the target operator is a filtering operator, the second display interface also displays the fourth information, the fourth field, the first filtering condition, the seventh field and the second filtering condition. The seventh field is the field used to determine whether the filtering condition is met in the filtering operation represented by the target operator, and the second filtering condition is the filtering condition used in the filtering operation represented by the target operator.

[0156] After the first display interface is displayed, the user inputs an add operation for the first display interface. Specifically, a control for adding an operator may be displayed in the first display interface, so that the user can input the add operation by triggering the control. It may also be a pre-defined shortcut command for inputting the add operation, and the add operation is input by responding to the user triggering the shortcut command, for example, inputting the add operation by clicking the left mouse button, inputting the add operation by clicking a specified key on the keyboard, etc., which is not specifically limited here.

[0157] Taking clicking the left mouse button to input an add operation as an example, the operator indicated by the cursor when clicking the left mouse button can be used as the target operator. Taking clicking a specified key on the keyboard to input an add operation as an example, the platform device can pre-store the correspondence between each key position and each operator, and identify the operator that has a corresponding relationship with the key position clicked by the user as the target operator.

[0158] In response to the adding operation, the platform device adds the operation represented by the target operator on the basis of the first query mode to obtain a second query mode, and the preset query device queries the preset data table based on the second query mode to obtain a second query result. After obtaining the second query result, the platform device displays a second display page, which is similar to the content displayed on the first display page. The second display page not only displays the second query result, but also displays the query basis for obtaining the second query result.

[0159] Due to the different target operators, the second display interface will display different query bases, including the following situations:

[0160] Case 1: When the target operator is a grouping operator, the first information and the fifth field are correspondingly displayed in the second display interface.

[0161] The fifth field is the field used as the basis for grouping in the grouping operation represented by the target operator.

[0162] Case 2: When the target operator is an aggregation operator, the second information, the second field, the first type, the sixth field and the second type are correspondingly displayed in the second display interface.

[0163] The sixth field is the field aggregated in the aggregation operation represented by the target operator, and the second type is the type of the aggregation operation represented by the target operator.

[0164] Case 3: When the target operator is a sorting operator, the second display interface also displays the third information, the third field, the first arrangement order, the sixth field and the second arrangement order.

[0165] The sixth field is a field used as a sorting basis in the sorting operation represented by the target operator, and the second sorting order is the sorting order in the sorting operation represented by the target operator.

[0166] Case 4: when the target operator is a filtering operator, the second display interface also displays the fourth information, the fourth field, the first filtering condition, the seventh field and the second filtering condition accordingly.

[0167] The seventh field is a field used to determine whether the filtering condition is satisfied in the filtering operation represented by the target operator, and the second filtering condition is the filtering condition used in the filtering operation represented by the target operator.

[0168] Among them, the fifth field, the sixth field and the seventh field can be represented by any one of the field name, the physical name of the field, the index number of the field, and the field alias. The field name, the physical name of the field, the index number of the field, and the field alias have been explained in the previous text and will not be repeated here. The representation of the fifth field, the sixth field and the seventh field can be the same as the representation of the first field, the second field, the third field and the fourth field, or it can be different. No specific limitation is made here. The second type is the same as the representation of the first type, the second arrangement order is the same as the representation of the first arrangement order, and the second filter condition is the same as the representation of the first filter condition, which will not be repeated here.

[0169] The above is only an example in which the target operator is one of the grouping operator, aggregation operator, sorting operator and filtering operator. The target operator can also be multiple operators among the grouping operator, aggregation operator, sorting operator and filtering operator. The target operator can also be other operators except the grouping operator, aggregation operator, sorting operator and filtering operator, which are not listed here.

[0170] When displaying the query basis of the second query result, the second display page can present detailed information related to the target operator in a unique way, including field name, data type, sorting order, and filtering conditions. Specifically, in order to distinguish this information from other content on the page, different font styles, colors, or other visual elements can be used to highlight or specially mark it. Such a design not only makes the relevant information of the target operator more eye-catching, but also easy for users to identify.

[0171] Exemplarily, the first query result and the query basis for obtaining the first query result are as described above. Figure 3 For example, if the target operator is a MAX clause, that is, the target operator is an aggregation operator, the sixth field aggregated in the aggregation operation represented by the target operator is the student course score, and the sixth field is represented by the field meaning, that is, the sixth field is "student course score". The second type of the aggregation operation represented by the target operator is the maximum value, and the second type is described by semantics with clear meaning, that is, the second type is "maximum value".

[0172] See also Figure 6 , Figure 6 This is a schematic diagram of the second display interface provided in the embodiment of the present application, except for the aforementioned Figure 3 The content displayed in the first display interface shown in the figure, the second display interface also displays the sixth field "student course score", the second type "maximum value", and the second query result is that the course name with the largest number of students (i.e. the course name in the figure) is mathematics, the number of students (i.e. the student number count in the figure) is 35, and the highest score of the course with the largest number of students (i.e. the maximum student course score in the figure) is 100. Among them, the second type can also be marked in the same way as the first type and the first arrangement order, marked with underscores. The sixth field and the second type are displayed in italic text.

[0173] Figure 6 The above is only a possible example of the second display interface. In other embodiments, the second display interface may also be in other forms, which are not specifically limited in this document.

[0174] By applying the above embodiment, in response to the add operation for the first display interface, the system can dynamically determine the target operator indicated by the add operation and add the user-specified target operator based on the first query method, allowing the user to flexibly add new operations such as grouping, aggregation, sorting or filtering to the existing query method according to actual needs, thereby greatly improving the flexibility and scalability of data query. After obtaining the second query result obtained according to the new query method (i.e., the query method formed after adding the target operation on the basis of the first query method), a new interface containing these results can be displayed, which not only displays the query basis based on the second query result but also displays the query basis for obtaining the second query result, which not only enables the user to intuitively see the changes in the query results, but also helps the user to better understand the query results and query logic, thereby improving the overall user experience and solving the aforementioned problems one and two.

[0175] Taking the first display interface displaying a control for adding an operator, and the user inputting an adding operation through the control as an example, in a possible embodiment, the first display interface also displays an adding control, and the adding operation can be implemented by the following method, see Figure 7 , Figure 7 A schematic diagram of a process for adding an operator provided in an embodiment of the present application, wherein the method includes:

[0176] S701, in response to a triggering operation for adding a control, displaying a third display interface, where the third display interface includes all fields included in a preset data table.

[0177] S702, in response to a first selection operation input to the third display interface, determining a field indicated by the first selection operation; and displaying a fourth display interface, wherein the fourth display interface includes at least one preset function.

[0178] S703: In response to a second selection operation input on the fourth display interface, determine a function indicated by the second selection operation.

[0179] S704: Determine an operator for executing the function on the field according to the determined function and field.

[0180] The presentation of the added control in the first display interface is flexible and diverse, and can be presented in the form of clear and easy-to-read text, in the form of concise and intuitive symbols, or in the form of a combination of text and symbols. The trigger operation can be a single-click operation, a double-click operation, a long-press operation, etc.

[0181] The display method of all fields included in the preset data table in the third display interface is the same as the display method of the aforementioned first field, which will not be repeated here.

[0182] The relationship between the third display interface and the first display interface is also flexible and diverse. The third display interface can be a nested or embedded sub-interface in the first display interface, so as to maintain close connection and smooth switching between the display interfaces. The third display interface can also be a completely independent interface to enhance the user's data query experience.

[0183] Similarly, the relationship between the fourth display interface and the first display interface and the third display interface is also flexible and changeable. The fourth display interface can be used as a sub-interface of the first display interface, a sub-interface of the third display interface, or a completely independent interface, which is not specifically limited in this article.

[0184] The first selection operation may be single-clicking the field used as the basis for data query, or may be indicating the field used as the basis for data query in other forms, such as double-clicking, long pressing, etc., to provide a richer interactive experience.

[0185] The preset functions are the clauses included in the aforementioned operators, including but not limited to GROUP BY, SUM, AVG, MIN, MAX, COUNT, ORDER BY and HAVING, etc. In the fourth display interface, each function can be described with clear semantics or with a clause name, which is not specifically limited in this article.

[0186] In order to explain the above process of adding operators more clearly, Figure 3 In the first display interface shown in , the target operator is the MAX clause, the fifth field is "student course score", and the second type is "maximum value". Figure 8 , Fig. 9 as well as Fig.10 To explain:

[0187] See also Figure 8 , Figure 8 The first schematic diagram of adding an operator provided in the embodiment of the present application is as follows: Figure 8 As shown, in addition to the aforementioned first query result and the query basis for obtaining the first query result, the first display interface also displays an add control, in which the add control is only displayed in the form of a combination of text and symbols "+ Add".

[0188] The user clicks the add control "+Add", and the platform device displays the third display page. For example, the preset data table is Table 1, the target operator indicated by the add operation is the MAX clause, and the sixth field aggregated in the aggregation operation represented by the target operator is the student course score. Fig. 9 , Fig. 9The second schematic diagram of adding an operator provided in an embodiment of the present application, the fields displayed in the third display interface (the figure only takes the third display interface as a sub-interface in the first display interface as an example) include course number, course name, student ID number, student name and student course score. The user confirms the field indicated by the first selection operation by clicking the student course score field.

[0189] After determining the field indicated by the first selection operation, the platform device displays a fourth display interface (the fourth display interface is only taken as a sub-interface of the first display interface as an example in the figure), see Fig.10 , Fig.10 The third schematic diagram of adding operators provided in the embodiment of the present application, the preset functions displayed in the fourth display interface include grouping, summation, average, minimum, maximum, counting, sorting and filtering, and the user determines the function indicated by the second selection operation through the maximum value of the function.

[0190] The platform device determines the aggregation operator used to execute the function "maximum value" on the field "student course score" based on the determined function "maximum value".

[0191] By applying the above embodiment, by adding an add control in the first display interface, the user can enter the third display interface by triggering the add control. The interface displays all fields in the preset data table, greatly improving the flexibility and efficiency of the user's field selection. Furthermore, after the user selects a field in the first selection operation in the third display interface, a fourth display interface containing at least one preset function is displayed, so that the user can select an applicable function according to the needs. According to the selected function and field, the platform device can automatically determine the corresponding operator, which simplifies the user data query process, significantly improves the efficiency of data query, and brings a more convenient and efficient data query experience to the user, solving the aforementioned problems one and two.

[0192] The previous article has elaborated on the specific methods and steps of data query. The following will explain the data query method from the underlying execution logic level of data query:

[0193] In one possible embodiment, see Fig.11 , Fig.11 A third flow chart of the data query method provided in an embodiment of the present application, in response to an add operation, obtaining a second query statement based on the first query statement, and querying to obtain a second query result, specifically includes:

[0194] S1101: Generate a first syntax tree for representing a first query method according to a first query statement.

[0195] The first syntax tree includes a plurality of nodes, and each node corresponds to each step in the process of executing the first query statement.

[0196] S1102: In the first syntax tree, determine a node whose operation type is the same as the operation type represented by the target operator as the target node.

[0197] S1103: In the first syntax tree, add the operation represented by the target operator to the operation represented by the target node to obtain a second syntax tree.

[0198] S1104, starting from the root node of the second syntax tree, traverse each node of the second syntax tree to obtain a second query result.

[0199] By applying the above embodiment, a first syntax tree is generated according to the first query statement, and complex query logic can be clearly decomposed into multiple steps. Each step corresponds to a node in the syntax tree. After determining the target node (i.e., a node with the same operation type as the target operator), a new operation represented by the target operator can be added to the operation represented by the node, thereby obtaining an accurate second syntax tree and executing it to obtain a second query result. This syntax tree-based query construction and execution method realizes flexible expansion of data queries, and further realizes secondary analysis of query results by users, which not only improves the accuracy and flexibility of data queries, but also significantly improves the efficiency of data queries.

[0200] The above has described the specific process of "responding to the addition operation, obtaining the second query statement based on the first query statement, and querying to obtain the second query result" from the level of the syntax tree. The data query method provided in the embodiment of the present application will be described below from the level of interaction between the platform device and the preset query device:

[0201] See also Fig.12 , Fig.12 A fourth flow chart of a data query method provided in an embodiment of the present application, the method comprising:

[0202] S1201, sending a first query statement and an empty operator list to a preset query device, so that the preset query device determines and executes a first query mode represented by the first query statement in response to the operator list being empty, obtains a first query result and feeds back.

[0203] S1202: Receive a first query result fed back by a preset query device.

[0204] S1203, sending the first query statement and the operator list for recording the target operator to the preset query device, so that the preset query device responds to the operator list being not empty, determines the first query method represented by the first query statement and the operation represented by the target operator recorded in the operator list, and adds the target operation on the basis of the first query method, obtains the second query method and executes it, obtains the second query result and feeds back.

[0205] S1204: Receive a second query result fed back by a preset query device.

[0206] The empty operator list is created in advance and is used to store operators that may be added subsequently. When the operator list is empty, that is, the target operator is not added, the preset data table is queried in the first query mode to obtain the first query result.

[0207] When the operator list is not empty, that is, the target operator has been added, the preset data table is queried according to the second query method to obtain the second query result.

[0208] By applying the above embodiment, the query method is dynamically adjusted by sending the first query statement and the operator list that changes according to the demand to the preset query device. When the operator list is empty, the query method indicated by the first query statement is directly executed to quickly obtain the first query result; and when the operator list is not empty, the second query method can be generated and executed on the basis of the first query method, combined with the operation represented by the target operator recorded in the operator list, so as to obtain the second query result, which not only simplifies the complexity of re-querying based on the first query result, but also significantly improves the flexibility and adaptability of data query, and can meet the diverse needs of data query in different scenarios. At the same time, the real-time nature of the query result is ensured through the instant feedback of the preset query device.

[0209] The data query method provided in the embodiment of the present application will be described below in conjunction with hardware devices. Fig.13 , Fig.13 This is a structural diagram of the data query hardware device provided in an embodiment of the present application, where the hardware device 1300 includes an execution plan parsing module 1301, a function custom plug-in module 1302, an operator matching module 1303, an operator extraction module 1304, and an operator injection module 1305.

[0210] See also Fig.14 , Fig.14 A fifth flow chart of the data query method provided in the embodiment of the present application, after the platform device sends the first query statement and the operator list (that is, an empty operator list) to the preset query device, the method includes:

[0211] S1401, parse and obtain execution plan 1.

[0212] S1402, operator extraction.

[0213] S1403, custom aggregation function.

[0214] S1404, determine whether the operator list is empty, if so, execute step S1405, if not, execute step S1406.

[0215] S1405, execute execution plan 1, and feed back the first query result.

[0216] S1406, inject the target operator and generate execution plan 2.

[0217] S1407, execute execution plan 2, and feed back the second query result.

[0218] In step S1401, before the preset query device executes the first query statement or the second query statement, the execution plan parsing module parses the first query statement to obtain an execution plan, which is recorded as execution plan 1. For example, taking the first query statement as the aforementioned "SELECT class_name, COUNT(student_id) AS CNT FROM class_detailGROUP BY class_name ORDER BY CNT DESC LIMIT 1" as an example, the corresponding execution plan obtained by parsing it is:

[0219]

[0220]

[0221]

[0222]

[0223] The above-mentioned execution plan 1, the above-mentioned first query method and the above-mentioned first syntax tree correspond one to one, and are different expressions of the first query statement. The execution plan 1 represents the SQL query process from bottom to top. For the convenience of explanation, the above-mentioned execution plan 1 is recorded from bottom to top as step 1, step 2, step 3 and step 4 in sequence.

[0224] In step 1, LogicalTableScan is a logical table scan. Step 1 indicates that the data table named class_detail is scanned. The table is located in the public namespace of the database stored in pg_postgres_vkcfsxot (database identifier).

[0225] In step 2, LogicalProject is to project the scanned data. Step 2 means selecting the first field class_name. To identify the field, select the second field student_id. Used to identify this field.

[0226] In step 3, LogicalAggregate performs grouping and aggregation operations on the projected data. Step 3 indicates that the data is grouped according to class_name ( , that is, the first field in the previous projection operation) is grouped and the number of student_id in each group is calculated. CNT is the abbreviation of COUNT, that is, the counting result is identified by CNT.

[0227] In step 4, LogicalSort is used to sort the aggregated results. Step 4 indicates that class_name is sorted based on student_id, and the sorting direction is specified as descending (DESC). Fetch indicates that only the first record after sorting is obtained.

[0228] In step S1402, after the execution plan is parsed, the operator extraction module performs operator extraction. Specifically, a visitor object can be defined within the data query. The defined visitor object completes the traversal of each node in the above execution plan from the starting point in a top-down order, and extracts operators according to the different types of the current node. The process of operator extraction is the process of generating the syntax tree mentioned above.

[0229] Exemplarily, the nodes include three types: LogicalSort (sorting), LogicalAggregate (aggregation, grouping), and LogicalFilter (filtering). LogicalSort, this node type represents sorting operations, and specifies the sorting fields and the sorting direction (ascending or descending). LogicalAggregate, this node type represents aggregation and grouping operations. Aggregate functions (such as SUM, COUNT, AVG, etc.) are used to calculate the grouped data. The LogicalAggregate node specifies the grouping fields, the aggregate functions to be applied, and their specific parameter values. LogicalFilter, this node type represents filtering operations. During the query execution process, it may be necessary to filter out unnecessary data rows based on certain conditions. The LogicalFilter node specifies the filtered fields, filtering conditions (such as equal to, greater than, less than, etc.), and filter values.

[0230] In step S1403, during the operator extraction process, the grouping operator, sorting operator, and filtering operator all meet the industrial-grade SQL standards. However, the aggregation functions included in the aggregation operator have usage differences between different databases. Based on this, in a possible embodiment, the embodiment of the present application provides an interface for hot loading of custom aggregation functions, which supports the registration of custom aggregation functions in the form of plug-ins. Hot loading means that new aggregation functions can be loaded without restarting the preset query device, that is, during the data query process, the target operator injected as the aggregation function can be injected through the operator injection module without restarting the preset query device.

[0231] For the specific process of custom function registration, see Fig.15 , Fig.15 A schematic diagram of a process for registering a custom function provided in an embodiment of the present application, wherein the method comprises:

[0232] S1501, customize the aggregation function according to the plug-in rules.

[0233] S1502, aggregation function analysis and verification.

[0234] S1503, submit the registration and store it persistently.

[0235] S1504 is used for operator extraction and injection.

[0236] In order to ensure the correctness and consistency of the custom aggregate function, a series of rule attributes need to be defined, including the function name, parameter types, return value type, and the length and precision of the return value. Among them, the function name uniquely identifies a function and is used to reference it in data queries. The parameter type is used to specify the type of parameter that the function can be customized to. It can be a basic data type such as integer, floating point number, string, etc., or a complex type such as array, structure, etc. The return value type is used to specify the type of the function return value, which can be a basic data type or a complex data type. The length and precision of the return value are used to specify the maximum length or precision of the return value.

[0237] When receiving a new custom aggregate function, the preset query device parses and verifies the aggregate function. Specifically, it reads and parses the definition file or data structure of the aggregate function, extracts the above rule attributes, checks whether the function name is unique, whether the parameter type and quantity are legal, whether the return value type is consistent with expectations, and whether it meets other system-defined rules. If the verification passes, the function definition is stored in the system database or configuration file for subsequent use.

[0238] In step S1404, after the operator is extracted, it is determined whether the operator list is empty.

[0239] In step S1405, if it is empty, the first query mode is executed to obtain the first query result and feed back the first query result, after which the operator list is returned.

[0240] In step S1406, if it is not empty, the target operator is injected by the operator injection module. Both operator extraction and operator injection need to go through the execution plan analysis module first. When the operator list is not empty, the target operator injection process will be entered.

[0241] For example, taking the first query statement as the aforementioned "SELECT class_name, COUNT(student_id) ASCNT FROM class_detail GROUP BY class_name ORDER BY CNT DESC LIMIT 1", the target operator is the aforementioned MAX clause, and the sixth field is the student's course score, the operator list is not empty at this time, and is specifically: {"type":"aggregation","funcName":"max","column":"score"}, where type represents the operator type, funcName is the function name, and column is the aggregated field.

[0242] See also Fig.16 , Fig.16 A schematic diagram of the flow of the injection operator provided in an embodiment of the present application, the method includes:

[0243] S1601, obtaining execution plan 1 corresponding to the first query statement.

[0244] S1602, the visitor object traverses each node of the execution plan from top to bottom.

[0245] S1603, each operator in the operator list is matched with the current node.

[0246] S1604, determine whether the types match, if so, execute step S1605, if not, execute step S1602.

[0247] S1605: Inject the target operator into the current node.

[0248] S1606, after the traversal is completed, execution plan 2 is executed and the second query result is fed back.

[0249] During the operator injection process, a visitor object is also defined by the data query internally. The defined visitor object traverses each node of execution plan one from the starting point in a top-down order. If the current node type matches the operator type, the current operator is injected into the node. After the matching processing of all nodes is completed, a new execution plan will be obtained, which is recorded as execution plan two.

[0250] In step S1407, execution plan 2 is executed to obtain a second query result and feed it back.

[0251] The execution plan 2 after the operator is injected in the above example is shown below. It can be seen that an aggregate function MAX is injected into the LogicalAggregate node, that is, a target operation is added on the basis of the first query method.

[0252]

[0253]

[0254]

[0255]

[0256] The above-mentioned execution plan 2, the above-mentioned second query method and the above-mentioned second syntax tree correspond one to one, and are different expressions of the second query statement. Like the above-mentioned execution plan 1, the execution plan 2 represents the SQL query process from bottom to top. For the convenience of explanation, the above-mentioned execution plan 2 is recorded from bottom to top as step 1, step 2, step 3 and step 4.

[0257] Step 1 is the same as the above step 1 and will not be repeated here.

[0258] In step 2, LogicalProject is to perform a projection operation on the scanned data. Step 2 indicates selecting the first field class_name. To identify the field, select the second field student_id. Used to identify the field, select the third field score, Used to identify this field.

[0259] In step 3, LogicalAggregate performs grouping and aggregation operations on the projected data. Step 3 means grouping by class_name and calculating the number of student_ids in each group. CNT is the abbreviation of COUNT, that is, the counting result is identified by CNT, and the maximum score of the group with the largest number of student_ids in each group divided by class_name is checked.

[0260] Step 4 is the same as the above step 4 and will not be repeated here.

[0261] Corresponding to the aforementioned data query method, the present application embodiment also provides a data query device, see Fig.17 , Fig.17The structural diagram of the data query device provided in the embodiment of the present application includes:

[0262] The first acquisition module 1701 is used to acquire a first query statement input for a preset data table, and parse to obtain a grouping operator, an aggregation operator, a sorting operator, and a filtering operator included in the first query statement;

[0263] A first parsing module 1702 is used to determine, for the parsed grouping operator, a field used as a grouping basis in the grouping operation represented by the grouping operator from among the fields included in the preset data table, as a first field;

[0264] The second parsing module 1703 is used to determine, for the parsed aggregation operator, from the fields included in the preset data table, the field aggregated in the aggregation operation represented by the aggregation operator as the second field; and determine the type of the aggregation operation as the first type;

[0265] The third parsing module 1704 is used to determine, for the parsed sorting operator, a field used as a sorting basis in the sorting operation represented by the sorting operator from among the fields included in the preset data table as a third field; and determine an arrangement order in the sorting operation as a first arrangement order;

[0266] The fourth parsing module 1705 is used to determine, for the filter operator obtained by the analysis, a field in the fields included in the preset data table, which is used to judge whether the filter condition is satisfied in the filter operation represented by the filter operator as a fourth field; and determine the filter condition used in the filter operation as a first filter condition;

[0267] A second acquisition module 1706 is used to acquire a first query result obtained by querying the preset data table in a first query manner, wherein the first query manner is a query manner represented by the first query statement;

[0268] The first display module 1707 is used to display a first display interface, wherein the first display interface displays the first query result, and correspondingly displays the first information for indicating grouping, the first field, and correspondingly displays the second information for indicating aggregation, the second field and the first type, and correspondingly displays the third information for indicating sorting, the third field and the first arrangement order, and correspondingly displays the fourth information for indicating filtering, the fourth field and the first filtering condition.

[0269] By applying the above embodiment, by parsing the grouping operator, aggregation operator, sorting operator and filtering operator in the first query statement, the key elements in the query operation are accurately identified, including the field for grouping, the field and type of the aggregation operation, the field for sorting and the arrangement order, and the fields and specific conditions involved in the filtering conditions. After obtaining the query results based on the key elements in the query operation, an interface containing detailed key elements and query results in the query operation is displayed, and the user can intuitively see the entire process of the query operation, including the specific details of grouping, aggregation, sorting and filtering, so that it is easier to verify whether the query results meet their own needs. This visual query feedback mechanism not only enables users to clearly see the query results, but also deeply understand the query process, thereby effectively verifying the accuracy of the query results and improving the efficiency and accuracy of data queries.

[0270] In a possible implementation, the device further includes:

[0271] A first response module, configured to respond to an add operation input to the first display interface and determine a target operator indicated by the add operation;

[0272] A third acquisition module is used to obtain a second query result obtained by querying the preset data table according to a second query method, wherein the second query method is a query method formed by adding a target operation on the basis of the first query method, and the target operation is an operation represented by the target operator;

[0273] a second display module, for displaying a second display interface, wherein the second display interface displays the second query result, and when the target operator is the grouping operator, the second display interface also displays the first information and the fifth field, and the fifth field is the field used as the basis for grouping in the grouping operation represented by the target operator; when the target operator is the aggregation operator, the second display interface also displays the second information, the second field, the first type, the sixth field and the second type, and the sixth field is the field aggregated in the aggregation operation represented by the target operator, and the second type is the type of the aggregation operation represented by the target operator; when the target operator is the sorting operator, The second display interface also displays the third information, the third field, the first arrangement order, the sixth field and the second arrangement order, the sixth field is the field used as the sorting basis in the sorting operation represented by the target operator, and the second arrangement order is the arrangement order in the sorting operation represented by the target operator; when the target operator is the filtering operator, the second display interface also displays the fourth information, the fourth field, the first filtering condition, the seventh field and the second filtering condition, the seventh field is the field used to determine whether the filtering condition is met in the filtering operation represented by the target operator, and the second filtering condition is the filtering condition used in the filtering operation represented by the target operator.

[0274] In a possible implementation manner, the first display interface further displays an add control;

[0275] A third display module, configured to display a third display interface in response to a trigger operation on the adding control, wherein the third display interface includes all fields included in the preset data table;

[0276] a second response module, configured to respond to a first selection operation inputted to the third display interface, determine a field indicated by the first selection operation; and display a fourth display interface, wherein the fourth display interface includes at least one preset function;

[0277] The first response module includes:

[0278] A first response submodule, configured to respond to a second selection operation inputted to the fourth display interface and determine a function indicated by the second selection operation;

[0279] The response second submodule is used to determine an operator for executing the function on the field according to the determined function and field.

[0280] In a possible implementation, the second query result is obtained by querying in the following manner, including:

[0281] Generate a first syntax tree for representing the first query mode according to the first query statement, wherein the first syntax tree includes a plurality of nodes, each node corresponding to each step in the process of executing the first query statement;

[0282] In the first syntax tree, determine a node whose operation type is the same as the operation type represented by the target operator as the target node;

[0283] In the first syntax tree, adding the operation represented by the target operator to the operation represented by the target node to obtain a second syntax tree;

[0284] Starting from the root node of the second syntax tree, each node of the second syntax tree is traversed to obtain a second query result.

[0285] In a possible implementation manner, the second acquisition module includes:

[0286] Obtain a first submodule, which is used to send the first query statement and an empty operator list to a preset query device, so that the preset query device determines and executes a first query mode represented by the first query statement in response to the operator list being empty, obtains a first query result and feeds back the result;

[0287] Obtain a second submodule, which is used to receive the first query result fed back by the preset query device;

[0288] The third acquisition module includes:

[0289] Obtain a third submodule, which is used to send the first query statement and the operator list for recording the target operator to a preset query device, so that the preset query device determines the first query mode represented by the first query statement and the operation represented by the target operator recorded in the operator list in response to the operator list being not empty, and adds the target operation on the basis of the first query mode, obtains and executes the second query mode, obtains and feeds back the second query result;

[0290] The fourth submodule is obtained, which is used to receive the second query result fed back by the preset query device.

[0291] The present application also provides an electronic device, such as Fig.18 As shown, including:

[0292] Memory 1801, used for storing computer programs;

[0293] The processor 1802 is used to implement the following steps when executing the program stored in the memory 1801:

[0294] Obtaining a first query statement input for a preset data table, and parsing to obtain a grouping operator, an aggregation operator, a sorting operator, and a filtering operator included in the first query statement;

[0295] For the grouping operator obtained by parsing, determine, from the fields included in the preset data table, a field used as a grouping basis in the grouping operation represented by the grouping operator as a first field;

[0296] For the aggregation operator obtained by parsing, determine, from the fields included in the preset data table, the field aggregated in the aggregation operation represented by the aggregation operator as the second field; and determine the type of the aggregation operation as the first type;

[0297] For the sorting operator obtained by the analysis, determine, among the fields included in the preset data table, a field used as a sorting basis in the sorting operation represented by the sorting operator as a third field; and determine an arrangement order in the sorting operation as a first arrangement order;

[0298] For the filter operator obtained by the analysis, among the fields included in the preset data table, a field used for judging whether the filter condition is satisfied in the filter operation represented by the filter operator is determined as a fourth field; and the filter condition used in the filter operation is determined as a first filter condition;

[0299] Obtaining a first query result obtained by querying the preset data table in a first query manner, wherein the first query manner is a query manner represented by the first query statement;

[0300] A first display interface is displayed, wherein the first display interface displays the first query result, and correspondingly displays the first information for indicating grouping, the first field, and correspondingly displays the second information for indicating aggregation, the second field, and the first type, and correspondingly displays the third information for indicating sorting, the third field, and the first arrangement order, and correspondingly displays the fourth information for indicating filtering, the fourth field, and the first filtering condition.

[0301] In addition, the electronic device may further include a communication bus and / or a communication interface, and the processor 1802, the communication interface, and the memory 1801 communicate with each other via the communication bus.

[0302] The communication bus mentioned in the above electronic device can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.

[0303] The communication interface is used for communication between the above electronic device and other devices.

[0304] The memory may include a random access memory (RAM) or a non-volatile memory (NVM), such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.

[0305] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.

[0306] In another embodiment provided in the present application, a computer-readable storage medium is provided, in which a computer program is stored. When the computer program is executed by a processor, the steps of any of the above-mentioned data query methods are implemented.

[0307] In another embodiment provided in the present application, a computer program product including instructions is also provided, which, when executed on a computer, enables the computer to execute any of the data query methods in the above embodiments.

[0308] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from a website site, computer, server or data center to another website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium may be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated. The available medium may be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a solid-state hard disk (SSD), etc.

[0309] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.

[0310] Each embodiment in this specification is described in a related manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0311] The above description is only a preferred embodiment of the present application and is not intended to limit the protection scope of the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application are included in the protection scope of the present application.

Claims

1. A data query method, characterized in that: The method comprises: Obtaining a first query statement input for a preset data table, and parsing to obtain a grouping operator, an aggregation operator, a sorting operator, and a filtering operator included in the first query statement; For the grouping operator obtained by parsing, determine, from the fields included in the preset data table, a field used as a grouping basis in the grouping operation represented by the grouping operator as a first field; For the aggregation operator obtained by parsing, determine, from the fields included in the preset data table, the field aggregated in the aggregation operation represented by the aggregation operator as the second field; and determine the type of the aggregation operation as the first type; For the sorting operator obtained by the analysis, determine, among the fields included in the preset data table, a field used as a sorting basis in the sorting operation represented by the sorting operator as a third field; and determine an arrangement order in the sorting operation as a first arrangement order; For the filter operator obtained by the analysis, among the fields included in the preset data table, a field used for judging whether the filter condition is satisfied in the filter operation represented by the filter operator is determined as a fourth field; and the filter condition used in the filter operation is determined as a first filter condition; Obtaining a first query result obtained by querying the preset data table in a first query manner, wherein the first query manner is a query manner represented by the first query statement; A first display interface is displayed, wherein the first display interface displays the first query result, and correspondingly displays the first information for indicating grouping, the first field, and correspondingly displays the second information for indicating aggregation, the second field, and the first type, and correspondingly displays the third information for indicating sorting, the third field, and the first arrangement order, and correspondingly displays the fourth information for indicating filtering, the fourth field, and the first filtering condition.

2. The method according to claim 1, characterized in that The method further comprises: In response to an add operation input to the first display interface, determining a target operator indicated by the add operation; Obtaining a second query result obtained by querying the preset data table according to a second query method, wherein the second query method is a query method formed by adding a target operation on the basis of the first query method, and the target operation is an operation represented by the target operator; A second display interface is displayed, wherein the result display interface displays the second query result, and when the target operator is the grouping operator, the second display interface also displays the first information and the fifth field, and the fifth field is the field used as the basis for grouping in the grouping operation represented by the target operator; when the target operator is the aggregation operator, the second display interface also displays the second information, the second field, the first type, the sixth field and the second type, and the sixth field is the field aggregated in the aggregation operation represented by the target operator, and the second type is the type of the aggregation operation represented by the target operator; when the target operator is the sorting operator, the second The display interface also displays the third information, the third field, the first arrangement order, the sixth field and the second arrangement order accordingly, the sixth field is the field used as the sorting basis in the sorting operation represented by the target operator, and the second arrangement order is the arrangement order in the sorting operation represented by the target operator; when the target operator is the filtering operator, the second display interface also displays the fourth information, the fourth field, the first filtering condition, the seventh field and the second filtering condition accordingly, the seventh field is the field used to determine whether the filtering condition is met in the filtering operation represented by the target operator, and the second filtering condition is the filtering condition used in the filtering operation represented by the target operator.

3. The method according to claim 2, characterized in that The first display interface also displays an add control; In response to a trigger operation for the adding control, displaying a third display interface, wherein the third display interface includes all fields included in the preset data table; In response to a first selection operation inputted to the third display interface, determining a field indicated by the first selection operation; and displaying a fourth display interface, wherein the fourth display interface includes at least one preset function; The step of determining, in response to an add operation input to the first display interface, a target operator indicated by the add operation includes: In response to a second selection operation inputted on the fourth display interface, determining a function indicated by the second selection operation; According to the determined function and field, an operator for executing the function on the field is determined.

4. The method according to claim 2, characterized in that: The second query result is obtained by querying in the following ways, including: Generate a first syntax tree for representing the first query mode according to the first query statement, wherein the first syntax tree includes a plurality of nodes, each node corresponding to each step in the process of executing the first query statement; In the first syntax tree, determine a node whose operation type is the same as the operation type represented by the target operator as the target node; In the first syntax tree, adding the operation represented by the target operator to the operation represented by the target node to obtain a second syntax tree; Starting from the root node of the second syntax tree, each node of the second syntax tree is traversed to obtain a second query result.

5. The method according to claim 2, characterized in that: The obtaining of a first query result obtained by querying the preset data table in a first query manner includes: Sending the first query statement and the empty operator list to a preset query device, so that the preset query device determines and executes a first query mode represented by the first query statement in response to the operator list being empty, obtains a first query result and feeds back the result; Receive a first query result fed back by the preset query device; The obtaining of a second query result obtained by querying the preset data table in a second query manner includes: The first query statement and the operator list for recording the target operator are sent to a preset query device, so that the preset query device determines the first query mode represented by the first query statement and the operation represented by the target operator recorded in the operator list in response to the operator list being not empty, and adds the target operation on the basis of the first query mode, obtains the second query mode and executes it, obtains the second query result and feeds back; Receive a second query result fed back by the preset query device.

6. A data query system, characterized in that: The system includes a platform device and a preset query device: The platform device is used to obtain a first query statement input for a preset data table, and parse to obtain the grouping operator, aggregation operator, sorting operator and filtering operator included in the first query statement; for the grouping operator obtained by the analysis, determine the field used as the grouping basis in the grouping operation represented by the grouping operator in the fields included in the preset data table as the first field; for the aggregation operator obtained by the analysis, determine the field aggregated in the aggregation operation represented by the aggregation operator in the fields included in the preset data table as the second field; and determine the type of the aggregation operation as the first type; for the sorting operator obtained by the analysis, determine the field used as the sorting basis in the sorting operation represented by the sorting operator in the fields included in the preset data table as the third field; and determine the arrangement order in the sorting operation as the first arrangement order; for the filtering operator obtained by the analysis, determine the field used to judge whether the filtering condition is met in the filtering operation represented by the filtering operator in the fields included in the preset data table as the fourth field; and determine the filtering condition used in the filtering operation as the first filtering condition; Sending the first query statement to a preset query device; Obtaining a first query result obtained by querying the preset data table according to a first query method, wherein the first query method is a query method represented by the first query statement; displaying a first display interface, wherein the first display interface displays the first query result, and correspondingly displays first information for representing grouping and the first field, and correspondingly displays second information for representing aggregation, the second field, and the first type, and correspondingly displays third information for representing sorting, the third field, and the first arrangement order, and correspondingly displays fourth information for representing filtering, the fourth field, and the first filtering condition; The preset query device is used to query the preset data table according to the first query statement sent by the platform device to obtain the first query result and feed back.

7. A data query device, characterized in that: The device comprises: A first acquisition module, used to acquire a first query statement input for a preset data table, and parse to obtain a grouping operator, an aggregation operator, a sorting operator, and a filtering operator included in the first query statement; A first parsing module is used to determine, for the parsed grouping operator, a field used as a grouping basis in the grouping operation represented by the grouping operator from among the fields included in the preset data table, as a first field; A second parsing module is used to determine, for the parsed aggregation operator, from the fields included in the preset data table, the field aggregated in the aggregation operation represented by the aggregation operator as the second field; and determine the type of the aggregation operation as the first type; A third parsing module is used to determine, for the parsed sorting operator, from the fields included in the preset data table, a field used as a sorting basis in the sorting operation represented by the sorting operator as a third field; and determine an arrangement order in the sorting operation as a first arrangement order; A fourth parsing module is used to determine, for the filter operator obtained by the analysis, a field in the fields included in the preset data table, which is used to judge whether the filter condition is satisfied in the filter operation represented by the filter operator as a fourth field; and determine the filter condition used in the filter operation as a first filter condition; A second acquisition module, configured to acquire a first query result obtained by querying the preset data table in a first query manner, wherein the first query manner is a query manner represented by the first query statement; A first display module is used to display a first display interface, wherein the first display interface displays the first query result, and correspondingly displays the first information for indicating grouping, the first field, and correspondingly displays the second information for indicating aggregation, the second field, and the first type, and correspondingly displays the third information for indicating sorting, the third field, and the first arrangement order, and correspondingly displays the fourth information for indicating filtering, the fourth field, and the first filtering condition.

8. The device according to claim 7, characterized in that The device also includes: A first response module, configured to respond to an add operation input to the first display interface and determine a target operator indicated by the add operation; A third acquisition module is used to obtain a second query result obtained by querying the preset data table according to a second query method, wherein the second query method is a query method formed by adding a target operation on the basis of the first query method, and the target operation is an operation represented by the target operator; a second display module, for displaying a second display interface, wherein the second display interface displays the second query result, and when the target operator is the grouping operator, the second display interface also displays the first information and the fifth field, and the fifth field is the field used as the basis for grouping in the grouping operation represented by the target operator; when the target operator is the aggregation operator, the second display interface also displays the second information, the second field, the first type, the sixth field and the second type, and the sixth field is the field aggregated in the aggregation operation represented by the target operator, and the second type is the type of the aggregation operation represented by the target operator; when the target operator is the sorting operator, The second display interface also displays the third information, the third field, the first arrangement order, the sixth field and the second arrangement order, the sixth field is the field used as the sorting basis in the sorting operation represented by the target operator, and the second arrangement order is the arrangement order in the sorting operation represented by the target operator; when the target operator is the filtering operator, the second display interface also displays the fourth information, the fourth field, the first filtering condition, the seventh field and the second filtering condition, the seventh field is the field used to determine whether the filtering condition is satisfied in the filtering operation represented by the target operator, and the second filtering condition is the filtering condition used in the filtering operation represented by the target operator; The first display interface also displays an add control; A third display module, configured to display a third display interface in response to a trigger operation on the adding control, wherein the third display interface includes all fields included in the preset data table; a second response module, configured to respond to a first selection operation inputted to the third display interface, determine a field indicated by the first selection operation; and display a fourth display interface, wherein the fourth display interface includes at least one preset function; The first response module includes: A first response submodule, configured to respond to a second selection operation inputted to the fourth display interface and determine a function indicated by the second selection operation; A second submodule is responsive to determine, based on the determined function and field, an operator for executing the function on the field; The second query result is obtained by querying in the following ways, including: Generate a first syntax tree for representing the first query mode according to the first query statement, wherein the first syntax tree includes a plurality of nodes, each node corresponding to each step in the process of executing the first query statement; In the first syntax tree, determine a node whose operation type is the same as the operation type represented by the target operator as the target node; In the first syntax tree, adding the operation represented by the target operator to the operation represented by the target node to obtain a second syntax tree; Starting from the root node of the second syntax tree, traverse each node of the second syntax tree to obtain a second query result; The second acquisition module includes: Obtain a first submodule, which is used to send the first query statement and an empty operator list to a preset query device, so that the preset query device determines and executes a first query mode represented by the first query statement in response to the operator list being empty, obtains a first query result and feeds back the result; Obtain a second submodule, which is used to receive the first query result fed back by the preset query device; The third acquisition module includes: Obtain a third submodule, which is used to send the first query statement and the operator list for recording the target operator to a preset query device, so that the preset query device determines the first query mode represented by the first query statement and the operation represented by the target operator recorded in the operator list in response to the operator list being not empty, and adds the target operation on the basis of the first query mode, obtains and executes the second query mode, obtains and feeds back the second query result; The fourth submodule is obtained, which is used to receive the second query result fed back by the preset query device.

9. An electronic device, characterized in that: include: Memory, used to store computer programs; A processor, for implementing any of the methods described in claims 1-5 when executing a program stored in a memory.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 5 is implemented.

Citation Information

Patent Citations

  • HBase data persistence and query methods and HBase system

    CN103955538A

  • Program code display equipment, method and device

    CN108334321A

  • Interactive labeling method and device

    CN111797637A

  • Data blood relationship analysis method and device based on column-level data

    CN113191139A

  • Flink SQL statement verification method and device, computer equipment and storage medium

    CN114116268A

Cited By

  • Data query method for graph database and related equipment

    CN119848284A