CN115705330A - Data query method and device, electronic equipment and readable storage medium - Google Patents

Data query method and device, electronic equipment and readable storage medium Download PDF

Info

Publication number
CN115705330A
CN115705330A CN202110908740.5A CN202110908740A CN115705330A CN 115705330 A CN115705330 A CN 115705330A CN 202110908740 A CN202110908740 A CN 202110908740A CN 115705330 A CN115705330 A CN 115705330A
Authority
CN
China
Prior art keywords
target
query
information
data engine
aggregation
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.)
Pending
Application number
CN202110908740.5A
Other languages
Chinese (zh)
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.)
SF Technology Co Ltd
Original Assignee
SF Technology 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 SF Technology Co Ltd filed Critical SF Technology Co Ltd
Priority to CN202110908740.5A priority Critical patent/CN115705330A/en
Publication of CN115705330A publication Critical patent/CN115705330A/en
Pending legal-status Critical Current

Links

Images

Abstract

The embodiment of the invention provides a data query method and device, electronic equipment and a readable storage medium, and relates to the technical field of computers. The embodiment of the invention configures aggregation information, table association information and a mapping relation of a data engine in a metadata configuration table by constructing the metadata configuration table, analyzes a query statement after receiving the query statement to obtain target aggregation information and target table association information which are included in the query statement, and then searches for a target data engine from the metadata configuration table according to the target aggregation information and the target table association information, and then sends the query statement to the target data engine to realize data query through the target data engine. Therefore, the metadata can be mapped to each data engine through the metadata configuration table without researching and developing interfaces of each data engine, so that the unification of the interfaces of each data engine is realized, the workload is greatly reduced, and the working efficiency is improved.

Description

Data query method and device, electronic equipment and readable storage medium
Technical Field
The invention relates to the technical field of computers, in particular to a data query method, a data query device, electronic equipment and a readable storage medium.
Background
With the advent of the cloud era, big data (Big data) attracts more and more attention, and more industries depend on processing and analyzing the Big data, so that the query demand and the query scene of the data are more.
Under big data ecology, although the queried data engines are various and each data engine has respective advantages in a certain field, none of the data engines can cover all query scenes, so that a corresponding interface needs to be developed for each query scene, the development workload is large, and the efficiency is low.
Disclosure of Invention
Based on the research, the invention provides a data query method, a data query device, electronic equipment and a readable storage medium, and by unifying the interfaces of the data engines, the workload is reduced, and the working efficiency is improved.
Embodiments of the invention may be implemented as follows:
in a first aspect, an embodiment of the present invention provides a data query method, where the method includes:
receiving a query statement, and analyzing the query statement to obtain target aggregation information and target table association information included in the query statement;
searching a target data engine from a pre-constructed metadata configuration table according to the target aggregation information and the target table association information; the metadata configuration table is configured with the mapping relation between the aggregation information, the table association information and the data engine;
and sending the query statement to the target data engine to perform data query through the target data engine.
In an alternative embodiment, the metadata configuration table is configured with a priority of each data engine; the step of obtaining the target data engine by searching from a pre-constructed metadata configuration table according to the target aggregation information and the target table association information comprises:
searching whether at least one associated data engine corresponding to the target aggregation information and the target table associated information exists in the metadata configuration table according to the target aggregation information and the target table associated information;
if yes, determining to obtain the target data engine according to the searched priority of each associated data engine;
and if not, determining to obtain the target data engine according to the priority of each data engine in the metadata configuration table.
In an optional embodiment, the step of searching whether at least one associated data engine corresponding to the target aggregation information and the target table association information exists in the metadata configuration table according to the target aggregation information and the target table association information includes:
analyzing the target aggregation information, and judging whether the target aggregation information comprises aggregation keywords or not;
if the target aggregation information comprises an aggregation key word, searching whether at least one associated data engine corresponding to the aggregation key word and the target table associated information exists in the metadata configuration table or not according to the aggregation key word and the target table associated information;
and if the target aggregation information does not comprise the aggregation key words, searching whether at least one associated data engine corresponding to the target table associated information exists in the metadata configuration table or not according to the target table associated information.
In an optional embodiment, the step of searching whether at least one associated data engine corresponding to the aggregation key and the target table associated information exists in the metadata configuration table according to the aggregation key and the target table associated information includes:
analyzing the target table association information, and judging whether the target table association information comprises one of multi-table association and single-table query;
if the target table association information comprises multi-table association, searching whether at least one associated data engine corresponding to the aggregation key word and the multi-table association exists in the metadata configuration table;
and if the target table association information comprises single table query, searching whether at least one associated data engine corresponding to the aggregation key word and the single table query exists in the metadata configuration table.
In an optional embodiment, the step of searching whether at least one associated data engine corresponding to the target table associated information exists in the metadata configuration table according to the target table associated information includes:
analyzing the target table association information, and judging whether the target table association information comprises one of multi-table association and single-table query;
if the target table association information comprises multi-table association, searching whether at least one associated data engine corresponding to the multi-table association exists in the metadata configuration table;
and if the target table association information comprises single table query, searching whether at least one associated data engine corresponding to the single table query exists in the metadata configuration table.
In an optional embodiment, after receiving the query statement, the method further comprises:
comparing the second field in the query statement with the first field in the cache database, and judging whether a target query result corresponding to the query statement exists in the cache database; the cache database is used for storing historical query results and fields of query statements corresponding to the historical query results;
if yes, returning the target query result from the cache database;
and if the query statement does not exist, analyzing the query statement to obtain target aggregation information and target table association information included in the query statement.
In an alternative embodiment, the step of sending the query statement to the target data engine comprises:
acquiring metadata information of the target data engine according to the type of the target data engine;
judging whether the metadata information is matched with the query statement;
and if so, adjusting the query statement according to the metadata information, and sending the adjusted query statement to the target data engine.
In a second aspect, an embodiment of the present invention provides a data query apparatus, including:
the statement analysis module is used for receiving the query statement and analyzing the query statement to obtain target aggregation information and target table association information which are contained in the query statement;
the information processing module is used for searching a target data engine from a pre-constructed metadata configuration table according to the target aggregation information and the target table association information; the metadata configuration table is configured with the mapping relation between the aggregation information, the table association information and the data engine;
and the information routing module is used for sending the query statement to the target data engine so as to perform data query through the target data engine.
In a third aspect, an embodiment of the present invention provides an electronic device, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, where the processor executes the computer program to implement the data query method described in any one of the foregoing embodiments.
In a fourth aspect, an embodiment of the present invention provides a readable storage medium, where the readable storage medium includes a computer program, and the computer program controls, when running, an electronic device where the readable storage medium is located to perform the data query method in any of the foregoing embodiments.
According to the data query method, the data query device, the electronic equipment and the readable storage medium, the metadata configuration table is constructed, the mapping relation between the aggregation information and the table association information and the data engine is configured in the metadata configuration table, the query statement is analyzed after the query statement is received, the target aggregation information and the target table association information which are included in the query statement are obtained, the target data engine can be obtained by searching the metadata configuration table according to the target aggregation information and the target table association information, then the query statement is sent to the target data engine, and data query is achieved through the target data engine. Therefore, the metadata can be mapped to each data engine through the metadata configuration table without researching and developing interfaces of each data engine, so that the unification of the interfaces of each data engine is realized, the workload is greatly reduced, and the working efficiency is improved.
Drawings
The technical solution and other advantages of the present invention will become apparent from the following detailed description of specific embodiments of the present invention, which is to be read in connection with the accompanying drawings.
Fig. 1 is a block diagram of an electronic device according to an embodiment of the present invention.
Fig. 2 is a schematic flow chart of a data query method according to an embodiment of the present invention.
Fig. 3 is a block diagram of a data query apparatus according to an embodiment of the present invention.
Icon: 100-an electronic device; 10-a data query device; 11-statement parsing module; 12-an information processing module; 13-an information routing module; 20-a memory; 30-a processor; 40-a communication unit.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention. It should be apparent that the described embodiments are only some embodiments of the present invention, and not all embodiments. All other embodiments, which can be obtained by a person skilled in the art without inventive step based on the embodiments of the present invention, are within the scope of protection of the present invention.
In the description of the present invention, it is to be understood that the terms "center", "longitudinal", "lateral", "length", "width", "thickness", "upper", "lower", "front", "rear", "left", "right", "vertical", "horizontal", "top", "bottom", "inner", "outer", "clockwise", "counterclockwise", and the like, indicate orientations or positional relationships based on those shown in the drawings, merely for convenience of description and simplification of the description, and do not indicate or imply that the device or element referred to must have a particular orientation, be constructed in a particular orientation, and be operated, and thus, are not to be construed as limiting the present invention. Furthermore, the terms "first", "second" and "first" are used for descriptive purposes only and are not to be construed as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, features defined as "first" and "second" may explicitly or implicitly include one or more of the described features. In the description of the present invention, "a plurality" means two or more unless specifically defined otherwise.
In the description of the present invention, it should be noted that, unless otherwise explicitly specified or limited, the terms "mounted," "connected," and "connected" are to be construed broadly, e.g., as meaning either a fixed connection, a removable connection, or an integral connection; may be mechanically connected, may be electrically connected or may be in communication with each other; they may be directly connected or indirectly connected through intervening media, or may be connected through the use of two elements or the interaction of two elements. The specific meanings of the above terms in the present invention can be understood according to specific situations by those of ordinary skill in the art.
In the present invention, unless expressly stated or limited otherwise, the recitation of a first feature "on" or "under" a second feature may include the recitation of the first and second features being in direct contact, and may also include the recitation that the first and second features are not in direct contact, but are in contact via another feature between them. Also, the first feature being "on," "above" and "over" the second feature includes the first feature being directly on and obliquely above the second feature, or merely indicating that the first feature is at a higher level than the second feature. A first feature being "under," "below," and "beneath" a second feature includes the first feature being directly under and obliquely below the second feature, or simply meaning that the first feature is at a lesser elevation than the second feature.
The following disclosure provides many different embodiments or examples for implementing different features of the invention. To simplify the disclosure of the present invention, specific example components and arrangements are described below. Of course, they are merely examples and are not intended to limit the present invention. Moreover, the present invention may repeat reference numerals and/or reference letters in the various examples, which have been repeated for purposes of simplicity and clarity and do not in themselves dictate a relationship between the various embodiments and/or configurations discussed. In addition, the present invention provides examples of various specific processes and materials, but one of ordinary skill in the art may recognize applications of other processes and/or uses of other materials.
As background art, in big data ecology, although the queried data engines are various and each data engine has its own advantages in a certain field, none of the data engines can cover all query scenarios, and therefore, for each query scenario, a corresponding interface needs to be developed, the development workload is large, the efficiency is low, and the business requirements of multiple query scenarios cannot be solved at one time.
Based on this, according to the data query method, the data query device, the electronic device, and the readable storage medium provided in this embodiment, the metadata configuration table is constructed, the mapping relationship between the aggregation information and the table association information and the data engine is configured in the metadata configuration table, after the query statement is received, the query statement is analyzed, and after the target aggregation information and the target table association information included in the query statement are obtained, the target data engine can be obtained by searching the metadata configuration table according to the target aggregation information and the target table association information, and then the query statement is sent to the target data engine, so that data query is achieved through the target data engine. Therefore, the metadata can be mapped to each data engine through the metadata configuration table without researching and developing interfaces of each data engine, so that the unification of the interfaces of each data engine is realized, the workload is greatly reduced, and the working efficiency is improved.
Referring to fig. 1, fig. 1 is a block diagram of an electronic device 100 according to the present embodiment. As shown in fig. 1, the electronic device 100 may include a data query apparatus 10, a memory 20, a processor 30 and a communication unit 40, the memory 20 stores machine-readable instructions executable by the processor 30, when the electronic device 100 operates, the processor 30 and the memory 20 communicate with each other through a bus, and the processor 30 executes the machine-readable instructions and performs a data query method.
The elements of the memory 20, the processor 30 and the communication unit 40 are electrically connected to each other, directly or indirectly, to enable transmission or interaction of signals. For example, the components may be electrically connected to each other via one or more communication buses or signal lines. The data querying device 10 comprises at least one software functional module which can be stored in the memory 20 in the form of software or firmware (firmware). The processor 30 is used to execute executable modules (e.g., software functional modules or computer programs included in the data query device 10) stored in the memory 20.
The Memory 20 may be, but is not limited to, a Random Access Memory (RAM), a Read Only Memory (ROM), a Programmable Read-Only Memory (PROM), an Erasable Read-Only Memory (EPROM), an electrically Erasable Read-Only Memory (EEPROM), and the like.
In some embodiments, processor 30 is configured to perform one or more of the functions described in this embodiment. In some embodiments, the processor 30 may include one or more processing cores (e.g., a single-core processor (S) or a multi-core processor (S)). Merely by way of example, the Processor 30 may include a Central Processing Unit (CPU), an Application Specific Integrated Circuit (ASIC), an Application Specific Instruction Set Processor (ASIP), a Graphics Processing Unit (GPU), a Physical Processing Unit (PPU), a Digital Signal Processor (DSP), a Field Programmable Gate Array (FPGA), a Programmable Logic Controller (PLC), a microcontroller Unit, a reduced Instruction Set computer (reduced Instruction Set Computing, RISC), a microprocessor, or the like, or any combination thereof.
For ease of illustration, only one processor is depicted in electronic device 100. However, it should be noted that the electronic device 100 in this embodiment may also include multiple processors, and thus steps performed by one processor described in this embodiment may also be performed by multiple processors in combination or individually. For example, if the processor of the server performs step a and step B, it should be understood that step a and step B may also be performed by two different processors together or separately in one processor. For example, the processor performs step a and the second processor performs step B, or the processor and the second processor perform steps a and B together.
In this embodiment, the memory 20 is used for storing programs, and the processor 30 is used for executing the programs after receiving the execution instructions. The method defined by the process disclosed in any of the embodiments of the present invention can be applied to the processor 30, or can be implemented by the processor 30.
The communication unit 40 is used to establish a communication connection between the electronic apparatus 100 and another apparatus via a network, and to transmit and receive data via the network.
In some embodiments, the network may be any type of wired or wireless network, or combination thereof. Merely by way of example, a Network may include a wired Network, a Wireless Network, a fiber optic Network, a telecommunications Network, an intranet, the internet, a Local Area Network (LAN), a Wide Area Network (WAN), a Wireless Local Area Network (WLAN), a Metropolitan Area Network (MAN), a Wide Area Network (WAN), a Public Switched Telephone Network (PSTN), a bluetooth Network, a ZigBee Network, a Near Field Communication (NFC) Network, or the like, or any combination thereof.
In the embodiment, the electronic device 100 may be, but is not limited to, a notebook computer, an ultra-mobile personal computer (UMPC), a netbook, a Personal Digital Assistant (PDA), and other electronic devices, and the embodiment does not limit the specific type of the electronic device. In one embodiment, the electronic device may also be a physical server or a service cluster composed of a plurality of physical servers. The present embodiment does not set any limit to the specific type of the electronic device.
It will be appreciated that the configuration shown in figure 1 is merely schematic. Electronic device 100 may also have more or fewer components than shown in FIG. 1, or a different configuration than shown in FIG. 1. The components shown in fig. 1 may be implemented in hardware, software, or a combination thereof.
Based on the implementation architecture of fig. 1, the present embodiment provides a data query method, which is executed by the electronic device shown in fig. 1, and the following describes in detail the steps of the data query method provided by the present embodiment based on the structural diagram of the electronic device 100 shown in fig. 1. Referring to fig. 2, the data query method provided in the present embodiment includes steps S101 to S103.
Step S101: and receiving a query statement, and analyzing the query statement to obtain target aggregation information and target table association information included in the query statement.
The electronic equipment can be divided into a front end and a rear end based on a Spring boot frame and a Vue frame, the front end can provide an interactive page for a user, when the user needs to inquire certain data, an inquiry statement can be input through the interactive page of the front end, the front end sends the inquiry statement to the rear end after receiving the inquiry statement, and the rear end analyzes the inquiry statement. In order to facilitate the user to query the data, in this embodiment, the front end is configured with a uniform interface through which the user can input a query statement.
Optionally, in this embodiment, a Structured Query Language (SQL) is used as the Query statement, and mainly includes Query column information, table association information, condition information, aggregation information, and other part of information.
The query column information in the SQL statement comprises information such as a table name to be queried, a column name and the like. The table association information in the SQL statement is used for representing association relations between data tables to be queried, including multi-table association and single-table query. The condition information in the SQL statement is used for representing conditions that the data to be queried needs to satisfy, and can be set according to actual requirements. The aggregation information in the SQL statement is used for counting, summing, solving the most value, and the like, of the data to be queried. Other parts in the SQL statement are used for characterizing other statements in the SQL statement and can be set according to actual requirements.
After the query statement is received, the query statement is analyzed, that is, the query statement can be split into query column information, table association information, condition information, aggregation information and other parts, so that target aggregation information and target table association information included in the query statement are obtained.
Step S102: and searching a target data engine from a pre-constructed metadata configuration table according to the target aggregation information and the target table association information.
After the target aggregation information and the target table association information are obtained, the target data engine is searched and obtained from a pre-constructed metadata configuration table according to the target aggregation information and the target table association information.
In this embodiment, the metadata configuration table is configured with mapping relationships between the aggregation information, the table association information, and the data engine. The mapping relationship between the aggregation information and the table association information and the data engine can comprise at least one of the mapping relationship between the aggregation information and the data engine, the mapping relationship between the table association information and the data engine, and the mapping relationship between the aggregation information and the table association information and the data engine.
After the target aggregation information and the target table association information in the query statement are obtained, the target data engine corresponding to the target aggregation information and the target table association information can be found according to the mapping relation.
For example, the metadata configuration table is configured with the mapping relationship between the aggregation information _1 and the table association information _1 and the data engine a, the mapping relationship between the aggregation information _2 and the data engine b, the mapping relationship between the table association information _2 and the data engine a, and the like. After the query statement is analyzed, if the obtained target aggregation information is aggregation information _1 and the target table association information is table association information _2, since the aggregation information _1 and the table association information _1 have a mapping relationship with the data engine a and the table association information _2 has a mapping relationship with the data engine a, the obtained target data engine is the data engine a according to the mapping relationship, and if the obtained target aggregation information is aggregation information _2 and the target table association information is table association information _2, since the aggregation information _2 has a mapping relationship with the data engine b and the table association information _2 has a mapping relationship with the data engine a, the obtained target data engine can be the data engine a or the data engine b according to the mapping relationship.
Step S103: and sending the query statement to the target data engine to perform data query through the target data engine.
After the target data engine is determined to be obtained, the query statement can be sent to the target data engine, and the target data engine queries data according to the query statement.
In order to facilitate data query, in this embodiment, after the target data engine is determined to be obtained, the query statement may be further converted into a statement that can be directly analyzed by the target data engine according to the attribute of the target data engine, and then, after the target data engine receives the converted query statement, the target data engine may directly perform data query according to the converted query statement.
Optionally, the target data engine performs data query according to the query statement, and after obtaining the query result, the target data engine may return the query result to the electronic device, and the electronic device feeds the query result back to the user. In some optional embodiments, the target data engine performs data query according to the query statement, and after obtaining the query result, may also directly feed back the query result to the user.
According to the data query method provided by the embodiment, by constructing the metadata configuration table and configuring the aggregation information and the mapping relationship between the table association information and the data engine in the metadata configuration table, various data engines can be managed, including data engines such as Presto, kylin, elastic, mysql, clickhause, doris and the like, wherein different data engines support data query with different granularities (such as granularity of detail, aggregation and the like), and further, various query scenes can be covered through the metadata configuration table, including detail query scenes, aggregation query scenes and the like, so that service requests of various query scenes can be solved at one time, the workload of repeated research and development and debugging of each query scene is greatly reduced, and the research and development efficiency is greatly improved.
According to the data query method provided by the embodiment, by configuring the metadata configuration table, after the query statement is received, only the query statement needs to be analyzed to obtain the target aggregation information and the target table association information included in the query statement, the most appropriate target data engine can be searched and obtained from the metadata configuration table according to the target aggregation information and the target table association information, data query is realized through the target data engine, and the efficiency and the accuracy of data query are improved.
In the embodiment, the multiple data engines are managed through the metadata configuration table, only one entry needs to be exposed to the outside, the access details of each data engine are shielded to the outside while the advantages of each data engine are integrated, the unification of the interfaces of each data engine is realized, the stability is improved, and the use threshold is reduced.
In this embodiment, to facilitate management of the metadata configuration table, mysql may be used to store and manage the metadata configuration table for the metadata storage engine. As shown in table 1, the data structure of the metadata configuration table may be as follows:
TABLE 1
Figure BDA0003202888790000101
Figure BDA0003202888790000111
Wherein, source _ ID is a data Source ID, and represents the ID of the actual physical data engine, the data type is a bigint type, the field storage length is 20, and the field storage length is a primary key. Source _ desc is a data Source description, which mainly explains each data Source, and includes the name of each data Source, the data type of which is Varchar, and the field storage length is 255 and is not a primary key. And the view _ id is a table view name, namely a unique identifier of the metadata configuration table, the metadata configuration table can be obtained through positioning by the view _ id, and information in the metadata configuration table is modified, wherein the data type is Varchar, the field storage length is 255, and the field storage length is a main key. The Olap _ code is a bottom-layer Olap data engine, and mainly notes a data source ID corresponding to each data engine, the data type of the data engine is Varchar, the field storage length is 20, and the data engine is a primary key. Olap _ type is an Olap type, and mainly defines various types of query scenarios, including mapping relationships between each data engine and aggregation information and table association information, where the data type is Varchar, the field storage length is 1, and the field storage length is not a primary key. Olap _ prio is the priority of each data engine, can be set by self, and has a data type of Varchar, a field storage length of 1, and is not a primary key.
It should be understood that, in this embodiment, the metadata configuration table is only used to characterize the mapping management of the underlying multiple data engines, and in some other embodiments, other manners may also be used to map and manage the underlying multiple data engines, such as in the form of diagrams, and the present embodiment is not limited in particular.
In order to facilitate management and data query, in this embodiment, an entry may be configured at the front end, and when a query scenario needs to be added, modified, or deleted, that is, a mapping relationship is added, modified, or deleted, the entry and the table view name of the metadata configuration table may be located in the metadata configuration table, a new mapping relationship is configured in the metadata configuration table, and an existing mapping relationship in the metadata configuration table is deleted or modified.
In the data query method provided in this embodiment, a metadata configuration table is constructed, and after a query statement is received and analyzed to obtain target aggregation information and target table association information included in the query statement, a target data engine may be searched in an Olap _ type, and after the target data engine is found, a data source ID corresponding to the target data engine is found according to a correspondence between the data engine and the data source ID included in an Olap _ code, and then the query statement is sent to a data source corresponding to the target data engine, that is, the query statement is sent to an actual physical data engine, so as to implement data query.
In view of the fact that in practical applications, some data engines have various storage advantages and can store data of various query granularities, and further when searching for a target data engine, there may be multiple target data engines to be searched, and in order to facilitate obtaining a more preferable target data engine, in this embodiment, the metadata configuration table is further configured with priorities of the data engines, and the step of searching for the target data engine from the pre-constructed metadata configuration table according to the target aggregation information and the target table association information includes:
and searching whether at least one associated data engine corresponding to the target aggregation information and the target table associated information exists in the metadata configuration table or not according to the target aggregation information and the target table associated information.
And if so, determining to obtain a target data engine according to the priority of each searched associated data engine.
And if not, determining to obtain the target data engine according to the priority of each data engine in the metadata configuration table.
After the target aggregation information and the target table association information are obtained, whether an associated data engine corresponding to the target aggregation information and the target table association information exists in the metadata configuration table or not can be searched. And if a plurality of associated data engines exist, determining to obtain a target data engine according to the priority of each associated data engine obtained by searching. If only one associated data engine exists, the associated data engine is directly used as a target data engine. And if the associated data engines do not exist, determining to obtain the target data engine according to the priority of each data engine in the metadata configuration table. It should be noted that the priority of each data engine may be set according to actual requirements, and this embodiment is not limited in particular.
In order to obtain a data engine suitable for a query scenario and improve data query efficiency and accuracy, in this embodiment, when a target data engine is determined according to the priority of each searched associated data engine, the priorities of the associated data engines may be ranked, and then the associated data engine with the highest priority is selected as the target data engine. Therefore, a data engine suitable for the query scene can be obtained, and the efficiency and accuracy of data query are improved.
In this embodiment, when data query is performed, if statistics, summation, maximum value calculation, and the like need to be performed on data to be queried, aggregation information in a query statement needs to include an aggregation keyword, where the aggregation keyword may be an aggregation condition function of statistics, summation, maximum value calculation, and the like; if single table query or multi-table association query is required, the table association information in the query statement needs to include fields such as single table query or multi-table association. The aggregation information and the table association information corresponding to different query scenarios are different.
In order to accurately obtain the data engine adapted to each query scene, in this embodiment, when the mapping relationship is configured, the data engine adapted to each query scene may be determined first, and then the mapping relationship between the aggregation information, the table association information, and the data engine is configured according to the aggregation information and the table association information corresponding to each query scene. After the mapping relation is configured, after the target aggregation information and the target table association information in the query statement are obtained, the adaptive data engine can be determined according to the mapping relation.
In this embodiment, the query scenario is divided into a detail query scenario and an aggregate query scenario, where the detail query scenario includes a single-table-detail query scenario and a multi-table-association-detail query scenario, and the aggregate query scenario includes a single-table-aggregate query scenario and a multi-table-association-aggregate query scenario.
The aggregation information corresponding to the query scenes of the single table detail does not comprise aggregation keywords, the table association information corresponding to the query scenes of the single table detail comprises single table query, the aggregation information corresponding to the query scenes of the multiple table association details does not comprise aggregation keywords, the table association information corresponding to the query scenes of the multiple table association details comprises multiple table association, the aggregation information corresponding to the query scenes of the single table aggregation comprises aggregation keywords, the table association information corresponding to the query scenes of the single table aggregation comprises single table query, the aggregation information corresponding to the query scenes of the multiple table association comprises aggregation keywords, and the table association information corresponding to the query scenes of the multiple table association aggregation comprises multiple table association.
Based on this, in this embodiment, the mapping relationship between the aggregation information and the table association information and the data engine includes at least one of the mapping relationship between the aggregation key and the data engine, the mapping relationship between the single table query and the data engine, and the mapping relationship between the multi-table association and the data engine. The step of searching whether at least one associated data engine corresponding to the target aggregation information and the target table association information exists in the metadata configuration table according to the target aggregation information and the target table association information may include:
and analyzing the target aggregation information, and judging whether the target aggregation information comprises aggregation keywords.
And if the target aggregation information comprises the aggregation key words, searching whether at least one associated data engine corresponding to the aggregation key words and the target table associated information exists in the metadata configuration table or not according to the aggregation key words and the target table associated information.
And if the target aggregation information does not comprise the aggregation key words, searching whether at least one associated data engine corresponding to the target table associated information exists in the metadata configuration table or not according to the target table associated information.
After the target aggregation information is analyzed, whether the target aggregation information includes aggregation keywords or not can be judged, and if the target aggregation information includes the aggregation keywords, the query scene corresponding to the query statement is represented as an aggregation query scene. Because the aggregated query scenario includes a single-table aggregated query scenario and a multi-table association aggregated query scenario, it is further necessary to analyze whether the query scenario corresponding to the query statement is the single-table aggregated query scenario or the multi-table association aggregated query scenario according to the target table association information, so as to select a more adaptive data engine for data query.
Therefore, after the target aggregation information is determined to include the aggregation key, whether an associated data engine corresponding to the aggregation key and the target table associated information exists in the metadata configuration table needs to be searched according to the aggregation key and the target table associated information, that is, whether an associated data engine corresponding to both the aggregation key and a field in the target table associated information exists is searched according to a mapping relationship configured by the metadata configuration table.
Optionally, in this embodiment, the step of searching whether at least one associated data engine corresponding to the aggregation key and the target table associated information exists in the metadata configuration table according to the aggregation key and the target table associated information includes:
and analyzing the target table association information, and judging whether the target table association information comprises one of multi-table association and single-table query.
If the target table association information comprises multi-table association, whether at least one associated data engine corresponding to the aggregation key and the multi-table association exists in the metadata configuration table or not is searched.
And if the target table association information comprises single table query, searching whether at least one associated data engine corresponding to the aggregation key words and the single table query exists in the metadata configuration table.
After the target table association information is analyzed, if the obtained target table association information includes multi-table association, that is, the current query scene is represented as a multi-table association aggregated query scene, whether a data engine corresponding to the multi-table association aggregated query scene exists or not needs to be searched in the metadata configuration table, that is, whether an associated data engine corresponding to an aggregation keyword and the multi-table association at the same time exists or not is searched in the metadata configuration table. If the obtained target table association information includes single table query, that is, the current query scene is represented as a single table aggregated query scene, whether a data engine corresponding to the single table aggregated query scene exists or not needs to be searched in the metadata configuration table, that is, whether an associated data engine corresponding to the aggregated keyword and the single table query exist or not is searched in the metadata configuration table.
If the target aggregation information does not include the aggregation keywords, that is, the query scene corresponding to the representation query statement is a detail query scene, and the detail query scene includes a single-detail query scene and a multi-detail query scene, it is further necessary to analyze that the query scene corresponding to the query statement is the single-detail query scene and the multi-detail query scene according to the target-detail association information.
Therefore, after the target aggregation information is determined not to include the aggregation key, it is further required to search whether at least one associated data engine corresponding to the target table associated information exists in the metadata configuration table according to the target table associated information, that is, whether an associated data engine corresponding to a field in the target table associated information exists is searched according to the mapping relationship configured by the metadata configuration table.
Optionally, in this embodiment, the step of searching whether at least one associated data engine corresponding to the target table associated information exists in the metadata configuration table according to the target table associated information may include:
and analyzing the target table association information, and judging whether the target table association information comprises one of multi-table association and single-table query.
And if the target table association information comprises multi-table association, searching whether at least one associated data engine corresponding to the multi-table association exists in the metadata configuration table or not.
And if the target table association information comprises single table query, searching whether at least one associated data engine corresponding to the single table query exists in the metadata configuration table.
After the target table association information is analyzed, if the obtained target table association information includes multi-table association, that is, a current query scene is represented as a query scene of multi-table association details, whether a data engine corresponding to the query scene of the multi-table association details exists or not needs to be searched in the metadata configuration table, that is, whether an associated data engine corresponding to the multi-table association exists or not is searched in the metadata configuration table. If the obtained target table association information includes single table query, that is, a query scene representing that the current query scene is a single table detail, whether a data engine corresponding to the query scene of the single table detail exists or not needs to be searched in the metadata configuration table, that is, whether an associated data engine corresponding to the single table query exists or not is searched in the metadata configuration table.
And after the associated data engine is found, determining a target data engine according to the priority of the found associated data engine, and if the associated data engine is not found, determining the target data engine according to the priority of each data engine in the metadata configuration table.
The data query method provided by this embodiment can cover various query scenarios by configuring the mapping relationship between the data engine and the aggregation information and the table association information, and when performing data query, only the query statement needs to be analyzed to obtain the aggregation information and the table association information of the query statement, and according to the aggregation information and the table association information of the query statement, the query scenario corresponding to the query statement can be analyzed and obtained, and the data is routed to the most suitable data engine according to the mapping relationship to perform data query.
For example, the method is implemented by using five data engines, namely Kylin, elastic, mysql, clickHouse and Doris, wherein Kylin supports a query scene of multi-table association aggregation and also supports a query scene of multi-table association details, elastic supports a query scene of single-table association details, mysql supports a query scene of single-table association details and also supports a query scene of multi-table association details, clickHouse supports a query scene of single-table aggregation and also supports a query scene of single-table association details, and Doris supports a query scene of single-table aggregation and supports a query scene of single-table association details and also supports a query scene of multi-table association details. Therefore, when the mapping relation of the Kylin is configured, the aggregation information and the table association information corresponding to the multi-table association aggregation can be respectively mapped with the Kylin configuration, and the aggregation information and the table association information corresponding to the multi-table association detail can be respectively mapped with the Kylin configuration; when the mapping relation of Elastic is configured, the aggregation information and the table association information corresponding to the single indication detail can be respectively configured with the mapping relation of Elastic; when the mapping relation of the Mysql is configured, the aggregation information and the table association information corresponding to the single indication detail can be respectively configured with the mapping relation of the Mysql, and the aggregation information and the table association information corresponding to the multi-table association detail can be respectively configured with the mapping relation of the Mysql; when the mapping relation of the ClickHouse is configured, the aggregation information and the table association information corresponding to the single table aggregation can be respectively configured with the mapping relation of the ClickHouse, and the aggregation information and the table association information corresponding to the single table aggregation can be respectively configured with the mapping relation of the ClickHouse; when configuring the Doris mapping relationship, aggregation information and table association information corresponding to the single table aggregation may be respectively associated with the Doris configuration mapping relationship, aggregation information and table association information corresponding to the single table details may be respectively associated with the Doris configuration mapping relationship, and aggregation information and table association information corresponding to the multi-table association details may be respectively associated with the Doris configuration mapping relationship.
After receiving the query statement, analyzing the query statement, if the obtained aggregation information of the query statement comprises aggregation keywords and the obtained table association information of the query statement comprises multi-table association, determining that a query scene corresponding to the query statement is multi-table association aggregation, searching whether a data engine corresponding to the aggregation keywords and the multi-table association exists in a metadata configuration table, namely searching whether Kylin exists in the metadata configuration table, if yes, sending the query statement to Kylin, performing data query through Kylin, and if not, performing data query by taking the data engine with the highest priority in the metadata configuration table as a target data engine.
If the obtained aggregated information of the query statement comprises aggregated keywords, and the obtained table associated information of the query statement comprises single table query, determining that a query scene corresponding to the query statement is single table aggregation, searching whether a data engine corresponding to the aggregated keywords and the single table query exists in a metadata configuration table, namely searching whether a ClickHouse or Doris exists in the metadata configuration table, if both the ClickHouse and the Doris exist, selecting one with the best priority as a target data engine to perform data query, if neither the ClickHouse nor the Doris exists, selecting the highest priority data engine in the metadata configuration table as the target data engine to perform data query, and if only one ClickHouse or only one Doris exists, selecting the existing one as the target data engine to perform data query.
If the aggregate information of the obtained query statement does not include the aggregate keyword, and the table association information of the obtained query statement includes single table query, determining that a query scene corresponding to the query statement is single table detail query, searching whether a data engine corresponding to the single table query exists in a metadata configuration table, namely searching whether at least one of ClickHouse, doris, elastic and Mysql exists in the metadata configuration table, if only one exists, directly performing data query by using the only existing data engine as a target data engine, if multiple exist, selecting the highest priority of ClickHouse, doris, elastic and Mysql as the target data engine to perform data query, and if none of ClickHouse, doris, elastic and Mysql exists, selecting the data engine with the highest priority in the metadata configuration table as the target data engine to perform data query.
If the obtained aggregated information of the query statement does not include the aggregated keywords, and the obtained table association information of the query statement includes multi-table association, determining that a query scene corresponding to the query statement is multi-table association detail query, searching whether a data engine corresponding to the multi-table association exists in a metadata configuration table, namely searching whether at least one of Kylin, mysql and Doris exists in the metadata configuration table, if only one of Kylin, mysql and Doris exists, directly performing data query by using the existing target data engine, if multiple types exist, selecting the data engine with the highest priority among Kylin, mysql and Doris as a target data engine to perform data query, and if none of Kylin, mysql and Doris exists, selecting the data engine with the highest priority in the metadata configuration table as the target data engine to perform data query.
According to the data query method provided by the embodiment, the mapping relation between the data engine and the aggregation information and the table association information is configured in the metadata configuration table according to the data engine adapted to each query scene, and after the query statement is obtained, the query statement is analyzed, so that the data engine adapted to the query statement can be determined according to the aggregation information and the table association information of the query statement, and the efficiency and the accuracy of data query are improved.
According to the data query method provided by the embodiment, the query scenes are analyzed, the mapping relation between the data engine and the aggregation information and the mapping relation between the data engine and the table association information are configured in the metadata configuration table according to the query scenes, the service requests of various query scenes can be solved at one time, the workload of repeated research and development and debugging of each query scene is greatly reduced, and the research and development efficiency is improved to a great extent.
In view of the fact that in practical application, there are many data query requests every day, if each data query needs to penetrate through the data engine for querying, the query pressure of the data engine is greatly increased, in order to relieve the query pressure of the data engine, in this embodiment, the query result fed back by the data engine may be cached in the cache database, when a query statement is received, whether a corresponding query result exists in the cache database may be queried first, and if the corresponding query result does not exist, the data query is performed through the data engine, so the query pressure of the data engine may be effectively relieved.
Based on this, in this embodiment, after receiving the query statement, the data query method further includes:
comparing the second field in the query statement with the first field in the cache database, and judging whether a target query result corresponding to the query statement exists in the cache database; the cache database is used for storing historical query results and fields of query statements corresponding to the historical query results.
And if so, returning a target query result from the cache database.
And if the target aggregation information does not exist, analyzing the query statement to obtain the target aggregation information and the target table association information which are included in the query statement.
After each data query, the query result of the data query can be stored in the cache database, and meanwhile, the field of the query statement corresponding to the query result is stored. Therefore, when a subsequent query statement is received, the second field in the query statement and the first field in the cache database can be compared, whether the first field identical to the second field exists in the cache database or not is judged, if yes, a target query result corresponding to the query statement exists in the cache database is judged, and then the target query result is directly returned from the cache database. If the query statement does not exist, the query statement needs to be analyzed to obtain target aggregation information and target table association information which are included in the query statement, then a target data engine is obtained by searching according to the target aggregation information and the target table association information, data query is carried out through the target data engine, and a query result is returned.
It can be understood that after the query result is obtained through the query of the target data engine, the query result and the first field in the query statement corresponding to the query result may be stored in the cache database, and when the first field in the query statement is stored in the cache database, the first field in the query statement is the second field in the cache database.
Optionally, in this embodiment, the field may be a combination of a query table name and a query condition, and when the query result is stored in the cache database, the query table name and the query condition in the query statement corresponding to the query result may be used as a key value, the data in the query result may be used as a value, and the value may be stored in the cache database in a key value pair manner. Then, after receiving the query statement, the query table name and the query condition in the query statement can be compared with the query table name and the query condition in the cache database, so as to judge whether the cache database has a query result corresponding to the query statement.
In order to relieve the query pressure of a data engine and improve the convenience of data query, in this embodiment, timing query may be further set, and a user may input a query statement, scheduling time and frequency in advance through a front end, where the frequency represents the frequency of data query and may be set according to days, hours and minutes, and the scheduling time represents the time for triggering data query. After setting query sentences, scheduling time and frequency, carrying out timing query by a rear end, when the scheduling time is located, executing a scheduling task by the rear end, carrying out data query, analyzing the query sentences, searching a target data engine according to aggregation information and table association information in the query sentences, after the target data engine is found, sending the query sentences to the target data engine for data query, receiving query results returned by the target data engine, caching the query results to a cache database, then carrying out the data query at regular time according to the set frequency, and updating the query results in the cache database. For example, when the scheduling time is 2021 year, 7 month, 1 day, and 13, and the frequency is 1 day, then at 2021 year, 7 month, 1 day, and 13, the back end executes the scheduling task, performs data query, obtains the query result, and stores the query result in the cache database, and then, executes the scheduling task at 13 days, performs data query, obtains a new query result, and updates the query result cached in the cache database according to the new query result. When the user needs to obtain the query result, the query result in the cache database can be directly fed back to the user, so that the query pressure of the data engine is relieved, and the convenience of data query is improved.
Optionally, in this embodiment, the cache database may be a Redis database or a Memcached database, and this embodiment is not limited in particular.
Optionally, in this embodiment, the cache database may be integrated in the electronic device, or may be in communication connection with the electronic device, and this embodiment is not limited in particular.
According to the data query method provided by the embodiment, the query result is cached, after the query statement is received, whether the query result corresponding to the query statement exists in the cache or not can be judged, and if the query result corresponding to the query statement exists, the corresponding query result in the cache can be directly returned without penetrating through the data engine, so that the query pressure of the data engine can be relieved.
In order to improve the accuracy of data query, in this embodiment, the corresponding query statement may also be optimized according to the data engine. Thus, in this embodiment, the step of sending the query statement to the target data engine may comprise:
and acquiring metadata information of the target data engine according to the type of the target data engine.
And judging whether the metadata information is matched with the query statement.
And if the query statement is matched with the target data engine, adjusting the query statement according to the metadata information, and sending the adjusted query statement to the target data engine.
Different data engines have different system architectures and different metadata. Therefore, after the target data engine is found, the metadata information of the target data engine can be obtained according to the type of the target data engine.
For example, for a Kylin data engine, the obtained metadata information may include an aggregation group, a cube description (cube description), and cube instances (cube instances), among others. For the Mysql data engine, the obtained metadata information may include index information of the table.
After obtaining the metadata information of the target data engine, the metadata information of the target data engine can be compared with the field in the query statement, whether the metadata information of the target data engine can be matched with the field in the query statement or not is judged, if the metadata information of the target data engine can be matched with the field in the query statement, the query statement is adjusted according to the metadata information to optimize the query statement, then the adjusted query statement is sent to the target data engine, and the data result can be obtained quickly and accurately. And if the query statement cannot be matched with the target data engine, directly sending the query statement to the target data engine to enable the target data engine to perform data query, and returning a query optimization suggestion while receiving a query result returned by the target data engine and feeding the query result back to the user.
For example, for a Kylin data engine, the aggregation information in the query statement may be matched with the aggregation group in the Kylin, whether there is an aggregation group that can be matched with the aggregation information in the query statement is determined, if so, the cube corresponding to the aggregation group is determined according to the aggregation group obtained by matching, then the query statement is marked according to the mark of the cube obtained by determination, that is, the mark of the cube obtained by determination is marked in the query statement, so as to implement adjustment of the query statement.
And if no matched aggregation group exists, directly sending the query statement to the Kylin data engine for data query, returning the query result to the user after receiving the query result returned by the Kylin data engine, and prompting the user to adjust the field in the aggregation information.
When the aggregation information in the query statement is matched with the aggregation group in the Kylin, the aggregation field in the aggregation information may be matched with the aggregation group in the Kylin, and if there are multiple aggregation groups obtained through matching, the aggregation group with the most matching fields is used as the aggregation group obtained through final matching. For example, if the query statement needs to perform an aggregate query on age and gender, the aggregation fields in the aggregation information are age and gender, when matching with the aggregation group in Kylin, for any one aggregation group in Kylin, if one field of age and gender exists in the aggregation group, it is determined that the aggregation group matches with the query statement, and if there are multiple aggregation groups obtained by matching, the aggregation group with the most matching fields is selected, for example, age and gender exist in the a aggregation group, age and gender exist in the B aggregation group, and gender exists in the C aggregation group, and the a aggregation group is taken as the final aggregation group obtained by matching.
For example, in the Mysql data engine, the sequence of the fields in the query statement may be adjusted to a, B, C, and D if the index matching the fields in the query statement exists according to the prefix matching rule, and if the sequence of the fields in the matched index matches the sequence of the fields in the query statement, for example, the sequence of the fields in the matched index is a, B, C, and D, and the sequence of the fields in the query statement is D, B, C, and D. Therefore, after the adjusted query statement is sent to the Mysql data engine, the Mysql data engine can perform data query according to the adjusted query statement, and accuracy and efficiency of data query are improved.
And if the index matched with the field in the query statement does not exist, directly sending the query statement to the Mysql data engine for data query. After receiving the query result returned by the Mysql data engine, the query result can be sent to the user, and the user is prompted to adjust the fields in the query statement.
The data query method provided by the embodiment optimizes the query statement correspondingly for different data engines, so that the efficiency and accuracy of data query can be improved after the query statement is sent to the data engines.
In the data query method provided by this embodiment, a metadata configuration table is constructed, aggregation information, mapping relationship between table association information and a data engine are configured in the metadata configuration table, after a query statement is received, the query statement is analyzed, and after target aggregation information and target table association information included in the query statement are obtained, a target data engine can be obtained by searching the metadata configuration table according to the target aggregation information and the target table association information, and then the query statement is sent to the target data engine, so that data query is realized by the target data engine. Therefore, the metadata can be mapped to each data engine through the metadata configuration table without researching and developing interfaces of each data engine, so that the unification of the interfaces of each data engine is realized, the workload is greatly reduced, and the working efficiency is improved.
Based on the same inventive concept, please refer to fig. 3 in combination, the present embodiment further provides a data query apparatus 10 applied to the electronic device shown in fig. 1, as shown in fig. 3, the data query apparatus 10 provided in the present embodiment includes a statement parsing module 11, an information processing module 12 and an information routing module 13.
And the statement analysis module 11 is configured to receive the query statement, and analyze the query statement to obtain target aggregation information and target table association information included in the query statement.
The information processing module 12 is configured to search for a target data engine from a pre-constructed metadata configuration table according to the target aggregation information and the target table association information; the metadata configuration table is configured with mapping relationships among the aggregation information, the table association information and the data engine.
And the information routing module 13 is configured to send the query statement to the target data engine, so as to perform data query through the target data engine.
In an alternative embodiment, the metadata configuration table is configured with priorities of the data engines, and the information processing module 12 is configured to:
and searching whether at least one associated data engine corresponding to the target aggregation information and the target table associated information exists in the metadata configuration table or not according to the target aggregation information and the target table associated information.
And if so, determining to obtain a target data engine according to the priority of each searched associated data engine.
And if not, determining to obtain the target data engine according to the priority of each data engine in the metadata configuration table.
In an alternative embodiment, information processing module 12 is configured to:
and analyzing the target aggregation information, and judging whether the target aggregation information comprises aggregation keywords.
If the target aggregation information comprises the aggregation key words, whether at least one associated data engine corresponding to the aggregation key words and the target table associated information exists in the metadata configuration table or not is searched according to the aggregation key words and the target table associated information.
If the target aggregation information does not comprise the aggregation key words, whether at least one associated data engine corresponding to the associated information of the target table exists in the metadata configuration table or not is searched according to the associated information of the target table.
In an alternative embodiment, information processing module 12 is configured to:
and analyzing the target table association information, and judging whether the target table association information comprises one of multi-table association and single-table query.
If the target table association information comprises multi-table association, whether at least one associated data engine corresponding to the aggregation key and the multi-table association exists in the metadata configuration table or not is searched.
And if the associated information of the target table comprises single table query, searching whether at least one associated data engine corresponding to the aggregation key words and the single table query exists in the metadata configuration table or not.
In an alternative embodiment, information processing module 12 is configured to:
and analyzing the target table association information, and judging whether the target table association information comprises one of multi-table association and single-table query.
And if the target table association information comprises multi-table association, searching whether at least one associated data engine corresponding to the multi-table association exists in the metadata configuration table or not.
And if the associated information of the target table comprises single table query, searching whether at least one associated data engine corresponding to the single table query exists in the metadata configuration table or not.
In an optional embodiment, the data query apparatus 10 further includes a data caching module, and after receiving the query statement, the data caching module is further configured to:
comparing the second field in the query statement with the first field in the cache database, and judging whether a target query result corresponding to the query statement exists in the cache database; the cache database is used for storing historical query results and fields of query statements corresponding to the historical query results.
And if so, returning a target query result from the cache database.
And if the target aggregation information does not exist, analyzing the query statement to obtain the target aggregation information and the target table association information which are included in the query statement.
In an alternative embodiment, the information routing module 13 is configured to:
and acquiring metadata information of the target data engine according to the type of the target data engine.
And judging whether the metadata information is matched with the query statement.
And if the query statement is matched with the target data engine, adjusting the query statement according to the metadata information, and sending the adjusted query statement to the target data engine.
The data query device provided in this embodiment configures, by constructing the metadata configuration table, the mapping relationship between the aggregation information and the table association information and the data engine in the metadata configuration table, and after receiving the query statement, analyzes the query statement to obtain the target aggregation information and the target table association information included in the query statement, that is, after obtaining the target aggregation information and the target table association information, the target data engine may be obtained by searching the metadata configuration table according to the target aggregation information and the target table association information, and then sends the query statement to the target data engine, and data query is implemented by the target data engine. Therefore, the metadata can be mapped to each data engine through the metadata configuration table without researching and developing the interface of each data engine, so that the unification of the interfaces of each data engine is realized, the workload is greatly reduced, and the working efficiency is improved.
It can be clearly understood by those skilled in the art that, for convenience and simplicity of description, the specific working process of the data query device 10 described above may refer to the corresponding process in the foregoing method, and will not be described in detail herein.
On the basis, the embodiment further provides a readable storage medium, where the readable storage medium includes a computer program, and the computer program controls, when running, the electronic device where the readable storage medium is located to execute the data query method of any of the foregoing embodiments.
The readable storage medium may be, but is not limited to, various media that can store program codes, such as a usb disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk, or an optical disk.
It can be clearly understood by those skilled in the art that, for convenience and simplicity of description, the specific working process of the readable storage medium described above may refer to the corresponding process in the foregoing method, and redundant description is not repeated here.
In summary, in the data query method, apparatus, electronic device, and readable storage medium provided in this embodiment, a metadata configuration table is constructed, mapping relationships between aggregation information, table association information, and a data engine are configured in the metadata configuration table, after a query statement is received, the query statement is analyzed to obtain target aggregation information and target table association information included in the query statement, that is, a target data engine is obtained by searching the metadata configuration table according to the target aggregation information and the target table association information, and then the query statement is sent to the target data engine, so as to implement data query through the target data engine. Therefore, the metadata can be mapped to each data engine through the metadata configuration table without researching and developing the interface of each data engine, so that the unification of the interfaces of each data engine is realized, the workload is greatly reduced, and the working efficiency is improved.
The data query method, the data query device, the electronic device, and the readable storage medium according to the embodiments of the present invention are described in detail above, and a specific example is applied in the description to explain the principle and the implementation of the present invention, and the description of the above embodiments is only used to help understanding the technical solution and the core idea of the present invention; those of ordinary skill in the art will understand that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and such modifications or substitutions do not depart from the spirit and scope of the corresponding technical solutions of the embodiments of the present invention.

Claims (10)

1. A method of data query, the method comprising:
receiving a query statement, and analyzing the query statement to obtain target aggregation information and target table association information included in the query statement;
searching a target data engine from a pre-constructed metadata configuration table according to the target aggregation information and the target table association information; the metadata configuration table is configured with the mapping relation between the aggregation information, the table association information and the data engine;
and sending the query statement to the target data engine so as to perform data query through the target data engine.
2. The data query method of claim 1, wherein the metadata configuration table is configured with a priority of each data engine; the step of searching and obtaining a target data engine from a pre-constructed metadata configuration table according to the target aggregation information and the target table association information comprises the following steps:
searching whether at least one associated data engine corresponding to the target aggregation information and the target table associated information exists in the metadata configuration table or not according to the target aggregation information and the target table associated information;
if yes, determining to obtain the target data engine according to the searched priority of each associated data engine;
and if not, determining to obtain the target data engine according to the priority of each data engine in the metadata configuration table.
3. The data query method according to claim 2, wherein the step of searching whether at least one associated data engine corresponding to the target aggregation information and the target table association information exists in the metadata configuration table according to the target aggregation information and the target table association information includes:
analyzing the target aggregation information, and judging whether the target aggregation information comprises aggregation keywords or not;
if the target aggregation information comprises an aggregation key word, searching whether at least one associated data engine corresponding to the aggregation key word and the target table associated information exists in the metadata configuration table or not according to the aggregation key word and the target table associated information;
and if the target aggregation information does not comprise the aggregation key words, searching whether at least one associated data engine corresponding to the target table associated information exists in the metadata configuration table or not according to the target table associated information.
4. The data query method according to claim 3, wherein the step of searching whether at least one associated data engine corresponding to the aggregation key and the target table associated information exists in the metadata configuration table according to the aggregation key and the target table associated information includes:
analyzing the target table association information, and judging whether the target table association information comprises one of multi-table association and single-table query;
if the target table association information comprises multi-table association, searching whether at least one associated data engine corresponding to the aggregation key word and the multi-table association exists in the metadata configuration table;
and if the target table association information comprises single table query, searching whether at least one associated data engine corresponding to the aggregation key word and the single table query exists in the metadata configuration table.
5. The method according to claim 3, wherein the step of searching whether at least one associated data engine corresponding to the target table associated information exists in the metadata configuration table according to the target table associated information comprises:
analyzing the target table association information, and judging whether the target table association information comprises one of multi-table association and single-table query;
if the target table association information comprises multi-table association, searching whether at least one associated data engine corresponding to the multi-table association exists in the metadata configuration table;
if the target table association information comprises single table query, searching whether at least one associated data engine corresponding to the single table query exists in the metadata configuration table or not.
6. The data query method of claim 1, wherein after receiving the query statement, the method further comprises:
comparing the second field in the query statement with the first field in a cache database, and judging whether a target query result corresponding to the query statement exists in the cache database; the cache database is used for storing historical query results and fields of query statements corresponding to the historical query results;
if yes, returning the target query result from the cache database;
and if the query statement does not exist, analyzing the query statement to obtain target aggregation information and target table association information included in the query statement.
7. The data query method of claim 1, wherein the step of sending the query statement to the target data engine comprises:
acquiring metadata information of the target data engine according to the type of the target data engine;
judging whether the metadata information is matched with the query statement;
and if the query statement is matched with the target data engine, adjusting the query statement according to the metadata information, and sending the adjusted query statement to the target data engine.
8. A data query device, comprising:
the statement analysis module is used for receiving the query statement and analyzing the query statement to obtain target aggregation information and target table association information which are included in the query statement;
the information processing module is used for searching a target data engine from a pre-constructed metadata configuration table according to the target aggregation information and the target table association information; the metadata configuration table is configured with the mapping relation between the aggregation information, the table association information and the data engine;
and the information routing module is used for sending the query statement to the target data engine so as to perform data query through the target data engine.
9. An electronic device comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, wherein the processor implements the data query method of any one of claims 1 to 7 when executing the program.
10. A readable storage medium, characterized in that the readable storage medium comprises a computer program, and the computer program controls an electronic device where the readable storage medium is located to execute the data query method according to any one of claims 1 to 7 when the computer program runs.
CN202110908740.5A 2021-08-09 2021-08-09 Data query method and device, electronic equipment and readable storage medium Pending CN115705330A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110908740.5A CN115705330A (en) 2021-08-09 2021-08-09 Data query method and device, electronic equipment and readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110908740.5A CN115705330A (en) 2021-08-09 2021-08-09 Data query method and device, electronic equipment and readable storage medium

Publications (1)

Publication Number Publication Date
CN115705330A true CN115705330A (en) 2023-02-17

Family

ID=85179286

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110908740.5A Pending CN115705330A (en) 2021-08-09 2021-08-09 Data query method and device, electronic equipment and readable storage medium

Country Status (1)

Country Link
CN (1) CN115705330A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116166671A (en) * 2023-04-21 2023-05-26 南方电网数字电网研究院有限公司 Memory database table pre-association processing method, system and medium

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116166671A (en) * 2023-04-21 2023-05-26 南方电网数字电网研究院有限公司 Memory database table pre-association processing method, system and medium
CN116166671B (en) * 2023-04-21 2023-08-15 南方电网数字电网研究院有限公司 Memory database table pre-association processing method, system and medium

Similar Documents

Publication Publication Date Title
US11567956B2 (en) Background format optimization for enhanced queries in a distributed computing cluster
US10210221B2 (en) System and method for distributed database query engines
US10311055B2 (en) Global query hint specification
CN109388637B (en) Data warehouse information processing method, device, system and medium
CN110795455A (en) Dependency relationship analysis method, electronic device, computer device and readable storage medium
US11907213B2 (en) Query processing method, data source registration method, and query engine
WO2016165562A1 (en) Apparatus and method for using parameterized intermediate representation for just-in-time compilation in database query execution engine
EP3929763B1 (en) Database access methods and apparatuses
US20140337338A1 (en) Efficient multi-tenant spatial and relational indexing
US10353966B2 (en) Dynamic attributes for searching
US10157234B1 (en) Systems and methods for transforming datasets
US20150199408A1 (en) Systems and methods for a high speed query infrastructure
CN115705330A (en) Data query method and device, electronic equipment and readable storage medium
US10592506B1 (en) Query hint specification
US11567957B2 (en) Incremental addition of data to partitions in database tables
CN114138821A (en) Database query method, system and electronic equipment
Li et al. Towards efficient distributed SPARQL queries on linked data
CN111079391A (en) Report generation method and device
CN116991884A (en) Data query method and device
WO2011104750A1 (en) Database management method, database management device, and database management program
CN109871372A (en) A kind of method of combined data library tuning and program tuning
WO2017063049A1 (en) A system, method, computer program and data signal for conducting an electronic search of a database
JP2017027471A (en) Distribution database system

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