Method and device for querying data

By analyzing the target statement and determining the appropriate query engine, the efficiency of querying data in a large-scale data storage environment is solved, and flexible query methods and improved query speed are achieved.

CN112307061BActive Publication Date: 2025-02-21BEIJING JINGDONG SHANGKE INFORMATION TECH CO LTD +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN201911051553.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2019-10-31
Publication Date
2025-02-21
Estimated Expiration
2039-10-31

AI Technical Summary

Technical Problem

In a large-scale data storage environment, how to query target data quickly and efficiently, especially to achieve flexible definition of query dimensions and indicators, and the query speed is fast.

Method used

By obtaining the target statement, parsing the table name in the statement, and determining the query engine associated with the table name from the predetermined query engine set as the target query engine. In response to the target statement being a query statement, the target query engine is used to query the data table with the target query engine. data in.

Benefits of technology

It realizes determining the appropriate query engine from the query engine collection to operate the data in the target data table, enriching the data query method and improving the data query speed.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112307061B_ABST
    Figure CN112307061B_ABST
Patent Text Reader

Abstract

The embodiments of the present disclosure disclose a method and device for querying data. A specific implementation of the method includes: obtaining a target statement, wherein the target statement is used to operate data in a data table, and the target statement contains the table name of at least one data table; parsing the target statement to obtain at least one table name contained in the target statement; determining a query engine associated with at least one table name from a predetermined query engine set as a target query engine; in response to the target statement being a query statement, using the target query engine to query the data in the data table corresponding to the target statement. This implementation enriches the data query method and helps to improve the data query speed.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] Embodiments of the present disclosure relate to the field of computer technology, and in particular to a method and device for querying data. Background Art

[0002] Currently, with the rapid development of big data technology, the amount of data of major companies continues to accumulate, and EB (Exabyte)-level data storage has become very common. In such a large-scale data storage, how to quickly and efficiently query the target results has attracted more and more attention. Usually, data analysts hope that the query speed is as fast as possible, and they hope to be able to freely define query dimensions and indicators and flexibly edit query statements.

[0003] In the prior art, some query functions are implemented based on the Hive (a data warehouse tool) engine, which can store data in HDFS (distributed file system, Hadoop Distributed File System), and implement data query functions by writing HiveSQL (Structured Query Language). Among them, Hive can map structured data files into a data table, and provide simple SQL query functions, which can convert SQL statements into MapReduce (a computing model, framework and platform for parallel processing of big data) tasks for execution. Summary of the invention

[0004] The present disclosure proposes a method and apparatus for querying data.

[0005] In a first aspect, an embodiment of the present disclosure provides a method for querying data, the method comprising: obtaining a target statement, wherein the target statement is used to operate data in a data table, and the target statement contains the table name of at least one data table; parsing the target statement to obtain at least one table name contained in the target statement; determining a query engine associated with at least one table name from a predetermined set of query engines as a target query engine; and in response to the target statement being a query statement, using the target query engine to query data in the data table corresponding to the target statement.

[0006] In some embodiments, the target statement contains the table names of at least two data tables; and, parsing the target statement to obtain at least one table name contained in the target statement, including: parsing the target statement to obtain at least two table names contained in the target statement; and, determining the query engine associated with at least one table name from a predetermined set of query engines as the target query engine, including: determining the query engine associated with each of the at least two table names from a predetermined set of query engines; in response to the determined query engines indicating the same query engine, taking the same query engine indicated by each query engine as the target query engine.

[0007] In some embodiments, in response to the target statement being a query statement, before using the target query engine to query the data in the data table corresponding to the target statement, the method includes: in response to the existence of at least two different query engines among the determined query engines, for each of the at least two table names, performing the following target query engine determination step based on the table name: in response to the frequency of access to the data in the data table indicated by the table name being greater than or equal to a preset threshold, and in response to receiving creation information for instructing the creation of the data table indicated by the table name in a predetermined high-speed engine, creating the data table indicated by the table name in the high-speed engine, and using the high-speed engine after the data table is created as the target query engine.

[0008] In some embodiments, the target query engine determination step also includes: in response to the frequency of access to data in the data table indicated by the table name being greater than or equal to a preset threshold, and in response to receiving creation information indicating that the data table indicated by the table name is not created in a predetermined high-speed engine, taking the first query engine in the query engine set as the target query engine.

[0009] In some embodiments, the target statement is obtained from the user end; and a data table indicated by the table name is created in the high-speed engine, including: sending each field in the data table indicated by the table name to the user end; obtaining the fields returned by the user end and selected by the user from the various fields; based on the selected fields, creating the data table indicated by the table name in the high-speed engine, wherein the fields in the created data table indicated by the table name are the fields selected by the user from the various fields.

[0010] In some embodiments, the method further includes: in response to the first query engine failing to find data in the data table corresponding to the target statement, using a second query engine to query data in the data table corresponding to the target statement, wherein the second query engine is a query engine in the query engine set that is different from the first query engine.

[0011] In some embodiments, parsing the target statement to obtain at least one table name included in the target statement includes: matching the target statement with a predetermined regular expression to obtain at least one table name included in the target statement.

[0012] In some embodiments, a target statement is parsed to obtain at least one table name contained in the target statement, including: in response to the target statement containing a first preset keyword, parsing the target statement into a structured query language according to a parsing rule established for the first preset keyword; and extracting at least one table name from the structured query language.

[0013] In some embodiments, the method further includes: in response to the target sentence containing a second preset keyword, processing the data in the data table using a custom function corresponding to the second preset keyword to perform a custom operation indicated by the second preset keyword on the data in the data table.

[0014] In a second aspect, an embodiment of the present disclosure provides a device for querying data, the device comprising: an acquisition unit, configured to acquire a target statement, wherein the target statement is used to operate data in a data table, and the target statement contains the table name of at least one data table; a parsing unit, configured to parse the target statement to obtain at least one table name contained in the target statement; a first determination unit, configured to determine a query engine associated with at least one table name from a predetermined set of query engines as a target query engine; and a first query unit, configured to, in response to the target statement being a query statement, use the target query engine to query data in the data table corresponding to the target statement.

[0015] In some embodiments, the target statement contains the table names of at least two data tables; and the parsing unit is further configured to: parse the target statement to obtain at least two table names contained in the target statement; and the first determination unit is further configured to: determine the query engine associated with each of the at least two table names from a predetermined set of query engines; in response to the determined query engines indicating the same query engine, use the same query engine indicated by each query engine as the target query engine.

[0016] In some embodiments, the device includes: a second determination unit, configured to, in response to the existence of at least two different query engines among the determined query engines, perform the following target query engine determination step based on each of the at least two table names: in response to the frequency of access to data in the data table indicated by the table name being greater than or equal to a preset threshold, and in response to receiving creation information for instructing the creation of the data table indicated by the table name in a predetermined high-speed engine, create the data table indicated by the table name in the high-speed engine, and use the high-speed engine after the data table is created as the target query engine.

[0017] In some embodiments, the target query engine determination step also includes: in response to the frequency of access to data in the data table indicated by the table name being greater than or equal to a preset threshold, and in response to receiving creation information indicating that the data table indicated by the table name is not created in a predetermined high-speed engine, taking the first query engine in the query engine set as the target query engine.

[0018] In some embodiments, the target statement is obtained from the user end; and the second determination unit is further configured to: send each field in the data table indicated by the table name to the user end; obtain the fields returned by the user end and selected by the user from the various fields; based on the selected fields, create the data table indicated by the table name in the high-speed engine, wherein the fields in the created data table indicated by the table name are the fields selected by the user from the various fields.

[0019] In some embodiments, the device also includes: a second query unit, configured to use a second query engine to query the data in the data table corresponding to the target statement in response to the first query engine not finding the data in the data table corresponding to the target statement, wherein the second query engine is a query engine in the query engine set that is different from the first query engine.

[0020] In some embodiments, the parsing unit is further configured to: match the target statement with a predetermined regular expression to obtain at least one table name contained in the target statement.

[0021] In some embodiments, the parsing unit is further configured to: in response to the target statement containing a first preset keyword, parse the target statement into a structured query language according to a parsing rule established for the first preset keyword; and extract at least one table name from the structured query language.

[0022] In some embodiments, the device also includes: a processing unit configured to process the data in the data table using a custom function corresponding to the second preset keyword in response to the target sentence containing a second preset keyword, so as to perform a custom operation indicated by the second preset keyword on the data in the data table.

[0023] In a third aspect, an embodiment of the present disclosure provides an electronic device for querying data, comprising: one or more processors; a storage device on which one or more programs are stored, and when the one or more programs are executed by the one or more processors, the one or more processors implement a method as in any embodiment of the above-mentioned method for querying data.

[0024] In a fourth aspect, an embodiment of the present disclosure provides a computer-readable medium for querying data, on which a computer program is stored, and when the program is executed by a processor, a method as in any embodiment of the above-mentioned method for querying data is implemented.

[0025] The method and device for querying data provided by the embodiments of the present disclosure obtain a target statement, wherein the target statement is used to operate data in a data table, and the target statement contains the table name of at least one data table. Then, the target statement is parsed to obtain at least one table name contained in the target statement. Thereafter, a query engine associated with the at least one table name is determined from a predetermined query engine set as a target query engine. Finally, in the case where the target statement is a query statement, the target query engine is used to query the data in the data table corresponding to the target statement. Thus, the embodiments of the present disclosure can determine the query engine used to operate the data in the data table corresponding to the target statement from the query engine set, and then different query engines can be used to operate the data in the data tables corresponding to different target statements. Data operations are performed based on the characteristics of each query engine, thereby enriching the data query method and helping to improve the data query speed. BRIEF DESCRIPTION OF THE DRAWINGS

[0026] Other features, objects and advantages of the present disclosure will become more apparent from the detailed description of non-limiting embodiments made with reference to the following drawings:

[0027] Figure 1 is an exemplary system architecture diagram in which some embodiments of the present disclosure may be applied;

[0028] Figure 2 is a flow chart of an embodiment of a method for querying data according to the present disclosure;

[0029] Figure 3A is a schematic architecture diagram of a method for querying data according to the present disclosure;

[0030] Figure 3B is a schematic diagram of an application scenario of the method for querying data according to the present disclosure;

[0031] Figure 4 is a flow chart of another embodiment of a method for querying data according to the present disclosure;

[0032] Figure 5 is a schematic diagram of another application scenario of the method for querying data according to the present disclosure;

[0033] Figure 6 is a structural schematic diagram of an embodiment of a device for querying data according to the present disclosure;

[0034] Figure 7 It is a schematic diagram of the structure of a computer system of an electronic device suitable for implementing some embodiments of the present disclosure. DETAILED DESCRIPTION

[0035] The present disclosure is further described in detail below in conjunction with the accompanying drawings and embodiments. It is understood that the specific embodiments described herein are only used to explain the relevant invention, rather than to limit the invention. It is also necessary to explain that, for ease of description, only the parts related to the relevant invention are shown in the accompanying drawings.

[0036] It should be noted that, in the absence of conflict, the embodiments and features in the embodiments of the present disclosure may be combined with each other. The present disclosure will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.

[0037] Figure 1 An exemplary system architecture 100 is shown to which an embodiment of a method for querying data or an apparatus for querying data according to an embodiment of the present disclosure can be applied.

[0038] like Figure 1 As shown, the system architecture 100 may include terminal devices 101, 102, 103, a network 104 and a server 105. The network 104 is used to provide a medium for communication links between the terminal devices 101, 102, 103 and the server 105. The network 104 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.

[0039] The user can use the terminal devices 101, 102, 103 to interact with the server 105 through the network 104 to receive or send data (such as target sentences), etc. Various client applications can be installed on the terminal devices 101, 102, 103, such as video playback software, news information applications, image processing applications, web browser applications, shopping applications, search applications, instant messaging tools, email clients, social platform software, etc.

[0040] Terminal devices 101, 102, 103 can be hardware or software. When terminal devices 101, 102, 103 are hardware, they can be various electronic devices with data query functions, including but not limited to smart phones, tablet computers, laptop computers, desktop computers, etc. When terminal devices 101, 102, 103 are software, they can be installed in the electronic devices listed above. It can be implemented as multiple software or software modules (for example, software or software modules used to provide distributed services), or it can be implemented as a single software or software module. No specific limitation is made here.

[0041] The server 105 may be a server that provides various services, such as a background server that performs corresponding operations on the data to be operated (e.g., queried) by the terminal devices 101, 102, and 103. The background server may analyze and process the received target statement (e.g., query statement) and other data, thereby obtaining the data in the data table to be operated by the target statement (e.g., the data in the data table to be queried by the target statement). Optionally, in the case where the target statement is a query statement, the background server may also send the data in the queried data table to the terminal device. As an example, the server 105 may be a cloud server.

[0042] It should be noted that the server can be hardware or software. When the server is hardware, it can be implemented as a distributed server cluster consisting of multiple servers, or it can be implemented as a single server. When the server is software, it can be implemented as multiple software or software modules (for example, software or software modules used to provide distributed services), or it can be implemented as a single software or software module. No specific limitation is made here.

[0043] It should also be noted that the method for querying data provided by the embodiments of the present disclosure can be executed by a server, can be executed by a terminal device, or can be executed by a server and a terminal device in cooperation with each other. Accordingly, the various parts (such as various units) included in the device for querying data can be all set in the server, can be all set in the terminal device, or can be set in the server and the terminal device respectively.

[0044] It should be understood that Figure 1 The number of terminal devices, networks, and servers in the system architecture is only illustrative. Any number of terminal devices, networks, and servers may be provided as required. When the electronic device on which the method for querying data is running does not need to transmit data with other electronic devices during the execution of the method, the system architecture may only include the electronic device (e.g., server) on which the method for querying data is running.

[0045] Continue to refer Figure 2, shows a process 200 of an embodiment of a method for querying data according to the present disclosure. The method for querying data includes the following steps:

[0046] Step 201, obtaining a target sentence.

[0047] In this embodiment, the execution subject of the method for querying data (for example Figure 1 The server shown in the figure) can be connected to other electronic devices (such as Figure 1 The target statement is obtained from the terminal device shown) or locally.

[0048] The target statement is used to operate the data in the data table, and the target statement includes at least one table name of the data table. As an example, the target statement can be a statement used to perform at least one of the following operations on the data in the data table: add, delete, modify, and search.

[0049] Here, the target statement may be a statement conforming to SQL grammar, or a statement conforming to other predetermined grammatical rules, which is not limited in the embodiments of the present disclosure.

[0050] Step 202: parse the target statement to obtain at least one table name included in the target statement.

[0051] In this embodiment, the execution subject may parse the target statement acquired in step 201 to obtain at least one table name included in the target statement.

[0052] It should be understood that, generally, the execution subject can parse all table names contained in the target statement. However, when the target statement contains the same table name, the execution subject can also parse different table names contained in the target statement.

[0053] Here, when the target statement contains a Union operator, the execution subject may first split the target statement according to the Union operator for subsequent parsing.

[0054] In some optional implementations of this embodiment, the execution subject may perform step 202 in the following manner: match the target statement with a predetermined regular expression to obtain at least one table name contained in the target statement. Regular expressions, also known as rule expressions, are usually used to retrieve and replace text that conforms to predetermined rules. Many programming languages ​​support string operations using regular expressions.

[0055] It can be understood that using regular expressions can improve the speed and accuracy of obtaining table names.

[0056] In some optional implementations of this embodiment, the execution subject may also perform step 202 in the following manner:

[0057] First, in response to the target statement containing a first preset keyword, the target statement is parsed into a structured query language according to a parsing rule established for the first preset keyword.

[0058] Here, the first preset keyword may be a predetermined keyword different from an SQL keyword. As an example, the first preset keyword may be "foreach", "set", "function", etc. The parsing rule established for each first preset keyword may be implemented using a program statement.

[0059] As an example, the parsing rule corresponding to the first preset keyword "foreach" may be "if the target statement contains foreach, then the target statement is equivalently transformed into the code corresponding to foreach". For example, for the target statement "#foreach(768,838,12301)select*from app.demo_table where id=${each}" containing foreach, it can be equivalently transformed into the following code: select*from app.demo_table where id=768; select*fromapp.demo_table where id=838; select*from app.demo_table where id=12301.

[0060] As another example, the parsing rule corresponding to the first preset keyword "set" may be "if the target statement contains set, then the target statement is equivalently transformed into the code corresponding to set". For example, for the target statement containing set "#setNAME=abc select*from app.demo_table where name=${NAME}", it can be equivalently transformed into the following code: select*from app.demo_table where id='abc'.

[0061] As another example, the parsing rule corresponding to the first preset keyword "function" may be "if the target statement contains function, then the target statement is equivalently transformed into the code corresponding to the function." For example, for the target statement containing function "#function test:select*from app.demo_table where id=?select*from$test(1)a left join$test(2)b on a.name=b.name", it can be equivalently transformed into the following code: select*from(select*from app.demo_table where id=1)a left join(select*from app.demo_table where id=2)b on a.name=b.name.

[0062] It should be understood that the parsing rule corresponding to the first preset keyword can be implemented by programming by a technician, and this optional implementation will not be described in detail.

[0063] Then, at least one table name is extracted from the structured query language.

[0064] Here, after parsing the structured query language (SQL), the execution subject can extract at least one table name from the obtained structured query language. For example, for the three SQL statements "select * from app.demo_table where id = 768; select * from app.demo_table where id = 838; select * from app.demo_table where id = 12301" obtained by the above parsing, the execution subject can extract three "app.demo_table" table names.

[0065] It can be understood that this optional implementation method can achieve more flexible data query by associating the first preset keyword with the parsing rule, which helps to improve the speed of data query.

[0066] Optionally, in the process of determining the target sentence, the table name may be set at a predetermined position in the target sentence (eg, the position of the first 10 characters in the target sentence). Thus, the execution subject may directly extract at least one table name contained in the target sentence from the predetermined position.

[0067] Step 203: Determine a query engine associated with at least one table name from a predetermined query engine set as a target query engine.

[0068] In this embodiment, the execution subject may determine a query engine associated with at least one table name from a predetermined query engine set, and use the determined query engine associated with the at least one table name as a target query engine.

[0069] The query engine in the above query engine set can be any existing query engine, for example, Kylin query engine, Phoenix query engine, Elasticsearch query engine, Presto query engine, Spark query engine, etc.; it can also be a query engine built by the technicians themselves. The query engines in the above query engine set can be different from each other. For example, the query engine set can include the following five query engines: Kylin query engine, Phoenix query engine, Elasticsearch query engine, Presto query engine, Spark query engine.

[0070] Here, the table name of each stored data table can be associated with one or more query engines in the query engine set in advance. As an example, the table name of the data table can be randomly associated with a query engine in the query engine set, or the table name of the data table can be associated with a query engine in the query engine set according to the characteristics of the data in each data table.

[0071] For example, please refer to Figure 3A , Figure 3A is a schematic architecture diagram of a method for querying data according to the present disclosure. Figure 3A In the data warehouse built on HDFS (Hadoop Distributed File System), the bottom-level data can be stored. After ETL (Extract-Transform-Load), the data from different business systems are divided into multiple Hive data tables in different business fields. These data tables can only be used for the bottom-level storage of data and do not provide query services to the outside.

[0072] The data in the above data tables can be connected to various advanced query engines (i.e., various query engines in the above query engine set) through different scheduling methods. Among them, the Spark query engine is the lowest-level storage engine that provides query services. At the same time, it is also responsible for scheduling data to other query engines; the Kylin query engine and the Phoenix query engine are built on Hbase (a distributed, column-oriented open source database) and are oriented to column storage; the Elasticsearch query engine is built on Lucene (a full-text search engine) and is oriented to document storage; the Presto query engine is similar to the Hive engine and is also based on HDFS, but its calculation operations are performed in memory, and the speed is more than 10 times that of the Hive engine. In particular, the Presto query engine relies on the underlying compression of the Orc format for data storage, and the compression format converter is needed to convert the format of the Hive data table into the Orc format, so as to ensure the stable operation of the Presto query engine.

[0073] Among them, since the query speed of the Hive engine is slow, the Hive engine does not directly provide services to the outside world here, but is supported by the Spark query engine. Generally, the Spark query engine can achieve a response speed of minutes, which can improve the query performance by about half compared to the Hive engine. In addition, the Spark query engine is also responsible for synchronizing data with other query engines and making incremental updates regularly. At the same time, it can also record the description information of the data table on other query engines, including table name, field name, field type, comments, etc., and store this information persistently to provide support for the engine routing service (used to determine the query engine used to access the data in the data table through the program).

[0074] The above Presto query engine, as a supplement to the Spark query engine, can provide faster query performance. For business-customized data tables, after setting the data compression format to Orc format, you can use the Presto query engine to query the data in the data table.

[0075] For second-level query scenarios, you can use the Phoenix query engine, relying on HBase's powerful storage capacity and read and write efficiency, build appropriate indexes according to business needs, and push data through the Spark query engine. Table information (such as table name, field name, field type, and comments) can also be persistently stored to provide support for the engine routing service.

[0076] For business scenarios where indicators and dimensions do not change frequently, the Kylin query engine can be used to achieve sub-second query speeds. Configure the Cube in the Kylin query engine, and the Spark query engine triggers the Build operation through the application programming interface. Since too many fields will reduce the query efficiency of the Kylin query engine, a controller can be used to periodically trigger the Merge operation in the SQL statement (used to merge the update and insert statements in the Sql statement, and can query another table based on the connection conditions of a table or subquery, and perform update operations on the connection conditions that match, and perform insert operations on unmatched conditions). Table information (such as table name, field name, field type, and comments) can also be persistently stored to provide support for the engine routing service.

[0077] For scenarios that require full-text retrieval, the Elasticsearch query engine can be used. The Spark query engine can extract data to obtain a matrix data table (Dataframe), then convert it into a JavaRDD (Java Resilient Distributed Datasets) through a function, and then call the Bulk API (used to implement batch operations) to write the data in batches. Since the query language of the Elasticsearch query engine is not SQL, a set of plug-ins (such as the Elasticsearch-sql plug-in) needs to be deployed on the Elasticsearch query engine to provide support for the JDBC (Java DataBase Connectivity) driver.

[0078] The above lists the five query engines in the query engine set (i.e., Kylin query engine, Phoenix query engine, Elasticsearch query engine, Presto query engine, and Spark query engine). Each of them has its own application scenario. Therefore, an engine routing service can be used to decide when to use which engine for querying. Table names and query engines can be associated and stored in the engine configuration library. When a SQL statement (such as a target statement) is sent, all table names in the statement are obtained by regular matching, and then, from the above query engine set, the query engine associated with the obtained table name is determined as the target query engine.

[0079] Return below Figure 2 .

[0080] Step 204 , in response to the target statement being a query statement, using a target query engine to query data in a data table corresponding to the target statement.

[0081] In this embodiment, when the target statement obtained in step 201 is a query statement, the execution subject may also use the target query engine determined in step 203 to query the data in the data table corresponding to the target statement. The query statement may be a statement for querying the data in the data table. The query statement may be a statement conforming to the SQL grammar, or a statement conforming to other predetermined grammatical rules. The data table corresponding to the target statement may be a data table indicated by the table name contained in the target statement.

[0082] Continue to see Figure 3B , Figure 3B FIG. 1 is a schematic diagram of an application scenario of the method for querying data according to this embodiment. Figure 3B In the application scenario, the server 301 first obtains the target statement 3011. As shown in the figure, the target statement 3011 is used to query the non-empty data of the field comm in the data table with the table name emp. The table name of the data table contained in the target statement 3011 is "emp". Then, the server 301 parses the target statement 3011 to obtain the table name 3012 (emp in the figure) contained in the target statement 3011. After that, the server 301 determines the query engine associated with the table name "emp" from the predetermined query engine set 3013 as the target query engine 3014. Finally, the server 301 uses the target query engine 3014 to query the data in the data table 3015 corresponding to the target statement 3011. As an example, in the figure, the server 301 uses the target query engine 3014 to query the data in the data table 3015 (that is, the data table indicated by the table name emp) corresponding to the target statement 3011, thereby obtaining the query result 3016.

[0083] The method for querying data provided by the above-mentioned embodiments of the present disclosure obtains a target statement, wherein the target statement is used to operate data in a data table, and the target statement contains the table name of at least one data table. Then, the target statement is parsed to obtain at least one table name contained in the target statement. Thereafter, a query engine associated with the at least one table name is determined from a predetermined query engine set as a target query engine. Finally, in the case where the target statement is a query statement, the target query engine is used to query the data in the data table corresponding to the target statement. Thus, the embodiments of the present disclosure can determine the query engine used to operate the data in the data table corresponding to the target statement from the query engine set, and then different query engines can be used to operate the data in the data tables corresponding to different target statements. Data operations are performed based on the characteristics of each query engine, thereby enriching the data query method and helping to improve the data query speed.

[0084] In some optional implementations of this embodiment, the target statement may also include the table names of at least two data tables. Therefore, the above step 202 may include: parsing the target statement to obtain at least two table names included in the target statement. Based on this, the above execution subject may perform the above step 203 in the following manner:

[0085] First, a query engine associated with each of the at least two table names is determined from a predetermined query engine set.

[0086] Then, in the case that the determined query engines indicate the same query engine, the same query engine indicated by the query engines is used as the target query engine.

[0087] It can be understood that this optional implementation method can determine the target query engine associated with each table name in at least two table names when the determined query engines indicate the same query engine, so that the data in the data table indicated by each table name in at least two table names can be queried through the target query engine.

[0088] In some optional implementations of this embodiment, the above execution subject may further perform the following steps:

[0089] In response to the target sentence containing the second preset keyword, the data in the data table is processed using a custom function corresponding to the second preset keyword to perform a custom operation indicated by the second preset keyword on the data in the data table.

[0090] The second preset keyword may be a predetermined string. The custom function corresponding to the second preset keyword may be a function (also referred to as a method, operator (e.g., Spark operator)) written by a technician for the second preset keyword. The second preset keyword is different from the first preset keyword.

[0091] Exemplarily, the custom function corresponding to the second preset keyword "UDF" can be used to process column transformation; the custom function corresponding to the second preset keyword "UDAF" can be used to aggregate multiple rows of data in a data table; the custom function corresponding to the second preset keyword "${yesterday}" can be used to obtain yesterday's date; the custom function corresponding to the second preset keyword "${last_month}" can be used to obtain last month's date; the custom function corresponding to the second preset keyword "${N_days_ago}" can be used to obtain the date N days ago, where N can be an integer greater than 2; the custom function corresponding to the second preset keyword "${M_months_ago}" can be used to obtain the date M months ago, where M can be an integer greater than 2.

[0092] It should be understood that the above-mentioned custom function corresponding to the second preset keyword can be written by a technician himself, and this optional implementation will not be described in detail.

[0093] It can be understood that this optional implementation method uses a custom function corresponding to the second preset keyword to process the data in the data table, so as to further expand the functions that can be achieved by the existing keywords, thereby realizing advanced SQL-oriented programming requirements and making data query more efficient and flexible.

[0094] Further references Figure 4 , which shows a process 400 of another embodiment of a method for querying data. The process 400 of the method for querying data includes the following steps:

[0095] Step 401, obtain the target sentence. Then, execute step 402.

[0096] In this embodiment, the execution subject of the method for querying data (for example Figure 1 The server shown in FIG. 1 may obtain a target statement, wherein the target statement is used to operate data in a data table, and the target statement includes table names of at least two data tables.

[0097] Step 402: parse the target statement to obtain at least two table names contained in the target statement. Then, execute step 403.

[0098] In this embodiment, the execution entity may parse the target statement to obtain at least two table names included in the target statement.

[0099] Step 403: From a predetermined set of query engines, determine the query engine associated with each of the at least two table names. Then, execute step 404.

[0100] In this embodiment, the execution entity may determine, from a predetermined set of query engines, a query engine associated with each of the at least two table names.

[0101] Step 404, determining whether the determined query engines indicate the same query engine. If so, then executing step 405; if not, then executing step 406.

[0102] In this embodiment, the execution entity may determine whether the determined query engines indicate the same query engine.

[0103] Step 405: The same query engine indicated by each query engine is used as the target query engine. Then, step 407 is executed.

[0104] In this embodiment, when the determined query engines indicate the same query engine, the execution subject may use the same query engine indicated by the query engines as the target query engine.

[0105] Step 406, for each of the at least two table names, the following target query engine determination step is performed based on the table name: in response to the frequency of data in the data table indicated by the table name being accessed being greater than or equal to a preset threshold, and in response to receiving creation information for instructing to create the data table indicated by the table name in a predetermined high-speed engine, the data table indicated by the table name is created in the high-speed engine, and the high-speed engine after the data table is created is used as the target query engine. Thereafter, step 407 is performed.

[0106] In this embodiment, when the determined query engines do not indicate the same query engine (i.e., there are at least two different query engines among the determined query engines), the execution subject may perform the following target query engine determination step based on the table name for each of the at least two table names: in response to the frequency of data in the data table indicated by the table name being accessed being greater than or equal to a preset threshold, and in response to receiving creation information for indicating the creation of the data table indicated by the table name in a predetermined high-speed engine, the data table indicated by the table name is created in the high-speed engine, and the high-speed engine after the data table is created is used as the target query engine. The high-speed engine may be an in-memory computing engine. As an example, the high-speed engine may be a Presto query engine or a Spark query engine. The creation information may be information sent by a user end (i.e., an electronic device used by a user) to indicate whether to create a data table in a high-speed engine.

[0107] Step 407: In response to the target statement being a query statement, a target query engine is used to query data in a data table corresponding to the target statement.

[0108] In this embodiment, when the target statement is a query statement, the execution subject may use a target query engine to query data in a data table corresponding to the target statement.

[0109] It should be noted that, in addition to the above contents, this embodiment may also include Figure 2 The same or similar features and effects as those in the corresponding embodiments will not be described in detail here.

[0110] from Figure 4 It can be seen that the process 400 of the method for querying data in this embodiment can use different query engines in the query engine set to implement operations on data in the data table according to different application scenarios, thereby further enriching the data query method and improving the data query speed.

[0111] In some optional implementations of this embodiment, the target query engine determination step in the above optional implementations further includes:

[0112] In response to the frequency of data in the data table indicated by the table name being accessed being greater than or equal to a preset threshold, and in response to receiving creation information for indicating that the data table indicated by the table name is not to be created in a predetermined high-speed engine, the first query engine in the query engine set is used as the target query engine. The first query engine may be any query engine in the query engine set, or may be a predetermined query engine in the query engine set. As an example, the first query engine may be a Presto query engine.

[0113] It can be understood that this optional implementation method can use the first query engine to query the data in the data table corresponding to the target statement without creating the data table indicated by the table name in a predetermined high-speed engine, thereby omitting the step of creating the data table indicated by the table name and improving the speed of accessing the data in the data table.

[0114] In some optional implementations of this embodiment, the target statement is obtained from the user end. Therefore, the execution subject can use the following method to execute the "creating the data table indicated by the table name in the high-speed engine" in the optional implementation:

[0115] The first step is to send each field in the data table indicated by the table name to the user end.

[0116] The second step is to obtain the fields returned by the user end and selected by the user from various fields.

[0117] The third step is to create a data table indicated by the table name in the high-speed engine based on the selected fields, wherein the fields in the created data table indicated by the table name are the fields selected by the user from various fields.

[0118] It can be understood that after the execution subject sends all the fields in the data table indicated by the table name to the user terminal, the user terminal can present the received fields, and then the user can select one or more fields from all the fields in the data table indicated by the table name through the user terminal used by the user. Here, the user can select fields according to actual needs. For example, the user can select fields in the data table whose access frequency is greater than or equal to the preset frequency threshold, or first determine the storage space occupied by each field in the data table, and then select fields whose storage space occupied is less than or equal to the preset threshold.

[0119] It can be understood that this optional implementation method can create a data table indicated by the table name in the high-speed engine according to the fields selected by the user, so that the created data table does not contain fields not selected by the user. Compared with the solution of using all the fields in the data table to create a data table in the high-speed engine, when the high-speed engine is an in-memory computing engine, this optional implementation method can reduce the memory space occupied by the created data table and improve the speed of subsequent access to data in the created data table.

[0120] In some optional implementations of this embodiment, the above execution subject may further perform the following steps:

[0121] In response to the first query engine failing to find data in the data table corresponding to the target statement, a second query engine is used to query data in the data table corresponding to the target statement, wherein the second query engine is a query engine in the query engine set that is different from the first query engine.

[0122] Here, the second query engine may be any query engine in the query engine set that is different from the first query engine, or may be a predetermined query engine in the query engine set that is different from the first query engine. As an example, when the query engine set consists of a Kylin query engine, a Phoenix query engine, an Elasticsearch query engine, a Presto query engine, and a Spark query engine, the first query engine may be a Presto query engine, and the second query engine may be a Spark query engine.

[0123] It can be understood that since each query engine in the query engine set may be suitable for querying data in different storage forms, for a certain query engine, the storage form of the data in the data table corresponding to the target statement may be different from the storage form of the data that it is suitable for querying, resulting in the query engine failing to query the data in the data table corresponding to the target statement. In this scenario, a second query engine different from the first query engine can be used to query the data in the data table corresponding to the target statement, thereby obtaining query results, thereby enriching the data query method.

[0124] As an example, please refer to Figure 5 , Figure 5 This is a schematic diagram of another application scenario of the method for querying data according to the present disclosure. The example of the method for querying data can be implemented by the following steps (including steps 501 to 514):

[0125] Step 501, obtain the target sentence from the user terminal. Then, execute step 502.

[0126] In this example, the execution body of the method for querying data (for example Figure 1 The server shown in the figure can obtain the target statement from the user terminal through a wired connection mode or a wireless connection mode. The target statement is used to operate the data in the data table, and the target statement contains the table names of at least two data tables.

[0127] Step 502: parse the target statement to obtain at least two table names contained in the target statement. Then, execute step 503.

[0128] In this example, the execution entity may parse the target statement to obtain at least two table names included in the target statement.

[0129] Step 503: From a predetermined set of query engines, a query engine associated with each of the at least two table names is determined. Then, step 504 is executed.

[0130] In this example, the execution subject may determine the query engine associated with each of the at least two table names from the predetermined query engine set.

[0131] Step 504, determining whether the determined query engines indicate the same query engine. If the determined query engines indicate the same query engine, then executing step 505; if the determined query engines do not indicate the same query engine, that is, there are at least two different query engines among the determined query engines, then executing step 506.

[0132] In this example, the execution entity may determine whether the determined query engines indicate the same query engine.

[0133] Step 505: The same query engine indicated by each query engine is used as the target query engine. Then, step 512 is executed.

[0134] In this example, when the determined query engines indicate the same query engine, the execution subject may use the same query engine indicated by the query engines as the target query engine.

[0135] Step 506: Select a table name from the at least two table names. Then, execute step 507.

[0136] In this example, when the determined query engines do not indicate the same query engine (ie, there are at least two different query engines among the determined query engines), the execution entity may select a table name from the at least two table names.

[0137] Step 507, determining whether the access frequency of the data in the data table indicated by the table name is greater than or equal to a preset threshold. If the access frequency of the data in the data table indicated by the table name is greater than or equal to the preset threshold, then executing step 508.

[0138] In this example, the execution subject may determine whether the access frequency of the data in the data table indicated by the table name is greater than or equal to a preset threshold.

[0139] Step 508, determining whether creation information for instructing to create the data table indicated by the table name in a predetermined high-speed engine is received. Afterwards, if creation information for instructing to create the data table indicated by the table name in a predetermined high-speed engine is received, step 509 is executed; if creation information for instructing to create the data table indicated by the table name in a predetermined high-speed engine is not received, or if creation information for instructing not to create the data table indicated by the table name in a predetermined high-speed engine is received, step 510 is executed.

[0140] In this example, when it is determined in step 507 that the frequency of access to the data in the data table indicated by the table name is greater than or equal to a preset threshold, the execution entity may determine whether creation information is received for instructing the creation of the data table indicated by the table name in a predetermined high-speed engine.

[0141] Step 509, sending each field in the data table indicated by the table name to the user end, obtaining the field selected by the user from the fields returned by the user end, creating the data table indicated by the table name in the high-speed engine based on the selected field, and using the high-speed engine after the data table is created as the target query engine. Then, step 511 is executed.

[0142] In this example, if it is determined in step 508 that creation information for instructing to create a data table indicated by the table name in a predetermined high-speed engine is received, the execution subject may send each field in the data table indicated by the table name to the user terminal, obtain the field selected by the user from each field returned by the user terminal, create the data table indicated by the table name in the high-speed engine based on the selected field, and use the high-speed engine after the data table is created as the target query engine. The fields in the created data table indicated by the table name are the fields selected by the user from each field.

[0143] Step 510: Use the first query engine in the query engine set as the target query engine. Then, execute step 511.

[0144] In this example, if it is determined in step 508 that no creation information is received for instructing to create the data table indicated by the table name in a predetermined high-speed engine, or if creation information is received for instructing not to create the data table indicated by the table name in a predetermined high-speed engine, the above-mentioned execution entity can use the first query engine in the query engine set as the target query engine.

[0145] Step 511, determining whether there is an unselected table name among the at least two table names. If there is an unselected table name among the at least two table names, then executing step 513; if there is no unselected table name among the at least two table names, then executing step 512.

[0146] In this example, the execution subject may determine whether there is an unselected table name among the at least two table names.

[0147] Step 512: In response to the target statement being a query statement, a target query engine is used to query data in a data table corresponding to the target statement. Then, step 514 is executed.

[0148] In this example, in step 511, when it is determined that there is an unselected table name among the at least two table names, and when the target statement is a query statement, the execution subject may use the target query engine to query the data in the data table corresponding to the target statement.

[0149] Step 513: Select a table name that has not been selected from the at least two table names. Then, execute step 507.

[0150] In this example, in step 511 , it is determined that there is no unselected table name in the at least two table names, and the execution subject may select an unselected table name from the at least two table names.

[0151] Step 514: In response to the first query engine not finding the data in the data table corresponding to the target statement, a second query engine is used to query the data in the data table corresponding to the target statement.

[0152] In this example, when the first query engine fails to find data in the data table corresponding to the target statement, the execution subject may use a second query engine to query data in the data table corresponding to the target statement. The second query engine is a query engine in the query engine set that is different from the first query engine.

[0153] from Figure 5It can be seen that the method for querying data in this application scenario can use different query engines in the query engine set to implement data operations in the data table for different application scenarios, and can provide minute-level, second-level, and even sub-second-level query services. At the same time, it can meet richer grammatical expression capabilities, support simple control logic, simplify the logic of time processing, text processing, and collection processing, and enable users to flexibly use structured query language-like syntax to implement complex business query tasks.

[0154] Further references Figure 6 , as a response to the above Figure 2 The present disclosure provides an embodiment of a device for querying data. Figure 2 Corresponding to the method embodiment shown in FIG. 1 , in addition to the features described below, the device embodiment may also include Figure 2 The same or corresponding features of the method embodiment shown, and the generation of Figure 2 The method embodiment shown has the same or corresponding effects. The device can be specifically applied to various electronic devices.

[0155] like Figure 6 As shown, the device 600 for querying data in this embodiment includes: an acquisition unit 601 is configured to acquire a target statement, wherein the target statement is used to operate data in a data table, and the target statement contains the table name of at least one data table; a parsing unit 602 is configured to parse the target statement to obtain at least one table name contained in the target statement; a first determination unit 603 is configured to determine a query engine associated with at least one table name from a predetermined query engine set as a target query engine; and a first query unit 604 is configured to use the target query engine to query data in the data table corresponding to the target statement in response to the target statement being a query statement.

[0156] In this embodiment, the acquisition unit 601 of the apparatus 600 for querying data can obtain data from other electronic devices (such as Figure 1 The target statement is obtained locally by using the terminal device shown in the figure. The target statement is used to operate the data in the data table, and the target statement includes the table name of at least one data table. As an example, the target statement can be a statement for performing at least one of the following operations on the data in the data table: adding, deleting, modifying, and searching.

[0157] In this embodiment, the parsing unit 602 may parse the target sentence acquired by the acquiring unit 601 to obtain at least one table name included in the target sentence. The parsing unit 602 may parse all the table names included in the target sentence. However, when the target sentence includes the same table name, the apparatus 600 may also parse different table names included in the target sentence.

[0158] In this embodiment, the first determination unit 603 can determine a query engine associated with at least one table name from a predetermined query engine set as a target query engine. The query engine in the query engine set can be any existing query engine, such as Kylin query engine, Phoenix query engine, Elasticsearch query engine, Presto query engine, Spark query engine, etc.; it can also be a query engine built by a technician.

[0159] In this embodiment, when the target statement acquired by the acquisition unit 601 is a query statement, the first query unit 604 may also use the target query engine determined by the first determination unit 603 to query the data in the data table corresponding to the target statement. The query statement may be a statement for querying the data in the data table. The query statement may be a statement conforming to the SQL grammar, or a statement conforming to other predetermined grammar rules.

[0160] In some optional implementations of this embodiment, the target statement includes the table names of at least two data tables; and the parsing unit 602 is further configured to: parse the target statement to obtain the at least two table names included in the target statement. And the first determination unit 603 is further configured to: determine the query engine associated with each of the at least two table names from a predetermined query engine set; in response to the determined query engines indicating the same query engine, use the same query engine indicated by the query engines as the target query engine.

[0161] In some optional implementations of the present embodiment, the device 600 includes: a second determination unit (not shown in the figure), configured to, in response to the existence of at least two different query engines among the determined query engines, perform the following target query engine determination step based on the table name for each of the at least two table names: in response to the frequency of access to data in the data table indicated by the table name being greater than or equal to a preset threshold, and in response to receiving creation information for instructing the creation of the data table indicated by the table name in a predetermined high-speed engine, create the data table indicated by the table name in the high-speed engine, and use the high-speed engine after the data table is created as the target query engine.

[0162] In some optional implementations of the present embodiment, the target query engine determination step further includes: in response to the frequency of access to data in the data table indicated by the table name being greater than or equal to a preset threshold, and in response to receiving creation information indicating that the data table indicated by the table name is not created in a predetermined high-speed engine, taking the first query engine in the query engine set as the target query engine.

[0163] In some optional implementations of this embodiment, the target statement is obtained from the user end; and the second determination unit (not shown in the figure) can be further configured to: send the various fields in the data table indicated by the table name to the user end; obtain the fields returned by the user end and selected by the user from the various fields; based on the selected fields, create the data table indicated by the table name in the high-speed engine, wherein the fields in the created data table indicated by the table name are the fields selected by the user from the various fields.

[0164] In some optional implementations of the present embodiment, the device 600 also includes: a second query unit (not shown in the figure), which is configured to use a second query engine to query the data in the data table corresponding to the target statement in response to the first query engine not finding the data in the data table corresponding to the target statement, wherein the second query engine is a query engine in the query engine set that is different from the first query engine.

[0165] In some optional implementations of this embodiment, the parsing unit 602 may be further configured to: match the target statement with a predetermined regular expression to obtain at least one table name included in the target statement.

[0166] In some optional implementations of this embodiment, the parsing unit 602 may also be further configured to: in response to the target statement containing a first preset keyword, parse the target statement into a structured query language according to a parsing rule established for the first preset keyword; and extract at least one table name from the structured query language.

[0167] In some optional implementations of this embodiment, the device 600 also includes: a processing unit (not shown in the figure), which is configured to process the data in the data table using a custom function corresponding to the second preset keyword in response to the target sentence containing a second preset keyword, so as to perform a custom operation indicated by the second preset keyword on the data in the data table.

[0168] The device for querying data provided by the above-mentioned embodiment of the present disclosure obtains a target statement through an acquisition unit 601, wherein the target statement is used to operate data in a data table, and the target statement contains a table name of at least one data table. Then, the parsing unit 602 parses the target statement to obtain at least one table name contained in the target statement. After that, the first determination unit 603 determines a query engine associated with the at least one table name from a predetermined query engine set as a target query engine. Finally, in response to the target statement being a query statement, the first query unit 604 uses the target query engine to query data in the data table corresponding to the target statement. Therefore, the device for querying data provided by the above-mentioned embodiment of the present disclosure can determine a query engine for operating data in a data table corresponding to the target statement from a query engine set, and then different query engines can be used to operate data in data tables corresponding to different target statements. Data operations are performed based on the characteristics of each query engine, thereby enriching the data query method and helping to improve the data query speed.

[0169] Reference below Figure 7 , which shows an electronic device (eg, Figure 1 The terminal device in the embodiment of the present disclosure may include but is not limited to mobile terminals such as mobile phones, notebook computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 7 The terminal device / server shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.

[0170] like Figure 7 As shown, the electronic device 700 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 701, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 702 or a program loaded from a storage device 708 into a random access memory (RAM) 703. In the RAM 703, various programs and data required for the operation of the electronic device 700 are also stored. The processing device 701, the ROM 702, and the RAM 703 are connected to each other via a bus 704. An input / output (I / O) interface 705 is also connected to the bus 704.

[0171] Typically, the following devices may be connected to the I / O interface 705: an input device 706 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 707 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 708 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 709. The communication device 709 may allow the electronic device 700 to communicate with other devices wirelessly or by wire to exchange data. Although Figure 7 The electronic device 700 is shown with various devices, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead. Figure 7 Each block shown in the figure may represent one device, or may represent multiple devices as required.

[0172] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device 709, or installed from a storage device 708, or installed from a ROM 702. When the computer program is executed by the processing device 701, the above-mentioned functions defined in the method of the embodiment of the present disclosure are executed.

[0173] It should be noted that the computer-readable medium described in the embodiments of the present disclosure may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the embodiments of the present disclosure, the computer-readable storage medium may be any tangible medium containing or storing a program, which may be used by or in combination with an instruction execution system, device or device. In the embodiments of the present disclosure, the computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, in which a computer-readable program code is carried. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. The computer readable signal medium may also be any computer readable medium other than a computer readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer readable medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.

[0174] The computer-readable medium may be included in the electronic device; or it may exist independently without being installed in the electronic device. The computer-readable medium carries one or more programs. When the one or more programs are executed by the electronic device, the electronic device: obtains a target statement, wherein the target statement is used to operate data in a data table, and the target statement contains the name of at least one data table; parses the target statement to obtain at least one table name contained in the target statement; determines a query engine associated with at least one table name from a predetermined query engine set as a target query engine; and in response to the target statement being a query statement, uses the target query engine to query data in the data table corresponding to the target statement.

[0175] Computer program code for performing the operations of embodiments of the present disclosure may be written in one or more programming languages ​​or a combination thereof, including object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on a user's computer, partially on a user's computer, as a separate software package, partially on a user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0176] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some implementations as replacements, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0177] The units involved in the embodiments described in the present disclosure may be implemented by software or by hardware. The described units may also be arranged in a processor, for example, may be described as: a processor includes an acquisition unit, a parsing unit, a first determination unit, and a first query unit. The names of these units do not constitute a limitation on the units themselves in certain cases, for example, the acquisition unit may also be described as a "unit for acquiring a target sentence".

[0178] The above description is only a preferred embodiment of the present disclosure and an explanation of the technical principles used. Those skilled in the art should understand that the scope of the invention involved in the present disclosure is not limited to the technical solution formed by a specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above invention concept. For example, the above features are replaced with the technical features with similar functions disclosed in the present disclosure (but not limited to) by each other.

Claims

1. A method for querying data, comprising: Obtaining a target statement, wherein the target statement is used to operate data in a data table, and the target statement includes table names of at least two data tables; Parsing the target statement to obtain the at least two table names included in the target statement; Determine, from a predetermined set of query engines, a query engine associated with each of the at least two table names; In response to the determined query engines indicating the same query engine, taking the same query engine indicated by the query engines as a target query engine; In response to the target statement being a query statement, the target query engine is used to query data in a data table corresponding to the target statement.

2. The method according to claim 1, wherein: Before, in response to the target statement being a query statement, using the target query engine to query data in a data table corresponding to the target statement, the method includes: In response to the existence of at least two different query engines among the determined query engines, for each of the at least two table names, the following target query engine determination step is performed based on the table name: in response to the frequency of access to data in the data table indicated by the table name being greater than or equal to a preset threshold, and in response to receiving creation information for instructing the creation of the data table indicated by the table name in a predetermined high-speed engine, the data table indicated by the table name is created in the high-speed engine, and the high-speed engine after the data table is created is used as the target query engine.

3. The method according to claim 2, wherein: The target query engine determination step further includes: In response to the frequency of data in the data table indicated by the table name being accessed being greater than or equal to a preset threshold, and in response to receiving creation information indicating that the data table indicated by the table name is not to be created in a predetermined high-speed engine, the first query engine in the query engine set is used as the target query engine.

4. The method according to claim 2, wherein: The target sentence is obtained from the user end; as well as The step of creating the data table indicated by the table name in the high-speed engine includes: Sending each field in the data table indicated by the table name to the user terminal; Obtaining a field returned by the user terminal and selected by the user from the various fields; Based on the selected fields, a data table indicated by the table name is created in the high-speed engine, wherein the fields in the created data table indicated by the table name are the fields selected by the user from the various fields.

5. The method according to claim 3, wherein: The method further comprises: In response to the first query engine failing to find data in the data table corresponding to the target statement, a second query engine is used to query data in the data table corresponding to the target statement, wherein the second query engine is a query engine in the query engine set that is different from the first query engine.

6. The method according to any one of claims 1 to 5, wherein: The step of parsing the target statement to obtain the at least one table name contained in the target statement includes: The target statement is matched using a predetermined regular expression to obtain the at least one table name included in the target statement.

7. The method according to any one of claims 1 to 5, wherein: The step of parsing the target statement to obtain the at least one table name contained in the target statement includes: In response to the target statement containing a first preset keyword, parsing the target statement into a structured query language according to a parsing rule established for the first preset keyword; The at least one table name is extracted from the structured query language.

8. The method according to any one of claims 1 to 5, wherein: The method further comprises: In response to the target sentence containing a second preset keyword, the data in the data table is processed using a custom function corresponding to the second preset keyword to perform a custom operation indicated by the second preset keyword on the data in the data table.

9. A device for querying data, comprising: An acquisition unit is configured to acquire a target statement, wherein the target statement is used to operate data in a data table, and the target statement contains table names of at least two data tables; A parsing unit, configured to parse the target statement to obtain the at least two table names included in the target statement; A first determining unit is configured to determine, from a predetermined set of query engines, a query engine associated with each of the at least two table names; A first responding unit is configured to, in response to the determined query engines indicating the same query engine, use the same query engine indicated by the query engines as a target query engine; The first query unit is configured to, in response to the target statement being a query statement, use the target query engine to query data in a data table corresponding to the target statement.

10. An electronic device, comprising: one or more processors; a storage device having one or more programs stored thereon, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 8.

11. A computer readable medium having a computer program stored thereon, wherein: When the program is executed by a processor, the method according to any one of claims 1 to 8 is implemented.

Citation Information

Patent Citations

  • Data query method and device

    CN109710859A

  • Data query platform, method, and equipment and storage medium

    CN110222072A