[go: up one dir, main page]

CN114661714B - Data query method, device and electronic device - Google Patents

Data query method, device and electronic device Download PDF

Info

Publication number
CN114661714B
CN114661714B CN202210255856.8A CN202210255856A CN114661714B CN 114661714 B CN114661714 B CN 114661714B CN 202210255856 A CN202210255856 A CN 202210255856A CN 114661714 B CN114661714 B CN 114661714B
Authority
CN
China
Prior art keywords
request message
query request
query
syntax tree
abstract syntax
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202210255856.8A
Other languages
Chinese (zh)
Other versions
CN114661714A (en
Inventor
桑文锋
刘耀洲
曹犟
付力力
王琛
郝栋
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Sensors Data Network Technology Beijing Co Ltd
Original Assignee
Sensors Data Network Technology Beijing Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Sensors Data Network Technology Beijing Co Ltd filed Critical Sensors Data Network Technology Beijing Co Ltd
Priority to CN202210255856.8A priority Critical patent/CN114661714B/en
Publication of CN114661714A publication Critical patent/CN114661714A/en
Application granted granted Critical
Publication of CN114661714B publication Critical patent/CN114661714B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/22Indexing; Data structures therefor; Storage structures
    • G06F16/2228Indexing structures
    • G06F16/2246Trees, e.g. B+trees
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/242Query formulation
    • G06F16/2433Query languages
    • G06F16/2448Query languages for particular applications; for extensibility, e.g. user defined types
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2457Query processing with adaptation to user needs
    • G06F16/24573Query processing with adaptation to user needs using data annotations, e.g. user-defined metadata
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2458Special types of queries, e.g. statistical queries, fuzzy queries or distributed queries
    • G06F16/2465Query processing support for facilitating data mining operations in structured databases
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2458Special types of queries, e.g. statistical queries, fuzzy queries or distributed queries
    • G06F16/2471Distributed queries
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Databases & Information Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • General Physics & Mathematics (AREA)
  • Computational Linguistics (AREA)
  • Mathematical Physics (AREA)
  • Software Systems (AREA)
  • Fuzzy Systems (AREA)
  • Probability & Statistics with Applications (AREA)
  • Library & Information Science (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

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.

Description

Data query method and device and electronic equipment
Technical Field
The disclosure relates to the technical field of computer application, and in particular relates to a data query method, a data query device and electronic equipment.
Background
At present, in an analysis and marketing scene, a service person generally performs simple operation in a visual graphical interface in a manner of a visual interface rule according to functions of providing basic rules, custom rules and the like for the service person, so that the service person can obtain required data information in a manner based on the visual interface rule, but when the service person has complex service requirements, the manner of the visual interface rule cannot meet the current service requirements, and further, query operation is performed in a database by utilizing a structured query language (Structured Query Language, SQL) so as to meet the service requirements of the service person.
However, with the method in the prior art, the technical requirement on the service personnel is higher in the way of querying by using SQL, and the way belongs to the way of offline operation, so that the problems of limiting the application of the service personnel and failing to meet the real-time performance of the service requirements of the service personnel exist, and the utilization efficiency of data is reduced.
Disclosure of Invention
In order to solve the above technical problems or at least partially solve the above technical problems, an embodiment of the present disclosure provides a data query method, a device, and an electronic device.
In a first aspect, the present disclosure provides a data query method, including:
Obtaining a query request message, wherein the query request message comprises 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;
Analyzing the query request message to obtain at least one piece of metadata corresponding to the query request message;
Based on at least one metadata, inquiring according to an abstract syntax tree to obtain an inquiry result corresponding to the inquiry request message, wherein the abstract syntax tree comprises a first abstract syntax tree and a second abstract syntax tree, the first abstract syntax tree is obtained according to the inquiry request message, the second abstract syntax tree is obtained according to a preset inquiry language generated by the inquiry request message, and the preset inquiry language at least comprises a structured inquiry language and a distributed inquiry language.
In one embodiment, before the parsing process is performed on the query request message, the method further includes:
and performing front-end grammar checking on the query request message, wherein the front-end grammar checking at least comprises operator checking, function integrity checking and expression return data type checking.
In one embodiment, before the querying is performed according to the abstract syntax tree based on at least one metadata to obtain the query result corresponding to the query request message, the method further includes:
acquiring a field corresponding to each piece of metadata based on at least one piece of metadata;
And performing back-end grammar checking on the field corresponding to each metadata, wherein the back-end grammar checking at least comprises the field authorization checking and the field type matching checking.
In one embodiment, the querying, based on at least one metadata, according to an abstract syntax tree to obtain a query result corresponding to the query request message includes:
judging whether the query request message meets real-time conditions or not;
And when the query request message is determined to meet the real-time condition, querying according to the first abstract syntax tree based on at least one piece of metadata to obtain a query result corresponding to the query request message.
In one embodiment, the method further comprises:
And when the query request message is determined not to meet the real-time condition, querying according to the second abstract syntax tree based on at least one piece of metadata to obtain a query result corresponding to the query request message.
In one embodiment, the querying, based on at least one metadata, according to the second abstract syntax tree, to obtain a query result corresponding to the query request message includes:
Determining at least one key metadata in at least one of the metadata according to the priority of at least one clause included in the query request message;
determining a query sentence corresponding to the preset query language generated by the query sentence message based on at least one key metadata;
And based on the query statement, querying according to the second abstract syntax tree to obtain a query result corresponding to the query request message.
In one embodiment, the acquiring the query request message includes:
acquiring 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.
In one embodiment, the method further comprises:
and responding to the query request message, and displaying a query result corresponding to the query request message on a query result page.
In a second aspect, the present disclosure provides a data query apparatus, comprising:
The query request message acquisition module is used for acquiring a query request message, wherein the query request message comprises 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 at least comprises a user, a client and a product;
The query request message analysis module is used for analyzing the query request message to obtain at least one metadata corresponding to the query request message;
The query result obtaining module is used for obtaining a query result corresponding to the query request message based on at least one metadata according to an abstract syntax tree, wherein the abstract syntax tree comprises a first abstract syntax tree and a second abstract syntax tree, the first abstract syntax tree is obtained according to the query request message, the second abstract syntax tree is obtained according to a preset query language generated by the query request message, and the preset query language at least comprises a structured query language and a distributed query language.
In a third aspect, an embodiment of the present disclosure provides an electronic device, including:
one or more processors;
storage means for storing one or more programs,
The one or more programs, when executed by the one or more processors, cause the one or more processors to implement the method of any of the first aspects.
Compared with the prior art, the technical scheme provided by the embodiment of the disclosure has the following advantages:
The method comprises the steps of obtaining query request information, analyzing the query request information to obtain at least one metadata corresponding to the query request information, and inquiring according to an abstract syntax tree based on the at least one metadata to obtain a query result corresponding to the query request information, wherein the abstract syntax tree comprises a first abstract syntax tree and a second abstract syntax tree, the first abstract syntax tree is obtained according to the query request information, the second abstract syntax tree is obtained according to a preset query language generated according to the query request information, and the preset query language at least comprises a structured query language and a distributed query language, namely, when the query request information is defined, the entity tag is utilized, so that users such as business personnel can flexibly use the query request information defined based on the entity tag to perform data query, and different abstract syntax trees can be utilized for obtaining the query result aiming at different query request information, thereby avoiding the problem that the real-time performance of the query request information cannot be satisfied in the prior art, and improving the utilization efficiency of the data.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the disclosure and together with the description, serve to explain the principles of the disclosure.
In order to more clearly illustrate the embodiments of the present disclosure or the solutions in the prior art, the drawings that are required for the description of the embodiments or the prior art will be briefly described below, and it will be obvious to those skilled in the art that other drawings can be obtained from these drawings without inventive effort.
Fig. 1 is a schematic flow chart of a data query method according to an embodiment of the disclosure;
FIG. 2 is a flowchart of another data query method according to an embodiment of the present disclosure;
Fig. 3 is a flowchart of another data query method according to an embodiment of the disclosure;
FIG. 4 is a flowchart of another data query method according to an embodiment of the present disclosure;
FIG. 5 is a flowchart of another data query method according to an embodiment of the present disclosure;
fig. 6 is a schematic structural diagram of a data query device according to an embodiment of the present disclosure;
Fig. 7 is a schematic structural diagram of an electronic device according to an embodiment of the present disclosure.
Detailed Description
In order that the above objects, features and advantages of the present disclosure may be more clearly understood, a further description of aspects of the present disclosure will be provided below. It should be noted that, without conflict, the embodiments of the present disclosure and features in the embodiments may be combined with each other.
In the following description, numerous specific details are set forth in order to provide a thorough understanding of the present disclosure, but the present disclosure may be practiced otherwise than as described herein, and it is apparent that the embodiments in the specification are only some, rather than all, of the embodiments of the present disclosure.
At present, in an analysis and marketing scene, a service person generally performs simple operation in a visual graphical interface in a manner of a visual interface rule according to functions of providing basic rules, custom rules and the like for the service person, so that the service person can obtain required data information in a manner based on the visual interface rule, but when the service person has complex service requirements, the manner of the visual interface rule cannot meet the current service requirements, and further, query operation is performed in a database by utilizing a structured query language (Structured Query Language, SQL) so as to meet the service requirements of the service person.
However, with the method in the prior art, the technical requirement on the service personnel is higher in the way of querying by using SQL, and the way belongs to the way of offline operation, so that the problems of limiting the application of the service personnel and failing to meet the real-time performance of the service requirements of the service personnel exist, and the utilization efficiency of data is reduced.
The data query method includes the steps of obtaining query request information, wherein the query request information comprises query request sentences and query request expressions, analyzing the query request information to obtain at least one metadata corresponding to the query request information, and obtaining query results corresponding to the query request information based on at least one metadata according to abstract syntax trees, wherein the abstract syntax trees comprise first abstract syntax trees and second abstract syntax trees, the first abstract syntax trees are obtained according to the query request information, the second abstract syntax trees are obtained according to preset query languages generated by the query request information, and the preset query languages at least comprise structured query languages and distributed query languages, namely, when the query request information is defined, the entity tags are utilized, so that users such as business personnel can flexibly use the query request information defined based on the entity tags to perform data query, and different abstract syntax trees can be utilized to obtain the query results, so that the real-time query efficiency of the query request information cannot be improved, and the problem that the real-time query efficiency of the prior art is solved.
The data query method provided by the disclosure can be applied to a data query device, and the device can be electronic equipment such as various personal computers, notebook computers, smart phones, tablet computers, portable wearable equipment and the like, and optionally, the device can also be a functional module or a functional entity which can realize the data query method in the electronic equipment.
Fig. 1 is a flow chart of a data query method provided by an embodiment of the present disclosure, as shown in fig. 1, specifically including:
s11, acquiring a query request message.
The query request message comprises a query request statement and a query request expression, and the query request message is determined according to entity tags, operators and functions.
The entity includes, but is not limited to, a customer, a user and a product, and the entity tag refers to corresponding tag information determined according to attribute information of the entity, and when the entity is the customer a, the tag corresponding to the attribute information of the customer a may be name, age or address, and when the entity is the product, the tag of the product may be an investment product, but is not limited thereto, and the disclosure is not particularly limited thereto, and a person skilled in the art may set according to practical situations.
Operators, which are intended to perform program code operations, operate on more than one operand item, include, by way of example and not limitation, logical, comparison, arithmetic operators;
The function is constructed based on an entity and is used for executing calculation of the program code, and the function can be, for example, a current date, a current_date (), a current date added value of datetime _add (), a filter of an object array, and whether the array contains a single element of include (), but is not limited to this, and can be set by a person skilled in the art according to practical situations.
It should be noted that the above operators and functions are used to calculate the query request expression. Further, the entity labels, operators and functions are preset for technicians based on different entities, so that a user can flexibly acquire the query request message based on the entity labels, operators and functions.
Specifically, the terminal, such as a mobile phone, obtains the query request message in the query request message editing interface.
The query request message editing interface is a data query component constructed based on a data query method, and the component encapsulates the processing flow of data query and provides the processing flow for users in a visual interface mode, so that the users can conveniently and directly operate on the visual interface, and the requirements of different users are met.
Based on the above embodiments, in some embodiments of the disclosure, one implementation of S11 is:
And acquiring a query request statement input by a user.
The query request statement refers to a query request statement input by a user, such as a service person, through a query request message editing interface.
For example, when a business person needs to query 10 to 50 thousands of clients of a client asset, a query request sentence is input in the query request message editing interface as "user.assets > =100000 oruser.assets <500000", but the present disclosure is not limited thereto, and those skilled in the art may set according to practical situations.
Optionally, on the basis of the foregoing embodiments, in some embodiments of the disclosure, a further implementation manner of S11 is:
based on the entity tags, operators, and functions, a query request expression is generated.
The query request expression refers to an operation of clicking a virtual key through a user, such as a service person, on a query request message editing interface, the terminal responds to and receives parameters, such as an ENTITY label, an operator, a function, and the like, corresponding to the virtual key clicked by the user, and generates a corresponding query request expression according to a grammar structure, and the query request expression may be "{ entity_1}, { entity_2},.+ -.) = > { result_type }" which is not limited thereto, and may be set by a person skilled in the art according to practical situations.
Optionally, on the basis of the above embodiment, when the query request message is input in the query request message editing interface, a corresponding query directory may also be generated based on the query request message, so as to facilitate a user, such as a service personnel, to check.
In this way, according to the data query method provided by the disclosure, the user inputs the query request statement by himself or directly generates two types of query request expressions based on the entity tag, the operator and the function to obtain the data query message, so that different users can select a proper mode to perform query operation according to their own needs, and user experience is improved.
Optionally, on the basis of the foregoing embodiments, in some embodiments of the present disclosure, further, as shown in fig. 2, before performing S13, the method further includes:
S12, performing front-end grammar check on the query request message.
The front-end grammar check at least comprises operator check, function integrity check and expression return data type check.
The operator check refers to judging that the data types of the left value and the right value of the operator are required to be consistent, when the data types are consistent, the current query request message is indicated to meet the operator check, and when the data types are inconsistent, prompt information is sent out, so that a user is prompted. For example, for the query request message "user.age-2022-01-01", by determining 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 fails to pass the operator verification, and then a prompt message such as "operator { operator } left value { data type }, right value { data type } data type mismatch" is sent out at the query request message syntax verification interface of the data query component, which is not limited thereto, and the disclosure is not specifically limited thereto, and can be specifically set by those skilled in the art according to actual situations.
The function integrity check is to check whether the parameter constitution of the function is legal or not, and when the parameter constitution is illegal, prompt information is sent out so as to prompt the user. For example, for the function "datetime _add (current_date (), 7)", if the function is determined to be illegal through the function integrity check, a prompt message such as "{ parameter } must be filled" is sent out at the query request message syntax check interface of the data query component, but the disclosure is not limited thereto, and the person skilled in the art can set specifically according to the actual situation.
The verification of the expression return data type refers to verification according to the data type defined in the parameter, wherein the expression return data type includes, but is not limited to, character strings, numerical values, dates, boolean, collections, objects and object arrays, and by way of example, the return value of the current data query request message should be boolean type, but the actual return value type is character strings, and prompt information such as "the return value of the expression needs to be { data type in parameter }" is sent, but not limited to this, the disclosure is not particularly limited, and the person skilled in the art can specifically set according to the actual situation.
It should be noted that, the front-end grammar checking may also include entity attribute correctness checking, authority checking, and the like, but is not limited thereto, and the disclosure is not particularly limited thereto, and may be specifically set by those skilled in the art according to actual situations.
Therefore, according to the data query method provided by the disclosure, before the query request message is analyzed, the query request message needs to be checked, so that the query request message which does not meet the front-end grammar check rule is screened out, the follow-up steps are avoided from being continuously executed, and resources are saved.
S13, analyzing the query request message to obtain at least one piece of metadata corresponding to the query request message.
The metadata refers to data that is obtained by analyzing the query request message by using a syntax structure and forms the query request message, and the metadata may be an entity tag such as a name tag, a user.$name, an object array tag, a user. Assets_hold, and an event name tag, wherein the user. Events. Event= =event_name.
Optionally, on the basis of the foregoing embodiments, in some embodiments of the present disclosure, further, as shown in fig. 3, before performing S15, the method further includes:
s141, acquiring a field corresponding to each metadata based on at least one metadata.
The field refers to a field corresponding to each metadata in the query request message, and for example, for the data query request message "user.assets > =100000 oruser.assets <500000", the fields "user.assets, > =, 100000, or, user.assets, <, 500000" corresponding to the metadata are determined through parsing.
S142, performing back-end grammar checking on the fields corresponding to each metadata.
The back-end grammar check at least comprises a field authorization check and a field type matching check.
The field authorization check refers to whether the authority is set for the field of the metadata corresponding to the query request message when the query request message is defined based on the entity, so as to determine whether the field corresponding to the metadata can be used, if the authorization is performed, the field authorization check is performed, if the authorization is not performed, prompt information is sent, and error prompt is performed.
The field type matching check refers to whether the data type predefined for the field corresponding to the metadata is matched with the data type acquired after the current analysis, if so, the field type matching check is passed, and if not, prompt information is sent out to carry out error reporting prompt.
And S15, inquiring according to the abstract syntax tree based on at least one metadata to obtain an inquiry result corresponding to the inquiry request message.
The abstract syntax tree comprises a first abstract syntax tree and a second abstract syntax tree, the first abstract syntax tree is obtained according to query request information, the second abstract syntax tree is obtained according to a preset query language generated by the query request information, and the preset query language at least comprises a structured query language and a distributed query language.
The abstract syntax tree refers to an abstract representation of the syntax structure of the source code, and each node on the tree represents a structure in the source code by representing the syntax structure of the programming language in the form of a tree.
The first abstract syntax tree is a syntax tree corresponding to the query request message based on the entity tag, the operator and the function definition, i.e. the first abstract syntax tree is also built based on the entity. The second abstract syntax tree is obtained according to a preset query language generated according to the query request message, wherein the preset query language at least comprises a structured query language and a distributed query language, and the distributed query language refers to a preset query language with a distributed search engine, such as an elastomer search specific domain language (Domain Specific Language, DSL), but the present disclosure is not limited thereto.
Based on the above embodiments, in some embodiments of the present disclosure, as shown in fig. 4, one implementation of S15 is:
s151, judging whether the query request message meets the real-time condition.
The real-time condition is that the pointer has real-time requirements on the query request message of the user, and by means of judging whether the query request message of the user needs to be responded within a preset time or not and feeding back a result value, whether the query request message meets the real-time condition or not is determined.
And S152, when the query request message is determined to meet the real-time condition, inquiring according to the first abstract syntax tree based on at least one metadata to obtain an inquiry result corresponding to the query request message.
Specifically, when it is determined that the current query request message meets the real-time condition, traversing query is performed according to the plurality of metadata obtained by analyzing the query request message and the first abstract syntax tree defined based on the entity, so as to obtain a query result corresponding to the query request message.
For example, when the query request message is "determine winning clients among all clients purchasing the product a in the last 7 days", it is determined that the query request message needs to be responded quickly, that is, the real-time condition is satisfied, and according to the plurality of metadata, the traversal query is performed according to the first abstract syntax tree defined based on the entity in time, so that the query result corresponding to the query request message is that the client a is the winning client.
Based on the above embodiments, in some embodiments of the present disclosure, as shown in fig. 4, a further implementation manner of S15 is:
And S153, when the query request message is determined not to meet the real-time condition, querying according to the second abstract syntax tree based on at least one metadata to obtain a query result corresponding to the query request message.
Specifically, when it is determined that the current query request message does not meet the real-time condition, traversing query is performed according to a plurality of metadata obtained by analyzing the query request message and a second abstract syntax tree corresponding to a preset query language generated by the current query request message, so as to obtain a query result corresponding to the query request message.
Based on the above embodiments, in some embodiments of the present disclosure, as shown in fig. 5, one implementation of S153 is:
S1531, determining at least one key metadata in the at least one metadata according to the priority of the at least one clause included in the query request message.
The priority refers to determining an operation sequence for processing a plurality of clauses in the query request message according to a function, an operator priority and the like. The key metadata includes, but is not limited to, functions, operators included in the query request message.
Specifically, in the process of executing the query request message, the priorities of a plurality of clauses in the query request message are determined according to functions and operators, and a plurality of key metadata are determined from a plurality of metadata in each clause according to the priorities.
For example, when 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())))",, if it is determined that the query request message includes a filter clause, the filter clause is preferentially parsed, then whether a logic operator exists in the clause is judged, when it is determined that the query request message includes the logic operator, the key metadata is determined to be the logic operator, and further, the left clause and the right clause of the logic operator are parsed, whether a calculation function exists in the left clause and the right clause is determined, and if the calculation function exists, the key metadata is determined to be the calculation function, such as datetime _add (), to_ datetime ().
S1532, determining a query sentence corresponding to a preset query language generated by the query sentence message based on at least one key metadata.
Specifically, after determining a plurality of key metadata contained in the query statement message, analyzing the plurality of key metadata, and obtaining a query statement corresponding to a preset query language generated by the query statement message based on analysis results of the plurality of metadata.
For example, if the preset query language of the 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())))", is an SQL statement, when it is determined that the key metadata such as the functions datetime _add (), to_ datetime (), the functions datetime _add (), to_ datetime () are parsed to obtain the corresponding SQL clauses respectively, and a plurality of SQL clauses are spliced to generate the SQL query statement.
S1533, based on the query statement, querying according to the second abstract syntax tree to obtain a query result corresponding to the query request message.
Specifically, when the query request message is converted into a query statement corresponding to a preset query language, the query statement is parsed, and traversing query is performed according to a second abstract syntax tree corresponding to the current query statement, so that a query result corresponding to the query request message is obtained.
In this way, the data query method provided by the embodiment includes obtaining a query request message, where the query request message includes a query request statement and a query request expression, analyzing the query request message according to an entity tag, an operator and a function to obtain at least one metadata corresponding to the query request message, and 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, where 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, the second abstract syntax tree is obtained according to a preset query language generated by the query request message, and the preset query language at least includes a structured query language and a distributed query language, that is, when the query request message is defined, the entity tag is utilized, so that a user, for example, a service personnel can flexibly use the query request message defined based on the entity tag to perform data query, and different abstract syntax trees can be utilized to obtain the query result, thereby meeting the problem that the query result cannot be used in the existing technology, and the real-time query efficiency is improved.
On the basis of the above embodiments, in some embodiments of the present disclosure, after performing S15, the method further includes:
and responding to the query request message, and displaying a query result corresponding to the query request message on a query result page.
Specifically, when a query request message is received, the query request message is responded, and further a query result corresponding to the query request message is displayed on a query result page.
In this way, the data query method provided by the embodiment can respond to the query request message and display the query result to the user on the query result page, so that the user experience is improved.
The embodiment of the disclosure also provides a data query device, which is used for executing any one of the data query methods provided by the embodiment, and has the corresponding beneficial effects of the data query method.
Fig. 6 is a schematic structural diagram of a data query device according to an embodiment of the present disclosure, and as shown in fig. 6, the data query device includes a query request message obtaining module 11, a query request message parsing module 13, and a query result obtaining module 15.
The query request message obtaining module 11 is configured to obtain a query request message, where 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 client, and a product;
The query request message analysis module 13 is configured to analyze the query request message to obtain at least one metadata corresponding to the query request message;
The query result obtaining module 15 is configured to perform a query according to an abstract syntax tree based on at least one metadata, to obtain a query result corresponding to a query request message, where 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.
In one implementation of the embodiment of the present disclosure, the query request message obtaining module 11 includes a front-end grammar checking module, configured to perform front-end grammar checking on the query request message, where the front-end grammar checking includes at least operator checking, function integrity checking, and expression return data type checking.
In an embodiment of the present disclosure, the query request message parsing module 13 includes a back-end syntax checking module, configured to obtain, based on at least one metadata, a field corresponding to each metadata, and perform back-end syntax checking on the field corresponding to each metadata, where the back-end syntax checking includes at least a field authorization check and a field type matching check.
In one implementation manner of the embodiment of the disclosure, the query result obtaining module 15 is specifically configured to determine whether the query request message meets the real-time condition, and when determining that the query request message meets the real-time condition, query according to the first abstract syntax tree based on at least one metadata, to obtain a query result corresponding to the query request message.
In an embodiment of the present disclosure, the query result obtaining module 15 is specifically further configured to, when it is determined that the query request message does not meet the real-time condition, perform, based on at least one metadata, a query according to the second abstract syntax tree, to obtain a query result corresponding to the query request message.
In an embodiment of the present disclosure, the query result obtaining module 15 is specifically further configured to determine at least one key metadata in the at least one metadata according to a priority of at least one clause included in the query request message, determine, based on the at least one key metadata, a query statement corresponding to a preset query language generated by the query statement message, and query, based on the query statement, according to the second abstract syntax tree, to obtain a query result corresponding to the query request message.
In one implementation of the embodiment of the present disclosure, the query request message obtaining module 11 is specifically configured to obtain a query request statement input by a user, and/or generate a query request expression based on an entity tag, an operator, and a function.
In an embodiment of the present disclosure, the query result obtaining module 15 includes a query result display module, configured to respond to a query request message, and display a query result corresponding to the query request message on a query result page.
In the technical scheme provided by the embodiment of the disclosure, a query request message obtaining module 11 is configured to obtain a query request message, where 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 includes at least a user, a client and a product, a query request message analyzing module 13 is configured to analyze the query request message to obtain at least one metadata corresponding to the query request message, and a query result obtaining module 15 is configured to query according to an abstract syntax tree based on at least one metadata, to obtain a query result corresponding to the query request message, where 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, when the query request message is defined, the query request message is used, the entity tag is used, so that a user can flexibly use the query request message defined by the entity tag, and query results are obtained according to the abstract syntax tree, and the query results cannot be obtained by using the abstract syntax tree to query results, and the real-time query results cannot be satisfied.
The technical solution corresponding to the apparatus of this embodiment, which may be used to execute the method embodiment shown in any one of fig. 1 to 5, is similar to the implementation principle and technical effect, and will not be repeated here.
It should be noted that, in the embodiment of the apparatus, each unit and module included are only divided according to the functional logic, but not limited to the above-mentioned division, so long as the corresponding functions can be implemented, and the specific names of the functional units are only for convenience of distinguishing each other, and are not used to limit the protection scope of the present invention.
Fig. 7 is a schematic structural diagram of an electronic device according to an embodiment of the present disclosure, where, as shown in fig. 7, the electronic device includes a processor 710, a memory 720, an input device 730, and an output device 740, where the number of processors 710 in the electronic device may be one or more, and in fig. 7, one processor 710 is taken as an example, and the processor 710, the memory 720, the input device 730, and the output device 740 in the electronic device may be connected by a bus or other manners, and in fig. 7, connection is taken as an example by a bus.
The memory 720 is a computer readable storage medium, and may be used to store a software program, a computer executable program, and modules, such as program instructions/modules corresponding to the methods in the embodiments of the present invention. The processor 710 executes various functional applications of the electronic device and data processing, i.e., implements the methods provided by embodiments of the present invention, by running software programs, instructions, and modules stored in the memory 720.
The memory 720 may mainly include a storage program area which may store an operating system, application programs required for at least one function, and a storage data area which may store data created according to the use of the terminal, etc. In addition, memory 720 may include high-speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other non-volatile solid-state storage device. In some examples, memory 720 may further include memory remotely located relative to processor 710, which may be connected to the electronic device via a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The input device 730 may be used to receive input numeric or character information and to generate key signal inputs related to user settings and function control of the electronic device, which may include a keyboard, mouse, etc. The output device 740 may include a display device such as a display screen.
The present disclosure also provides a computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, implements the technical solution of the method embodiments shown in any of fig. 1 to 5.
It should be noted that in this document, relational terms such as "first" and "second" and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Moreover, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises an element.
The foregoing is merely a specific embodiment of the disclosure to enable one skilled in the art to understand or practice the disclosure. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the disclosure. Thus, the present disclosure is not intended to be limited to the embodiments shown and described herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims (8)

1. A method of querying data, the method comprising:
obtaining a query request message, wherein the query request message comprises 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 at least comprises a user, a client and a product, the entity tag comprises a name tag, an object array tag and an event name tag, a virtual key is arranged on a query request message editing interface, the virtual key corresponds to the entity tag, the operator and the function, and the corresponding query request expression is generated according to a grammar structure through the entity tag, the operator and the function corresponding to the virtual key clicked by the user;
Analyzing the query request message to obtain at least one piece of metadata corresponding to the query request message;
based on at least one metadata, inquiring according to an abstract syntax tree to obtain an inquiry result corresponding to the inquiry request message, wherein the abstract syntax tree comprises a first abstract syntax tree and a second abstract syntax tree, the first abstract syntax tree is a syntax tree corresponding to the inquiry request message defined based on entity labels, operators and functions, the second abstract syntax tree is obtained according to a preset inquiry language generated by the inquiry request message, and the preset inquiry language at least comprises a structured inquiry language and a distributed inquiry language;
Wherein, based on at least one metadata, querying according to an abstract syntax tree to obtain a query result corresponding to the query request message, including:
judging whether the query request message meets real-time conditions or not;
when the query request message is determined to meet the real-time condition, querying according to the first abstract syntax tree based on at least one piece of metadata to obtain a query result corresponding to the query request message;
And when the query request message is determined not to meet the real-time condition, querying according to the second abstract syntax tree based on at least one piece of metadata to obtain a query result corresponding to the query request message.
2. The method of claim 1, wherein prior to parsing the query request message, further comprising:
and performing front-end grammar checking on the query request message, wherein the front-end grammar checking at least comprises operator checking, function integrity checking and expression return data type checking.
3. The method according to claim 1, wherein before the querying according to the abstract syntax tree based on at least one of the metadata to obtain the query result corresponding to the query request message, further comprises:
acquiring a field corresponding to each piece of metadata based on at least one piece of metadata;
And performing back-end grammar checking on the fields corresponding to each metadata, wherein the back-end grammar checking at least comprises field authorization checking and field type matching checking.
4. The method according to claim 1, wherein the querying, based on at least one of the metadata, according to the second abstract syntax tree, obtains a query result corresponding to the query request message, including:
Determining at least one key metadata in at least one of the metadata according to the priority of at least one clause included in the query request message;
determining a query sentence corresponding to the preset query language generated by the query sentence message based on at least one key metadata;
And based on the query statement, querying according to the second abstract syntax tree to obtain a query result corresponding to the query request message.
5. The method of claim 1, wherein the acquiring the query request message comprises:
acquiring 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, wherein the method further comprises:
and responding to the query request message, and displaying a query result corresponding to the query request message on a query result page.
7. A data query device, comprising:
The query request message acquisition module is used for acquiring a query request message, wherein the query request message comprises a query request statement and a query request expression, the query request message is determined according to entity tags, operators and functions, the entity tags are corresponding tag information determined according to attribute information of the entities, the entities at least comprise users, clients and products, the entity tags comprise name tags, object array tags and event name tags, virtual keys are arranged on a query request message editing interface, the virtual keys correspond to the entity tags, operators and functions, and the corresponding query request expression is generated according to grammar structures through the entity tags, operators and functions corresponding to the virtual keys clicked by the users;
The query request message analysis module is used for analyzing the query request message to obtain at least one metadata corresponding to the query request message;
The query result obtaining module is used for obtaining a query result corresponding to the query request message by querying according to an abstract syntax tree based on at least one piece of metadata, wherein the abstract syntax tree comprises 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 defined by an entity tag, an operator and a function, the second abstract syntax tree is obtained according to a preset query language generated by the query request message, and the preset query language at least comprises a structured query language and a distributed query language;
Wherein, based on at least one metadata, querying according to an abstract syntax tree to obtain a query result corresponding to the query request message, including:
judging whether the query request message meets real-time conditions or not;
when the query request message is determined to meet the real-time condition, querying according to the first abstract syntax tree based on at least one piece of metadata to obtain a query result corresponding to the query request message;
And when the query request message is determined not to meet the real-time condition, querying according to the second abstract syntax tree based on at least one piece of metadata to obtain a query result corresponding to the query request message.
8. An electronic device, comprising:
one or more processors;
storage means for storing one or more programs,
When executed by the one or more processors, causes the one or more processors to implement the method of any of claims 1-6.
CN202210255856.8A 2022-03-15 2022-03-15 Data query method, device and electronic device Active CN114661714B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210255856.8A CN114661714B (en) 2022-03-15 2022-03-15 Data query method, device and electronic device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210255856.8A CN114661714B (en) 2022-03-15 2022-03-15 Data query method, device and electronic device

Publications (2)

Publication Number Publication Date
CN114661714A CN114661714A (en) 2022-06-24
CN114661714B true CN114661714B (en) 2025-05-16

Family

ID=82029399

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210255856.8A Active CN114661714B (en) 2022-03-15 2022-03-15 Data query method, device and electronic device

Country Status (1)

Country Link
CN (1) CN114661714B (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101788992A (en) * 2009-05-06 2010-07-28 厦门东南融通系统工程有限公司 Method and system for converting query sentence of database
CN110399388A (en) * 2019-07-29 2019-11-01 中国工商银行股份有限公司 Data query method, system and equipment
CN111563094A (en) * 2020-03-31 2020-08-21 北京奇艺世纪科技有限公司 Data query method and device, electronic equipment and computer-readable storage medium
CN113297273A (en) * 2021-06-09 2021-08-24 北京百度网讯科技有限公司 Method and device for querying metadata and electronic equipment

Family Cites Families (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9081873B1 (en) * 2009-10-05 2015-07-14 Stratacloud, Inc. Method and system for information retrieval in response to a query
US10803083B2 (en) * 2015-08-27 2020-10-13 Infosys Limited System and method of generating platform-agnostic abstract syntax tree
EP3435257B1 (en) * 2017-07-28 2021-11-24 Risk Management Solutions, Inc. Metadata-based general request translator for distributed computer systems
US10637887B2 (en) * 2017-12-29 2020-04-28 Cyphort Inc. System for query injection detection using abstract syntax trees
CN113515285B (en) * 2020-04-10 2024-08-16 北京沃东天骏信息技术有限公司 Method and device for generating real-time calculation logic data
CN112069201A (en) * 2020-09-04 2020-12-11 北京百度网讯科技有限公司 Target data acquisition method and device
CN112905595B (en) * 2021-03-05 2025-10-14 腾讯科技(深圳)有限公司 Data query method, device and computer-readable storage medium

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101788992A (en) * 2009-05-06 2010-07-28 厦门东南融通系统工程有限公司 Method and system for converting query sentence of database
CN110399388A (en) * 2019-07-29 2019-11-01 中国工商银行股份有限公司 Data query method, system and equipment
CN111563094A (en) * 2020-03-31 2020-08-21 北京奇艺世纪科技有限公司 Data query method and device, electronic equipment and computer-readable storage medium
CN113297273A (en) * 2021-06-09 2021-08-24 北京百度网讯科技有限公司 Method and device for querying metadata and electronic equipment

Also Published As

Publication number Publication date
CN114661714A (en) 2022-06-24

Similar Documents

Publication Publication Date Title
US12164568B2 (en) Tool to build and store a data model and queries for a graph database
US9959311B2 (en) Natural language interface to databases
EP2426609B1 (en) Context-based user interface, search, and navigation
US10042921B2 (en) Robust and readily domain-adaptable natural language interface to databases
CN110765101B (en) Label generation method, device, computer-readable storage medium and server
CN111858608A (en) A data management method, device, server and storage medium
CN113268500B (en) Service processing method and device and electronic equipment
CN111061733A (en) Data processing method, apparatus, electronic device and computer-readable storage medium
CN117931834A (en) Virtual expert analysis method and device based on large language model intention recognition
EP4575822A1 (en) Data source mapper for enhanced data retrieval
CN108074033A (en) Processing method, system, electronic equipment and the storage medium of achievement data
US8862609B2 (en) Expanding high level queries
US20220269744A1 (en) Methods and systems for enabling dynamic filters for software search optimization
US20240220876A1 (en) Artificial intelligence (ai) based data product provisioning
CN110347573B (en) Application program analysis method, device, electronic device, and computer-readable medium
JP2019537171A (en) System and method for efficiently delivering warning messages
US11328005B2 (en) Machine learning (ML) based expansion of a data set
CN119669317B (en) Information display method and device, electronic device, storage medium and program product
US12321864B2 (en) Multi-hop search for entity relationships
CN114661714B (en) Data query method, device and electronic device
US20220083611A1 (en) Data management system for web based data services
CN118796863A (en) Data query method and device
US12039266B2 (en) Methods and system for the extraction of properties of variables using automatically detected variable semantics and other resources
CN114841668A (en) A production strategy determination method, device, electronic device and storage medium
CN115757995A (en) Non-characteristic data label processing method, device, computer equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant