Data query method, device and electronic device

By obtaining and parsing query request messages and using abstract syntax trees for querying, the problem of high technical requirements for business personnel in the existing technology and inability to meet real-time performance is solved, and more efficient data utilization is achieved.

CN114661714BActive Publication Date: 2025-05-16SENSOR NETWORKS TECH BEIJING CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202210255856.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-03-15
Publication Date
2025-05-16
Estimated Expiration
2042-03-15

AI Technical Summary

Technical Problem

In the prior art, the use of SQL for querying has high technical requirements for business personnel, and is offline operation, which cannot meet the real-time nature of business needs, reducing the efficiency of data utilization.

Method used

By obtaining query request messages, including query request statements and query request expressions, based on entity tags, operators and functions, parsing processing is performed to obtain metadata, and querying is performed using an abstract syntax tree, including a first abstract syntax tree and a second abstract syntax tree, supporting structured query language and distributed query language.

Benefits of technology

It realizes that business personnel can flexibly define query request messages through entity tags, adapt to abstract syntax trees of different query requests, avoid real-time problems, and improve data utilization efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114661714B_ABST
    Figure CN114661714B_ABST
Patent Text Reader

Abstract

The present disclosure relates to the field of computer application technology, and in particular to a data query method, device and electronic device. The method includes: obtaining a query request message, wherein the query request message is determined according to an entity tag, an operator and a function; parsing the query request message to obtain at least one metadata corresponding to the query request message; based on the at least one metadata, querying according to an abstract syntax tree to obtain a query result corresponding to the query request message, wherein the abstract syntax tree includes a first abstract syntax tree and a second abstract syntax tree, the first abstract syntax tree is obtained according to the query request message, and the second abstract syntax tree is obtained according to a preset query language generated by the query request message. This method is convenient for users to flexibly use query request messages based on entity definitions for querying, and for different query request messages, different abstract syntax trees are used to obtain query results, thereby improving the efficiency of data utilization.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of computer application technology, and in particular to a data query method, device and electronic device. Background Art

[0002] At present, in analysis and marketing scenarios, business personnel usually use visual interface rules to provide basic rules, custom rules and other functions for business personnel in a visual graphical interface, so that business personnel can perform simple operations based on the visual interface rules to obtain the required data information. However, when the business personnel have more complex business needs, the visual interface rules cannot meet the current business needs, and then it is necessary to use structured query language (SQL) to perform query operations in the database to meet the business needs of business personnel.

[0003] However, the existing technology method has high technical requirements for business personnel because of the SQL query method, and this method is an offline operation method. Therefore, there are problems such as limiting the application of business personnel and failing to meet the real-time business needs of business personnel, thereby reducing the efficiency of data utilization. Summary of the invention

[0004] In order to solve the above technical problems or at least partially solve the above technical problems, the embodiments of the present disclosure provide a data query method, device and electronic device.

[0005] In a first aspect, the present disclosure provides a data query method, comprising:

[0006] Obtaining a query request message, wherein the query request message includes a query request statement and a query request expression, and the query request message is determined according to an entity tag, an operator, and a function;

[0007] Parsing the query request message to obtain at least one metadata corresponding to the query request message;

[0008] Based on at least one of the metadata, a query is performed according to an abstract syntax tree to obtain a query result corresponding to the query request message, wherein the abstract syntax tree includes a first abstract syntax tree and a second abstract syntax tree, the first abstract syntax tree is obtained according to the query request message, and the second abstract syntax tree is obtained according to a preset query language generated according to the query request message, and the preset query language includes at least a structured query language and a distributed query language.

[0009] In one embodiment, before parsing the query request message, the method further includes:

[0010] A front-end syntax check is performed on the query request message, wherein the front-end syntax check at least includes: operator check, function integrity check, and expression return data type check.

[0011] In one embodiment, before performing a query based on the at least one metadata and according to the abstract syntax tree to obtain a query result corresponding to the query request message, the method further includes:

[0012] Based on at least one of the metadata, obtaining a field corresponding to each of the metadata;

[0013] A backend syntax check is performed on each field corresponding to the metadata, wherein the backend syntax check at least includes: the field authorization check and the field type matching check.

[0014] In one embodiment, the querying based on the at least one metadata according to the abstract syntax tree to obtain the query result corresponding to the query request message includes:

[0015] Determining whether the query request message meets the real-time condition;

[0016] When it is determined that the query request message meets the real-time condition, a query is performed according to the first abstract syntax tree based on at least one of the metadata to obtain a query result corresponding to the query request message.

[0017] In one embodiment, the method further comprises:

[0018] When it is determined that the query request message does not meet the real-time condition, a query is performed according to the second abstract syntax tree based on at least one of the metadata to obtain a query result corresponding to the query request message.

[0019] In one embodiment, the querying according to the second abstract syntax tree based on at least one of the metadata to obtain a query result corresponding to the query request message includes:

[0020] Determining at least one key metadata in at least one metadata according to a priority of at least one clause included in the query request message;

[0021] Determine, based on at least one of the key metadata, a query statement corresponding to the preset query language generated by the query statement message;

[0022] Based on the query statement, a query is performed according to the second abstract syntax tree to obtain a query result corresponding to the query request message.

[0023] In one embodiment, the obtaining the query request message includes:

[0024] Obtaining the query request statement input by the user; and / or

[0025] The query request expression is generated based on the entity tag, the operator and the function.

[0026] In one embodiment, the method further comprises:

[0027] In response to the query request message, the query result corresponding to the query request message is displayed on the query result page.

[0028] In a second aspect, the present disclosure provides a data query device, comprising:

[0029] A query request message acquisition module, used to acquire a query request message, wherein the query request message includes a query request statement and a query request expression, the query request message is determined according to an entity tag, an operator and a function, and the entity includes at least a user, a customer and a product;

[0030] A query request message parsing module, used to parse the query request message to obtain at least one metadata corresponding to the query request message;

[0031] A query result obtaining module is used to perform a query based on at least one of the metadata and according to an abstract syntax tree to obtain a query result corresponding to the query request message, wherein the abstract syntax tree includes a first abstract syntax tree and a second abstract syntax tree, the first abstract syntax tree is obtained according to the query request message, and the second abstract syntax tree is obtained according to a preset query language generated according to the query request message, and the preset query language includes at least a structured query language and a distributed query language.

[0032] In a third aspect, an embodiment of the present disclosure provides an electronic device, including:

[0033] one or more processors;

[0034] a storage device for storing one or more programs,

[0035] When the one or more programs are executed by the one or more processors, the one or more processors implement any method as described in the first aspect.

[0036] Compared with the prior art, the technical solution provided by the embodiments of the present disclosure has the following advantages:

[0037] By obtaining a query request message, wherein the query request message includes a query request statement and a query request expression, and the query request message is determined according to an entity tag, an operator and a function; parsing the query request message to obtain at least one metadata corresponding to the query request message; based on the at least one metadata, querying according to an abstract syntax tree to obtain a query result corresponding to the query request message, wherein the abstract syntax tree includes a first abstract syntax tree and a second abstract syntax tree, the first abstract syntax tree is obtained according to the query request message, and the second abstract syntax tree is obtained according to a preset query language generated according to the query request message, and the preset query language at least includes a structured query language and a distributed query language, that is, by using entity tags when defining query request messages, so that users such as business personnel can flexibly use query request messages defined based on entity tags to perform data queries, and different abstract syntax trees can be used to obtain query results for different query request messages, thereby avoiding the problem of being unable to meet the real-time requirements of query request messages in the prior art, and improving the efficiency of data utilization. BRIEF DESCRIPTION OF THE DRAWINGS

[0038] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.

[0039] In order to more clearly illustrate the embodiments of the present invention 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, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0040] Figure 1 A flowchart of a data query method provided by an embodiment of the present disclosure;

[0041] Figure 2 A flowchart of another data query method provided by an embodiment of the present disclosure;

[0042] Figure 3 A flowchart of another data query method provided in an embodiment of the present disclosure;

[0043] Figure 4 A flowchart of another data query method provided by an embodiment of the present disclosure;

[0044] Figure 5 A flowchart of another data query method provided by an embodiment of the present disclosure;

[0045] Figure 6 A schematic diagram of the structure of a data query device provided by an embodiment of the present disclosure;

[0046] Figure 7 A schematic diagram of the structure of an electronic device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION

[0047] In order to more clearly understand the above-mentioned objectives, features and advantages of the present disclosure, the scheme of the present disclosure will be further described below. It should be noted that the embodiments of the present disclosure and the features in the embodiments can be combined with each other without conflict.

[0048] In the following description, many specific details are set forth to facilitate a full understanding of the present disclosure, but the present disclosure may also be implemented in other ways different from those described herein; it is obvious that the embodiments in the specification are only part of the embodiments of the present disclosure, rather than all of the embodiments.

[0049] At present, in analysis and marketing scenarios, business personnel usually use visual interface rules to provide basic rules, custom rules and other functions for business personnel in a visual graphical interface, so that business personnel can perform simple operations based on the visual interface rules to obtain the required data information. However, when the business personnel have more complex business needs, the visual interface rules cannot meet the current business needs, and then it is necessary to use structured query language (SQL) to perform query operations in the database to meet the business needs of business personnel.

[0050] However, the existing technology method has high technical requirements for business personnel because of the SQL query method, and this method is an offline operation method. Therefore, there are problems such as limiting the application of business personnel and failing to meet the real-time business needs of business personnel, thereby reducing the efficiency of data utilization.

[0051] Therefore, the present disclosure provides a data query method, which obtains a query request message, wherein the query request message includes a query request statement and a query request expression, and the query request message is determined according to an entity tag, an operator and a function; the query request message is parsed and processed to obtain at least one metadata corresponding to the query request message; based on the at least one metadata, a query is performed according to an abstract syntax tree to obtain a query result corresponding to the query request message, wherein the abstract syntax tree includes a first abstract syntax tree and a second abstract syntax tree, the first abstract syntax tree is obtained according to the query request message, and the second abstract syntax tree is obtained according to a preset query language generated according to the query request message, and the preset query language at least includes a structured query language and a distributed query language, that is, by using entity tags when defining query request messages, so that users such as business personnel can flexibly use query request messages defined based on entity tags to perform data queries, and different abstract syntax trees can be used to obtain query results for different query request messages, thereby avoiding the problem of being unable to meet the real-time requirements of query request messages in the prior art, and improving the efficiency of data utilization.

[0052] The data query method provided by the present disclosure can be applied to a data query device, which can be various electronic devices such as personal computers, laptops, smart phones, tablet computers and portable wearable devices. Optionally, the device can also be a functional module or functional entity in these electronic devices that can implement the data query method.

[0053] Figure 1 A flowchart of a data query method provided by an embodiment of the present disclosure is shown in FIG. Figure 1 As shown, specifically including:

[0054] S11, obtaining a query request message.

[0055] The query request message includes a query request statement and a query request expression, and the query request message is determined according to the entity tag, operator and function.

[0056] The above-mentioned entities include but are not limited to customers, users and products. The entity label refers to the corresponding label information determined according to the attribute information of the entity. For example, when the entity is customer A, the label corresponding to the attribute information of customer A may be name, age, and address; when the entity is a product, the label of the product may be an investment product, but is not limited to this. The present disclosure does not specifically limit it, and those skilled in the art may set it according to actual conditions.

[0057] An operator is a function used to execute program code operations and to perform operations on one or more operand items. For example, the operator includes but is not limited to logical, comparison, and arithmetic operators.

[0058] A function is constructed based on an entity and is used to execute calculations in program code. For example, the function may be the current date: current_date(), adding a date: datetime_add(), filtering an object array: filter(), whether an array contains a single element: includes(), but is not limited to this. The present disclosure does not specifically limit this, and those skilled in the art may set it according to actual conditions.

[0059] It should be noted that the above operators and functions are used to calculate query request expressions. Further, the entity tags, operators and functions are pre-set by technicians based on different entities, so that users can flexibly obtain query request messages based on the entity tags, operators and functions.

[0060] Specifically, a terminal such as a mobile phone obtains the query request message in the query request message editing interface.

[0061] The above-mentioned query request message editing interface refers to a data query component built based on a data query method. This component encapsulates the processing flow of data query and provides it to users in the form of a visual interface, so that users can directly operate on the visual interface to meet the needs of different users.

[0062] On the basis of the above embodiments, in some embodiments of the present disclosure, an implementation of S11 is:

[0063] Get the query request statement entered by the user.

[0064] The query request statement refers to a query request statement for querying input by a user such as a business person in a query request message editing interface.

[0065] For example, when a business person needs to query customers whose assets are between 100,000 and 500,000, the query request statement entered in the query request message editing interface is "user.ASSETS>=100000oruser.ASSETS<500000", but is not limited to this. The present disclosure does not specifically limit this, and technicians in this field can set it according to actual conditions.

[0066] Optionally, based on the above embodiments, in some embodiments of the present disclosure, another implementation of S11 is:

[0067] Generate query request expressions based on entity tags, operators, and functions.

[0068] Among them, the query request expression refers to the operation of clicking a virtual button by a user such as a business personnel in the query request message editing interface. The terminal responds and receives the entity label, operator, function and other parameters corresponding to the virtual button clicked by the user, and generates a corresponding query request expression according to the grammatical structure. Exemplarily, the query request expression can be "{ENTITY_1},{ENTITY_2},...)=>{RESULT_TYPE}". This is but not limited to this. The present disclosure does not specifically limit it, and technical personnel in this field can set it according to actual conditions.

[0069] Optionally, based on the above embodiment, when a query request message is input in the query request message editing interface, a corresponding query catalog may be generated based on the query request message to facilitate viewing by users such as business personnel.

[0070] In this way, the data query method provided by the present invention obtains data query messages by either user inputting query request statements or directly generating query request expressions based on entity tags, operators and functions, so that different users can choose the appropriate method to perform query operations according to their needs, thereby improving the user experience.

[0071] Optionally, based on the above embodiments, in some embodiments of the present disclosure, further, as Figure 2 As shown, before executing S13, it also includes:

[0072] S12, performing front-end syntax verification on the query request message.

[0073] Among them, the front-end syntax check includes at least: operator check, function integrity check, and expression return data type check.

[0074] The above-mentioned operator check refers to judging whether the data types of the left value and the right value of the operator must be consistent. When they are consistent, it means that the current query request message satisfies the operator check. When they are inconsistent, a prompt message is issued to prompt the user. Exemplarily, for the query request message "user.age-2022-01-01", by judging that the data types of the left value and the right value of the operator "-" are inconsistent, it is determined that the query request message has not passed the operator check. Then, a prompt message such as "The data types of the operator {operator} left value {data type} and the right value {data type} do not match" will be issued on the query request message syntax check interface of the data query component, but it is not limited to this. The present disclosure is not specifically limited, and those skilled in the art can make specific settings according to actual conditions.

[0075] Function integrity check is to check whether the function parameter structure is legal. If it is illegal, a prompt message will be issued to prompt the user. For example, for the function "datetime_add(current_date(),7)", if the function integrity check determines that the function is illegal, a prompt message such as "{parameter} is required" will be issued in the query request message syntax check interface of the data query component, but it is not limited to this. The present disclosure does not specifically limit it, and those skilled in the art can make specific settings according to actual conditions.

[0076] Expression return data type verification refers to verification based on the data type defined in the passed parameters, where the expression return data type includes but is not limited to strings, numbers, dates, Booleans, sets, objects, and object arrays. For example, the return value of the current data query request message should be a Boolean type, but the actual return value type is a string, then a prompt message such as "The return value of the expression must be {the data type in the parameter}" is issued, but is not limited to this. The present disclosure does not specifically limit this, and those skilled in the art can make specific settings based on actual conditions.

[0077] It should be noted that the front-end syntax check may also include entity attribute correctness check, permission check, etc., but is not limited to this. The present disclosure does not specifically limit this, and those skilled in the art may make specific settings according to actual conditions.

[0078] In this way, the data query method provided by the present invention needs to verify the query request message before parsing it, so as to filter out the query request messages that do not meet the front-end syntax verification rules, avoid continuing to execute subsequent steps, and thus save resources.

[0079] S13, parsing the query request message to obtain at least one metadata corresponding to the query request message.

[0080] Among them, metadata refers to the data constituting the query request message obtained after parsing the query request message using the grammatical structure. For example, the metadata can be an entity tag such as a name tag: user.$name, an object array tag: user.ASSETS_HOLD, and an event name tag: user.events.event==event_name.

[0081] Optionally, based on the above embodiments, in some embodiments of the present disclosure, further, as Figure 3 As shown, before executing S15, it also includes:

[0082] S141, based on at least one metadata, obtaining a field corresponding to each metadata.

[0083] The field refers to the field corresponding to each metadata in the query request message. For example, for the data query request message "user.ASSETS>=100000oruser.ASSETS <500000", after parsing, the metadata corresponding fields "user.ASSETS, > =,100000,or,user.ASSETS,<,500000”.

[0084] S142, performing backend syntax verification on the fields corresponding to each metadata.

[0085] Among them, the backend syntax check at least includes: field authorization check and field type matching check.

[0086] The above-mentioned field authorization check refers to whether permissions are set for the fields of the corresponding metadata in the query request message when the query request message is based on the entity definition, so as to determine whether the fields corresponding to the metadata can be used. If authorized, the field authorization check is passed. If not authorized, a prompt message is issued and an error prompt is given.

[0087] Field type matching check refers to whether the pre-defined data type of the field corresponding to the metadata matches the data type obtained after the current parsing. If they match, the field type matching check is performed. If they do not match, a prompt message is issued and an error prompt is given.

[0088] S15, based on at least one metadata, perform a query according to the abstract syntax tree to obtain a query result corresponding to the query request message.

[0089] The abstract syntax tree includes a first abstract syntax tree and a second abstract syntax tree. The first abstract syntax tree is obtained according to a query request message, and the second abstract syntax tree is obtained according to a preset query language generated according to the query request message. The preset query language includes at least a structured query language and a distributed query language.

[0090] The above-mentioned abstract syntax tree refers to an abstract representation of the syntax structure of the source code, which represents the syntax structure of the programming language in a tree form, and each node on the tree represents a structure in the source code.

[0091] The first abstract syntax tree is a syntax tree corresponding to a query request message based on entity tags, operators, and function definitions, that is, the first abstract syntax tree is essentially constructed based on entities. The second abstract syntax tree is obtained from a preset query language generated according to the query request message, and the preset query language includes at least a structured query language and a distributed query language, wherein the distributed query language refers to a preset query language with a distributed search engine, such as Elasticsearch Domain Specific Language (DSL), but is not limited to this, and the present disclosure does not specifically limit it.

[0092] Based on the above embodiments, in some embodiments of the present disclosure, such as Figure 4 As shown, one implementation of S15 is:

[0093] S151, determining whether the query request message meets the real-time condition.

[0094] Among them, the real-time condition refers to the real-time requirement for the user's query request message. Exemplarily, it can be determined whether the query request message meets the real-time condition by judging whether the user's query request message needs to be responded to within a preset time and feeding back a result value. The preset time is not specifically limited in this disclosure, and the definition of the real-time condition is not specifically limited in this disclosure, and those skilled in the art can set it according to actual conditions.

[0095] S152: When it is determined that the query request message meets the real-time condition, based on at least one metadata, a query is performed according to the first abstract syntax tree to obtain a query result corresponding to the query request message.

[0096] Specifically, when it is determined that the current query request message meets the real-time condition, a traversal query is performed according to the first abstract syntax tree based on the entity definition according to multiple metadata obtained by parsing the query request message, so as to obtain the query result corresponding to the query request message.

[0097] Exemplarily, when the query request message is "determine the winning customer among all customers who have purchased product A in the past 7 days", it is determined that the query request message needs to be responded to quickly, that is, it meets the real-time condition, then according to multiple metadata, a traversal query is performed in a timely manner according to the first abstract syntax tree based on the entity definition, and the query result corresponding to the query request message is that customer A is the winning customer.

[0098] Based on the above embodiments, in some embodiments of the present disclosure, such as Figure 4 As shown, another implementation of S15 is:

[0099] S153: When it is determined that the query request message does not meet the real-time condition, a query is performed according to the second abstract syntax tree based on at least one metadata to obtain a query result corresponding to the query request message.

[0100] Specifically, when it is determined that the current query request message does not meet the real-time condition, a second abstract syntax tree corresponding to a preset query language generated according to the current query request message is traversed and queried based on multiple metadata obtained by parsing the query request message, so as to obtain a query result corresponding to the query request message.

[0101] Based on the above embodiments, in some embodiments of the present disclosure, such as Figure 5 As shown, one implementation of S153 is:

[0102] S1531: Determine at least one key metadata in at least one metadata according to the priority of at least one clause included in the query request message.

[0103] The priority refers to determining the order of operations for processing multiple clauses in the query request message according to the priority of functions and operators, etc. The key metadata includes but is not limited to the functions and operators included in the query request message.

[0104] Specifically, during the execution of the query request message, the priorities of multiple clauses in the query request message are determined according to the function and the operator, and multiple key metadata are determined from the multiple metadata in each clause according to the priorities.

[0105] Exemplarily, the query request message is "user.events.filter(user.events.event=='wealthpageView'and(user.events.date>=to_datetime(datetime_add(current_date(),-7,'DAY'))and user.events.date<=to_datetime(current_date())))". When parsing the query request message, if it is determined that the query request message contains a filter clause, the filter clause is parsed first, and then it is determined whether there is a logical operator in the clause. When it is determined that the query request message contains a logical operator, the key metadata is determined to be the logical operator such as and, and the left clause and the right clause of the logical operator are further parsed to determine whether there are calculation functions in the left clause and the right clause. If so, the key metadata is determined to be the calculation function such as datetime_add() and to_datetime().

[0106] S1532: Determine, based on at least one key metadata, a query statement corresponding to a preset query language generated by the query statement message.

[0107] Specifically, after determining a plurality of key metadata included in the query statement message, the plurality of key metadata are parsed, and based on the parsing results of the plurality of metadata, a query statement corresponding to a preset query language generated by the query statement message is obtained.

[0108] Exemplarily, for the above query request message "user.events.filter(user.events.event=='wealthpageView'and(user.events.date>=to_datetime(datetime_add(current_date(),-7,'DAY'))and user.events.date<=to_datetime(current_date())))", the above preset query language is an SQL statement. After determining key metadata such as functions datetime_add() and to_datetime(), the functions datetime_add() and to_datetime() are parsed to obtain their corresponding SQL clauses respectively, and multiple SQL clauses are concatenated to generate an SQL query statement.

[0109] S1533: Based on the query statement, query is performed according to the second abstract syntax tree to obtain a query result corresponding to the query request message.

[0110] Specifically, when converting the query request message into a query statement corresponding to the preset query language, the query statement is parsed, and a traversal query is performed according to the second abstract syntax tree corresponding to the current query statement, so as to obtain a query result corresponding to the query request message.

[0111] In this way, the data query method provided by this embodiment obtains a query request message, wherein the query request message includes a query request statement and a query request expression, and the query request message is determined according to an entity tag, an operator, and a function; parses and processes the query request message to obtain at least one metadata corresponding to the query request message; based on the at least one metadata, queries are performed according to an abstract syntax tree to obtain a query result corresponding to the query request message, wherein the abstract syntax tree includes a first abstract syntax tree and a second abstract syntax tree, the first abstract syntax tree is obtained according to the query request message, and the second abstract syntax tree is obtained according to a preset query language generated according to the query request message, and the preset query language includes at least a structured query language and a distributed query language, that is, by using entity tags when defining the query request message, so that users such as business personnel can flexibly use query request messages defined based on entity tags to perform data queries, and different abstract syntax trees can be used to obtain query results for different query request messages, thereby avoiding the problem of being unable to meet the real-time requirements of query request messages in the prior art, and improving the efficiency of data utilization.

[0112] On the basis of the above embodiments, in some embodiments of the present disclosure, after executing S15, the method further includes:

[0113] In response to the query request message, the query result corresponding to the query request message is displayed on the query result page.

[0114] Specifically, when a query request message is received, the query request message is responded to, and the query result corresponding to the query request message is further displayed on the query result page.

[0115] In this way, the data query method provided in this embodiment can respond to the query request message and display the query result to the user on the query result page, thereby improving the user experience.

[0116] The disclosed embodiment also provides a data query device, which is used to execute any one of the data query methods provided in the above embodiments, and has the corresponding beneficial effects of the data query method.

[0117] Figure 6 A schematic diagram of a data query device provided by an embodiment of the present disclosure is shown in FIG. Figure 6 As shown, the data query device includes: a query request message acquisition module 11, a query request message parsing module 13 and a query result obtaining module 15.

[0118] The query request message acquisition module 11 is used to acquire a query request message, wherein the query request message includes a query request statement and a query request expression, the query request message is determined according to an entity tag, an operator and a function, and the entity includes at least a user, a customer and a product;

[0119] A query request message parsing module 13, configured to parse the query request message to obtain at least one metadata corresponding to the query request message;

[0120] The query result obtaining module 15 is used to perform a query according to an abstract syntax tree based on at least one metadata to obtain a query result corresponding to the query request message, wherein the abstract syntax tree includes a first abstract syntax tree and a second abstract syntax tree, the first abstract syntax tree is obtained according to the query request message, and the second abstract syntax tree is obtained according to a preset query language generated according to the query request message, and the preset query language includes at least a structured query language and a distributed query language.

[0121] In one implementation of the disclosed embodiment, the query request message acquisition module 11 includes a front-end syntax check module for performing front-end syntax check on the query request message, wherein the front-end syntax check includes at least: operator check, function integrity check, and expression return data type check.

[0122] In one implementation of the embodiment of the present disclosure, the query request message parsing module 13 includes a back-end syntax verification module, which is used to obtain the fields corresponding to each metadata based on at least one metadata; and perform back-end syntax verification on the fields corresponding to each metadata, wherein the back-end syntax verification includes at least: field authorization verification and field type matching verification.

[0123] In one implementation of the embodiment of the present disclosure, the query result obtaining module 15 is specifically used to determine whether the query request message meets the real-time condition; when it is determined that the query request message meets the real-time condition, based on at least one of the metadata, a query is performed according to the first abstract syntax tree to obtain a query result corresponding to the query request message.

[0124] In one implementation of the disclosed embodiment, the query result obtaining module 15 is further used to perform a query based on the second abstract syntax tree based on at least one metadata to obtain a query result corresponding to the query request message when it is determined that the query request message does not meet the real-time condition.

[0125] In one implementation of the embodiment of the present disclosure, the query result obtaining module 15 is further specifically used to determine at least one key metadata in at least one metadata according to the priority of at least one clause included in the query request message; based on the at least one key metadata, determine the query statement corresponding to the preset query language generated by the query statement message; based on the query statement, perform a query according to the second abstract syntax tree to obtain a query result corresponding to the query request message.

[0126] In an implementation of an embodiment of the present disclosure, the query request message acquisition module 11 is specifically used to acquire a query request statement input by a user; and / or generate a query request expression based on entity tags, operators and functions.

[0127] In an implementation of an embodiment of the present disclosure, the query result obtaining module 15 includes a query result display module, which is used to display the query result corresponding to the query request message on the query result page in response to the query request message.

[0128] In the technical solution provided by the embodiment of the present disclosure, a query request message acquisition module 11 is used to acquire a query request message, wherein the query request message includes a query request statement and a query request expression, the query request message is determined according to an entity tag, an operator and a function, and the entity includes at least a user, a customer and a product; a query request message parsing module 13 is used to parse the query request message to obtain at least one metadata corresponding to the query request message; a query result obtaining module 15 is used to perform a query according to an abstract syntax tree based on the at least one metadata to obtain a query result corresponding to the query request message, wherein the abstract syntax tree includes a first abstract syntax tree and a second abstract syntax tree, the first abstract syntax tree is obtained according to the query request message, and the second abstract syntax tree is obtained according to a preset query language generated according to the query request message, and the preset query language includes at least a structured query language and a distributed query language, that is, by using entity tags when defining the query request message, users such as business personnel can flexibly use the query request message defined based on the entity tags to perform data queries, and different abstract syntax trees can be used to obtain query results for different query request messages, thereby avoiding the problem of being unable to meet the real-time requirements of the query request message in the prior art and improving the efficiency of data utilization.

[0129] The device of this embodiment can be used to perform the above Figures 1 to 5 The technical solution of any of the method embodiments shown has similar implementation principles and technical effects, which will not be repeated here.

[0130] It is worth noting that in the embodiment of the above-mentioned device, the various units and modules included are only divided according to functional logic, but are not limited to the above-mentioned division, as long as the corresponding functions can be achieved; in addition, the specific names of the functional units are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of the present invention.

[0131] Figure 7 is a schematic diagram of the structure of an electronic device provided by an embodiment of the present disclosure, such as Figure 7 As shown, the electronic device includes a processor 710, a memory 720, an input device 730, and an output device 740; the number of the processor 710 in the electronic device can be one or more. Figure 7 A processor 710 is taken as an example; the processor 710, the memory 720, the input device 730 and the output device 740 in the electronic device can be connected via a bus or other means. Figure 7 The example of connecting through bus is taken in the following.

[0132] The memory 720 is a computer-readable storage medium that can be used to store software programs, computer executable programs and modules, such as program instructions / modules corresponding to the method in the embodiment of the present invention. The processor 710 executes various functional applications and data processing of the electronic device by running the software programs, instructions and modules stored in the memory 720, that is, implements the method provided in the embodiment of the present invention.

[0133] The memory 720 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system and at least one application required for a function; the data storage area may store data created according to the use of the terminal, etc. In addition, the memory 720 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage device. In some instances, the memory 720 may further include a memory remotely arranged relative to the processor 710, and these remote memories may be connected to the electronic device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0134] The input device 730 may be used to receive input digital or character information and generate key signal input related to user settings and function control of the electronic device, and may include a keyboard, a mouse, etc. The output device 740 may include a display device such as a display screen.

[0135] The present disclosure also provides a computer-readable storage medium having a computer program stored thereon, which implements Figures 1 to 5 A technical solution of any of the method embodiments shown.

[0136] It should be noted that, in this article, relational terms such as "first" and "second" 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 existence of other identical elements in the process, method, article or device including the elements.

[0137] The above description is only a specific embodiment of the present disclosure, so that those skilled in the art can understand or implement the present disclosure. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present disclosure. Therefore, the present disclosure will not be limited to the embodiments described herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A data query method, characterized in that: The method comprises: Obtaining a query request message, wherein the query request message includes a query request statement and a query request expression, the query request message is determined according to an entity tag, an operator, and a function, the entity tag is corresponding tag information determined according to attribute information of an entity, the entity includes at least a user, a customer, and a product, the entity tag includes a name tag, an object array tag, and an event name tag, a virtual button is provided in a query request message editing interface, the virtual button corresponds to an entity tag, an operator, and a function, and a corresponding query request expression is generated according to a grammatical structure through the entity tag, the operator, and the function corresponding to the virtual button clicked by the user; Parsing the query request message to obtain at least one metadata corresponding to the query request message; Based on at least one of the metadata, query is performed according to an abstract syntax tree to obtain a query result corresponding to the query request message, wherein the abstract syntax tree includes a first abstract syntax tree and a second abstract syntax tree, the first abstract syntax tree is a syntax tree corresponding to the query request message based on entity tags, operators, and function definitions, and the second abstract syntax tree is obtained according to a preset query language generated according to the query request message, and the preset query language includes at least a structured query language and a distributed query language; The querying based on the at least one metadata and according to the abstract syntax tree to obtain the query result corresponding to the query request message includes: Determining whether the query request message meets the real-time condition; When it is determined that the query request message meets the real-time condition, querying according to the first abstract syntax tree based on at least one of the metadata to obtain a query result corresponding to the query request message; When it is determined that the query request message does not meet the real-time condition, a query is performed according to the second abstract syntax tree based on at least one of the metadata to obtain a query result corresponding to the query request message.

2. The method according to claim 1, characterized in that Before parsing the query request message, the method further includes: A front-end syntax check is performed on the query request message, wherein the front-end syntax check at least includes: operator check, function integrity check, and expression return data type check.

3. The method according to claim 1, characterized in that Before performing a query based on the at least one metadata according to the abstract syntax tree to obtain a query result corresponding to the query request message, the method further includes: Based on at least one of the metadata, obtaining a field corresponding to each of the metadata; A backend syntax check is performed on each field corresponding to the metadata, wherein the backend syntax check at least includes: field authorization check and field type matching check.

4. The method according to claim 1, characterized in that: The querying according to the second abstract syntax tree based on at least one of the metadata to obtain a query result corresponding to the query request message includes: Determining at least one key metadata in at least one metadata according to a priority of at least one clause included in the query request message; Determine, based on at least one of the key metadata, a query statement corresponding to the preset query language generated by the query statement message; Based on the query statement, a query is performed according to the second abstract syntax tree to obtain a query result corresponding to the query request message.

5. The method according to claim 1, characterized in that: The obtaining query request message includes: Obtaining the query request statement input by the user; and / or The query request expression is generated based on the entity tag, the operator and the function.

6. The method according to claim 1, characterized in that The method further comprises: In response to the query request message, the query result corresponding to the query request message is displayed on the query result page.

7. A data query device, characterized in that: include: A query request message acquisition module is used to acquire a query request message, wherein the query request message includes a query request statement and a query request expression, the query request message is determined according to an entity tag, an operator and a function, the entity tag is corresponding tag information determined according to attribute information of an entity, the entity includes at least a user, a customer and a product, the entity tag includes a name tag, an object array tag and an event name tag, a virtual button is provided in the query request message editing interface, the virtual button corresponds to an entity tag, an operator and a function, and a corresponding query request expression is generated according to a grammatical structure through the entity tag, the operator and the function corresponding to the virtual button clicked by the user; A query request message parsing module, used to parse the query request message to obtain at least one metadata corresponding to the query request message; A query result obtaining module, configured to perform a query based on at least one of the metadata and an abstract syntax tree to obtain a query result corresponding to the query request message, wherein the abstract syntax tree includes a first abstract syntax tree and a second abstract syntax tree, the first abstract syntax tree is a syntax tree corresponding to the query request message based on entity tags, operators, and function definitions, and the second abstract syntax tree is obtained according to a preset query language generated according to the query request message, and the preset query language includes at least a structured query language and a distributed query language; The querying based on the at least one metadata and according to the abstract syntax tree to obtain the query result corresponding to the query request message includes: Determining whether the query request message meets the real-time condition; When it is determined that the query request message meets the real-time condition, querying according to the first abstract syntax tree based on at least one of the metadata to obtain a query result corresponding to the query request message; When it is determined that the query request message does not meet the real-time condition, a query is performed according to the second abstract syntax tree based on at least one of the metadata to obtain a query result corresponding to the query request message.

8. An electronic device, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • Method and system for converting query sentence of database

    CN101788992A

  • Data query method, system and device

    CN110399388A

  • Data query method and device, electronic equipment and computer readable storage medium

    CN111563094A

  • Method and device for querying metadata and electronic equipment

    CN113297273A