Index query method, device, electronic device and readable storage medium

By creating virtual tables to obtain historical and real-time data from preset databases and real-time calculation engines, it solves the complexity of offline and real-time data processing in business indicator queries, simplifies the query process, and improves efficiency and resource utilization.

CN118394800BActive Publication Date: 2024-09-24BEIJING DIPEAK TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410810498.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-06-21
Publication Date
2024-09-24
Estimated Expiration
2044-06-21

AI Technical Summary

Technical Problem

In data analysis scenarios, the query of business indicators needs to process both offline and real-time data. The existing technology requires two independent sets of query logic and calculation logic, resulting in a cumbersome query process, high professional quality requirements and a waste of human resources.

Method used

By creating the first virtual table and the second virtual table, historical and real-time data are obtained from the preset database and real-time calculation engine respectively, and the same table structure is used for aggregation processing to simplify the query process.

Benefits of technology

It realizes unified query of historical and real-time data, reduces the difficulty and cost of data research and development, improves the efficiency of data processing and analysis, and saves human resources.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118394800B
    Figure CN118394800B
Patent Text Reader

Abstract

The embodiment of the present application provides a method, device, electronic device and readable storage medium for querying indicators, and relates to the field of data processing technology. The method includes: obtaining query conditions for the indicators to be queried; if the query time period includes both the current time period and the historical time period, obtaining a first virtual table and a second virtual table with the same table structure that are pre-created for the indicators to be queried; obtaining the first indicator value of each drill-down indicator in the historical time period according to the first virtual table and the data in the preset database; obtaining the second indicator value of each drill-down indicator in the current time period according to the data in the second virtual table and the real-time computing engine; and performing aggregation processing on the first indicator value and the second indicator value of each drill-down indicator according to the first aggregation metric to obtain the indicator value of the indicator to be queried. This simplifies the query operation by using only one set of query conditions to simultaneously obtain the indicator values ​​obtained based on the data of the historical time period and the current time period.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data processing technology. Specifically, the present application relates to an indicator query method, device, electronic device and readable storage medium. Background Art

[0002] In the data analysis scenario, the industry reporting field needs to provide users with business indicators (referred to as "indicators") that allow them to directly view business data. Indicators are key quantitative indicators used to measure business operations and are very important data analysis assets.

[0003] The data required for indicator calculation is stored in different locations due to the difference between offline and real-time. Offline data is usually written to the database; while real-time data is usually stored in the real-time calculation engine and has not been written to the database yet.

[0004] With the development of business, data users have more requirements for the timeliness of indicators. When querying business indicators, offline data and real-time data need to be queried separately using two sets of query logic, and indicators need to be calculated using two sets of logic. The queryer is also required to manually splice the results of the two parts of the indicators. The query method is cumbersome, requires a high level of professional quality from the queryer, and wastes human resources. Summary of the invention

[0005] According to a first aspect of an embodiment of the present application, a method for querying an indicator is provided, the method comprising:

[0006] Obtain query conditions for the indicator to be queried, where the query conditions include a query time period, each drill-down indicator of the indicator to be queried, and a first aggregated metric of each drill-down indicator;

[0007] If it is determined that the query time period includes both the current time period and the historical time period, the current time period is a time period in the current cycle, and the historical time period is a time period in at least one historical cycle, then a first virtual table and a second virtual table pre-created for the indicator to be queried are obtained; the data source of the first virtual table is a preset database, and the data source of the second virtual table is a real-time computing engine; the first virtual table and the second virtual table have the same table structure;

[0008] According to the data in the first virtual table and the preset database, the first indicator value corresponding to each drill-down indicator in the historical time period is obtained; according to the data in the second virtual table and the real-time calculation engine, the second indicator value corresponding to each drill-down indicator in the current time period is obtained;

[0009] According to the first aggregation metric of each drill-down indicator, the first indicator value and the second indicator value of each drill-down indicator are aggregated, and the aggregated indicator value is used as the indicator value of the indicator to be queried.

[0010] According to a second aspect of an embodiment of the present application, a device for querying an indicator is provided, the device comprising:

[0011] A first acquisition module is used to acquire query conditions of the indicator to be queried, where the query conditions include a query time period, each drill-down indicator of the indicator to be queried, and a first aggregated metric of each drill-down indicator;

[0012] a processing module, configured to obtain a first virtual table and a second virtual table pre-created for the indicator to be queried if it is determined that the query time period includes both the current time period and the historical time period, the current time period is a time period in the current cycle, and the historical time period is a time period in at least one historical cycle; the data source of the first virtual table is a preset database, and the data source of the second virtual table is a real-time computing engine; the first virtual table and the second virtual table have the same table structure;

[0013] The second acquisition module is used to obtain the first indicator value corresponding to each drill-down indicator in the historical time period according to the data in the first virtual table and the preset database; and obtain the second indicator value corresponding to each drill-down indicator in the current time period according to the data in the second virtual table and the real-time calculation engine;

[0014] The aggregation module is used to aggregate the first indicator value and the second indicator value of each drill-down indicator according to the first aggregation metric of each drill-down indicator, and use the aggregated indicator value as the indicator value of the indicator to be queried.

[0015] According to a third aspect of an embodiment of the present application, an electronic device is provided, which includes a memory, a processor, and a computer program stored in the memory, and when the processor executes the program, the steps of the method provided in the first aspect are implemented.

[0016] According to a fourth aspect of an embodiment of the present application, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps of the method provided in the first aspect are implemented.

[0017] According to the fifth aspect of the embodiment of the present application, a computer program product is provided, which includes computer instructions, and the computer instructions are stored in a computer-readable storage medium. When a processor of a computer device reads the computer instructions from the computer-readable storage medium, the processor executes the computer instructions, so that the computer device executes the steps of implementing the method provided in the first aspect.

[0018] The beneficial effects of the technical solution provided by the embodiment of the present application are:

[0019] The embodiment of the present application creates a first virtual table and a second virtual table for the indicator to be queried. The first virtual table defines the acquisition and processing logic of the data of the historical period (i.e., offline data), and the second virtual table defines the acquisition and processing logic of the data of the current period (i.e., real-time data). For the indicator inquirer, the inquirer only needs to use a set of query conditions. The inquirer does not need to understand the execution logic inside the first virtual table and the second virtual table. The inquirer only needs to use a set of drill-down indicators and the aggregation method of the drill-down indicators to simultaneously obtain the indicators generated based on the offline data of the historical time period and the real-time data of the current time period, which simplifies the query operation of the inquirer and effectively saves human resources.

[0020] In addition, the embodiments of the present application also reduce the difficulty of data research and development, and at least reduce the data research and development costs. It has broad application prospects and can be applied to various big data analysis scenarios to improve the efficiency of data processing and analysis and release the potential of data. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in describing the embodiments of the present application are briefly introduced below.

[0022] Figure 1 A flowchart of a method for querying an indicator provided in an embodiment of the present application;

[0023] Figure 2 A schematic diagram of the architecture of a method for querying an indicator provided in an embodiment of the present application;

[0024] Figure 3 A schematic diagram of the structure of an indicator query device provided in an embodiment of the present application;

[0025] Figure 4 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0026] The embodiments of the present application are described below in conjunction with the drawings in the present application. It should be understood that the implementation methods described below in conjunction with the drawings are exemplary descriptions for explaining the technical solutions of the embodiments of the present application and do not constitute a limitation on the technical solutions of the embodiments of the present application.

[0027] It will be understood by those skilled in the art that, unless specifically stated, the singular forms "one", "said", and "the" used herein may also include plural forms. It should be further understood that the terms "including" and "comprising" used in the embodiments of the present application refer to that the corresponding features can be implemented as the presented features, information, data, steps, operations, elements and / or components, but do not exclude the implementation of other features, information, data, steps, operations, elements, components and / or combinations thereof supported by the technical field. It should be understood that when we say that an element is "connected" or "coupled" to another element, the one element may be directly connected or coupled to the other element, or it may refer to that the one element and the other element establish a connection relationship through an intermediate element. In addition, the "connection" or "coupling" used herein may include wireless connection or wireless coupling. The term "and / or" used herein indicates at least one of the items defined by the term, for example, "A and / or B" may be implemented as "A", or as "B", or as "A and B".

[0028] In order to make the objectives, technical solutions and advantages of the present application more clear, the implementation methods of the present application will be further described in detail below with reference to the accompanying drawings.

[0029] First, several terms involved in this application are introduced and explained:

[0030] Physical table: A physical table is a table that actually stores data in a database. It specifically corresponds to the physical storage structure in the database system. A physical table contains actual data rows and columns, as well as corresponding physical properties such as storage format, index, partition, etc. In technology stacks such as databases / data warehouses and big data, physical tables are entities that persist and organize data. They are stored on disk and managed by the aforementioned systems for read and write operations. A physical table can consist of a table structure and data rows, and is used to store and operate actual business data.

[0031] Table structure (Schema): refers to the structure and properties of the table defined in the database, including column names, data types, constraints, etc. It describes the meaning and characteristics of each column in the table.

[0032] Fact table: A table in a data warehouse used to store business metrics. It contains factual data related to the business process, such as sales amount, quantity, time, etc. Fact tables are usually associated with dimension tables, and connected to fact tables through the primary key of the dimension table to provide a richer analysis perspective.

[0033] Dimension table: A table used to store dimensional data in a data warehouse. It contains detailed information related to the business, such as time, location, product, etc. Dimension tables usually contain a unique identifier (primary key) and descriptive attributes (such as name, description, level, etc.). The role of dimension tables is to provide context and association for fact tables.

[0034] Virtual table: A special table that separates the table structure (schema) and physical data (physical data). It is derived from one or more source tables. The logical table defines the data query method through Create Table As Select and has the characteristics of a physical table logically.

[0035] Stream-batch integration: It is a method to express the data computing mode. Data computing is divided into batch computing and stream computing. The two are usually calculated separately and the calculation results are used separately. The purpose of stream-batch integration is to make the data user unaware of the existence of the two parts of data and can access data in different time intervals at will.

[0036] Stream-batch integrated virtual table: a type of virtual table that logically aggregates offline data tables and real-time data tables. Stream-batch integrated virtual table ensures that the format (number of fields, order, type) of offline and real-time data tables is consistent, and then combines the data of the two virtual tables together through Select * from A union B to form a virtual table that can access data at any time point.

[0037] Materialized view: is a pre-calculated and stored query result set created in the data warehouse. It is a virtual table that can convert complex queries into a simplified table structure based on pre-defined query rules and aggregate functions to improve query performance and response time. Materialized views are often used in frequent query situations to reduce the computational overhead of queries.

[0038] In the traditional system, enterprise IT personnel are required to deploy two types of computing clusters, manually define indicators twice, write two sets of indicator calculation logic, and manually splice calculation results of different time ranges according to user conditions when querying. The entire computing development process is highly complex, with a lot of repetitive content, the number of indicators doubles, and the data accuracy is low. It is inefficient and redundant in the context of real-time data.

[0039] Specifically, the indicator processing logic is divided into the following steps:

[0040] Data source definition;

[0041] Offline data table definition;

[0042] Real-time data format definition;

[0043] Offline indicator logic definition;

[0044] Real-time indicator logic definition;

[0045] Indicator calculation job development;

[0046] Concatenate indicator query results.

[0047] The data source definition requires data developers to define offline data sources and real-time data sources respectively. The data table or data structure definition refers to the physical table of data corresponding to the data source. The real-time data source references the data schema of the topic and defines two sets of data models.

[0048] The logical definition of indicators requires defining two sets of indicator calibers for offline data tables and real-time data tables respectively. It is necessary to manually ensure that the data structures of offline data and real-time data are consistent, as well as that the indicator calibers are consistent.

[0049] Indicator calculation jobs (also called calculation tasks or tasks) are developed. Offline and real-time indicators develop calculation jobs separately. Several steps are required: job logic configuration (including dimensions and metrics), computing cluster allocation, and job launch.

[0050] The result splicing of indicator query is because the results of offline and real-time indicator calculations are written in different engines and storages respectively. When querying indicators, the two parts of the results need to be manually spliced ​​together. The query logic needs to be dynamically spliced ​​based on the time interval, dimension conditions, and aggregated metrics of the user's query.

[0051] Traditional data indicators are mainly based on offline indicators. Offline indicators generally count the data results of the previous day and display the indicators of T-1 (T represents the current day, T-1 represents the previous day). Data users can usually see data from 8 to 12 hours ago. With the development of business, data users have more and more requirements for the timeliness of indicators. They are no longer satisfied with only looking at the data content before T-1 days. They hope to be able to view the data indicators of the last few minutes or even seconds at any time. At the same time, they can choose the time range of the indicators themselves. Then, the calculation of indicators based on offline data and the calculation of indicators based on real-time data are two sets of logic. The queryer needs to manually splice the results of the two parts of the indicators. The query method is cumbersome, which increases the difficulty of development and the queryer's query difficulty.

[0052] The following describes several exemplary embodiments to illustrate the technical solutions of the embodiments of the present application and the technical effects produced by the technical solutions of the present application. It should be noted that the following embodiments can refer to, draw on or combine with each other, and the same terms, similar features and similar implementation steps in different embodiments will not be described repeatedly.

[0053] The present application provides a method for querying an indicator, such as Figure 1 As shown, the method includes:

[0054] Step S101, obtaining query conditions of the indicator to be queried, where the query conditions include a query time period, each drill-down indicator of the indicator to be queried, and a first aggregated metric of each drill-down indicator.

[0055] The indicator to be queried in the embodiment of the present application refers to the business indicator to be queried. Business indicators (hereinafter referred to as "indicators") are key quantitative indicators used to measure business operations and are very important data analysis assets. These business indicators are usually closely related to the organization's goals, strategic goals and key performance indicators (KPIs), and are used to evaluate the efficiency, quality, cost and other aspects of business operations.

[0056] There are different indicators in different business scenarios or business needs. For example, in the commodity sales scenario, the indicators may be sales revenue and sales volume.

[0057] The embodiment of the present application can obtain the query conditions of the indicator to be queried, and the query conditions of the indicator to be queried can be directly entered by the business personnel. The query conditions include the query time period, the drill-down indicator of the indicator to be queried, and the first aggregation measurement of the drill-down indicator. In addition, the query conditions can also be extracted from the query statement expressed in natural language input by the business personnel, and the embodiment of the present application does not limit this.

[0058] The query time period refers to a time period that the business personnel intend to query, which can be the current time period, the historical time period, or both. The current time period refers to the time period in the current cycle, that is, the current time period can be a time period in the current cycle. When the query time period is the current time period, the indicator to be queried can be called a "historical indicator"; the historical time period can be a time period in at least one historical cycle before the current cycle; when the query time period is a historical time period, the indicator to be queried can be called a "current indicator".

[0059] There is no limit on the duration of each cycle, which can be 1 day, 1 hour, 10 minutes, etc. It is worth noting that the current time period and the historical time period here may not be a complete cycle, and the current time period can be a part of the current cycle. Specifically, assuming that the duration of a cycle is 1 day, the current cycle can be any period from the start time of today to the current time, usually from the start time of the current cycle to the current time.

[0060] The historical time period may be a partial time period of a certain historical cycle, or may be a period of time composed of multiple historical cycles, which is not limited in the embodiments of the present application.

[0061] In business analytics, metric drill-down refers to the process of further breaking down and analyzing raw metrics to gain deeper understanding and insight. Metric drill-down can help identify potential problems, discover new opportunities, and guide decisions and actions.

[0062] Taking sales as an example, the sales indicator can be drilled down in any one or more of the following ways:

[0063] Drill down by region: Break down sales into sales by region to understand sales and trends in different regions;

[0064] Drill down by product: Break down sales into sales of various products or product categories to understand the sales performance of various products;

[0065] Drill down by customer: segment sales into sales to different customers or customer groups to understand the purchasing behavior and preferences of different customers;

[0066] Drill down by channel: Segment sales into sales of different sales channels (such as direct sales, agents, e-commerce, etc.) to understand the contribution and efficiency of different sales channels;

[0067] Drill down by time or time period to break down sales into sales at different times (annual, monthly, quarterly, etc.) to understand the relationship between sales and time or time period.

[0068] Of course, in actual business scenarios, indicators can also be drilled down based on other types, and the embodiments of the present application do not limit this.

[0069] The drill-down indicator of the indicator to be queried in the embodiment of the present application refers to the indicator obtained after drilling down on the indicator to be queried. The indicator to be queried belongs to the original indicator, and the drill-down indicator is the indicator obtained after drilling down on the indicator. The indicator to be queried can be drilled down in the way of one or several indicators required by the actual business scenario. The indicator to be queried can be drilled down at any granularity (for example, provincial, municipal, district, etc.) to obtain multiple drill-down indicators, and there is no limitation on this.

[0070] Each drill-down indicator can be calculated based on the same field in the data table.

[0071] The first aggregate metric of the drill-down indicator refers to a method of combining multiple drill-down indicators to produce a more comprehensive evaluation or understanding of the indicator to be queried. The first aggregate metric includes but is not limited to sum, weighted average, weighted sum, comprehensive index, etc. In actual business scenarios, any one or several first aggregate metrics can be selected according to the actual situation of the indicator to be queried.

[0072] Specifically, assuming that a certain indicator to be queried is "the total sales of product A in various provinces in the southwest region in spring", and assuming that there are three provinces A, B, and C in the southwest region, then the drill-down indicators can be the sales of product A in province A in spring, the sales of product A in province B in spring, and the sales of product A in province C in spring. The first aggregation measure of each drill-down indicator can be determined based on the "total sales", which is "sum".

[0073] In addition, the query conditions may also include other information, such as filter conditions. The filter conditions may be used to filter drill-down indicators that do not meet the preset conditions, and there is no restriction on other information in the query conditions.

[0074] Step S102: If it is determined that the query time period includes both the current time period and the historical time period, the current time period is a time period in the current cycle, and the historical time period is a time period in at least one historical cycle, then a first virtual table and a second virtual table pre-created for the indicator to be queried are obtained.

[0075] The data source of the first virtual table is the preset database, and the first virtual table indicates that offline data of the historical period is obtained from the preset database. The first virtual table is also called an "offline virtual table". The data source of the second virtual table is the real-time computing engine. The second virtual table indicates that real-time data of the current period is obtained from the real-time computing engine. The second virtual table is also called a "real-time virtual table". The first virtual table and the second virtual table have the same table structure (the fields contained in the first virtual table and the second virtual table are the same).

[0076] In the embodiment of the present application, the first virtual table and the second virtual table are both virtual tables, not physical tables. Multiple fields in the first virtual table and the second virtual table are the same fields, so that the inquirer can query the first virtual table and the second virtual table at the same time. Multiple fields in the first virtual table correspond to fields in the physical table in the preset database, and multiple fields in the second virtual table correspond to fields in the message queue in the real-time computing engine. The first virtual table and the second virtual table can provide a "stream-batch integrated virtual table" to the outside world.

[0077] After obtaining the query time period of the indicator to be queried, the embodiment of the present application needs to determine the type of time to be queried, which specifically includes the following three types: current time period, historical time period, and current time period + historical time period. Among them, the current time period is a time period in the current cycle, and the historical time period is a time period in at least one historical cycle. When calculating the indicator value of the business indicator in the historical time period, the data written in the preset database is used. The data in the preset database is the "offline data". When calculating the indicator value of the business indicator in the current time period, the data in the real-time calculation engine is used. The data in the real-time calculation engine is the "real-time data". The data in the real-time calculation engine has not yet been written into the preset database.

[0078] The preset database may be a database for storing business data, may be a stand-alone database, or may be a distributed database, which is not limited in the embodiments of the present application.

[0079] If it is determined that the query time period includes both the current time period and the historical time period, the query time period will be split into two time periods, namely the current time period and the historical time period, and the first virtual table and the second virtual table created in advance for the indicator to be queried will be obtained.

[0080] In fact, the first virtual table and the second virtual table have the same table structure. Specifically, multiple fields in the first virtual table and multiple fields in the second virtual table are the same fields. When configuring the first virtual table and the second virtual table, the system will automatically verify whether the structures of the two tables are consistent, including the number of table fields, field types, and field order. After ensuring that the data structures of the two data sources are consistent (or compatible), the system can save the two virtual tables as a batch-stream virtual table.

[0081] The calculation of the indicator value of the drill-down indicator requires the use of some fields in the data table and the calculation method between these fields. The calculation method between the various fields can be defined according to the actual business scenario and there is no restriction on this.

[0082] Step S103, obtaining the first indicator value corresponding to each drill-down indicator in the historical time period according to the data in the first virtual table and the preset database; obtaining the second indicator value corresponding to each drill-down indicator in the current time period according to the data in the second virtual table and the real-time calculation engine.

[0083] In the embodiment of the present application, the first virtual table and the second virtual table provide a table structure. The first virtual table and the second virtual table do not actually store data. The preset database can be accessed according to the first virtual table to obtain offline data in the preset database. The real-time computing engine can be accessed according to the second virtual table to obtain real-time data in the real-time computing engine.

[0084] The offline data in the preset database is the field values ​​corresponding to each field in the first virtual table. The first virtual table also includes a first calculation method between each field (related to actual needs, such as summation, multiplication, etc.). The field value of each field in the first virtual table can be calculated according to the first calculation method to obtain the first indicator value corresponding to each drill-down indicator in the historical time period.

[0085] The second virtual table also includes a second calculation method between each field. The first calculation formula and the second calculation formula may be the same or different (different data formats may result in different two calculation formulas). The first calculation method and the second calculation method are both set according to actual business scenarios. The field value of each field in the second virtual table can be calculated according to the second calculation method to obtain the second indicator value corresponding to each drill-down indicator in the current time period.

[0086] Step S104 , performing aggregation processing on the first indicator value and the second indicator value of each drill-down indicator according to the first aggregation metric of each drill-down indicator, and taking the aggregated indicator value as the indicator value of the indicator to be queried.

[0087] After obtaining the first indicator value corresponding to each drill-down indicator in the historical time period and the second indicator value corresponding to each drill-down indicator in the current time period, the embodiment of the present application can aggregate the first indicator value and the second indicator value of each drill-down indicator according to the first aggregation metric of each drill-down indicator (sum, average, variance, etc., which can be determined according to actual conditions) to obtain an aggregated indicator value, which is the indicator value of the indicator to be queried.

[0088] The embodiment of the present application creates a first virtual table and a second virtual table for the indicator to be queried. The first virtual table defines the acquisition and processing logic of the data of the historical period (i.e., offline data), and the second virtual table defines the acquisition and processing logic of the data of the current period (i.e., real-time data). For the indicator inquirer, the inquirer only needs to use a set of query conditions. The inquirer does not need to understand the execution logic inside the first virtual table and the second virtual table. The inquirer only needs to use a set of drill-down indicators and the aggregation method of the drill-down indicators to simultaneously obtain the indicators generated based on the data of the historical period and the real-time data of the current period, which simplifies the query operation of the inquirer and effectively saves human resources.

[0089] In addition, the embodiments of the present application also reduce the difficulty of data research and development, and at least reduce the data research and development costs. It has broad application prospects and can be applied to various big data analysis scenarios to improve the efficiency of data processing and analysis and release the potential of data.

[0090] In addition, if the query time period of the indicator to be queried corresponds to a historical time period, a first virtual table is obtained, and the first indicator value corresponding to each drill-down indicator in the historical time period is directly obtained from the preset database according to the first virtual table, and the first indicator value is used as the indicator value of the indicator to be queried.

[0091] If the query time period of the indicator to be queried corresponds to a current time period, a second virtual table is obtained, and the second indicator value corresponding to each drill-down indicator in the current time period is directly obtained from the real-time computing engine according to the second virtual table, and the second indicator value is used as the indicator value of the indicator to be queried.

[0092] Since multiple fields of the first virtual table and the second virtual table are the same fields (the subsequent time column fields may indicate that data of different time periods are obtained, but they may all represent time column fields and may also be regarded as the same fields), this indicates that the two have the same table structure, so that no matter whether the query time period is the current time period, the historical time period, or both the current time period and the historical time period, a set of query logic is queried to the inquirer, which simplifies the query operation of the inquirer and effectively saves human resources.

[0093] The embodiment of the present application provides a possible implementation method, wherein the first virtual table includes multiple fields and a first calculation method between the multiple fields;

[0094] According to the data in the first virtual table and the preset database, the first indicator value corresponding to each drill-down indicator in the historical time period is obtained, including:

[0095] Query the preset view. If it is determined that at least one pre-calculation method included in the preset view contains various target pre-calculation methods, and the various target pre-calculation methods are integrated to obtain the first calculation method, then obtain the target pre-calculation results obtained in the historical time period based on the various target pre-calculation methods from the preset view; when a new current period is generated, for each pre-calculation method, the preset offline calculation engine obtains the field values ​​of each field involved in the pre-calculation method in the previous historical period of the new current period from the preset database, performs pre-calculation processing on the field values ​​of the previous historical period through the pre-calculation method, obtains the pre-calculation results, and stores the pre-calculation results in the preset view;

[0096] The target pre-calculation results of each target pre-calculation method in the historical time period are integrated and processed to obtain the first indicator value corresponding to the drill-down indicator in the historical time period.

[0097] In the embodiment of the present application, each field in the first virtual table corresponds to the first calculation method. For example, the first calculation method is A*B+C*D, where A, B, C, and D are different fields. Since the first calculation method involves offline data in the calculation, the first calculation method is also called an "offline calculation job". The "offline calculation job" can be executed by an offline calculation engine, which can be a calculation engine such as Hive or Spark. In addition, the first virtual table can also include the access path, connection relationship, filter conditions, and field sorting of the physical table.

[0098] The embodiment of the present application also includes a preset view. The real-time computing engine can periodically write data to the preset database. Specifically, when a new current cycle is generated, the real-time computing engine can write the data of the previous historical cycle of the new current cycle to the preset database. If the preset database partitions data in cycles, each partition corresponds to the data of one cycle. When a new partition is generated, the data in the new partition is the data of the previous historical cycle.

[0099] In addition, since the data based on each historical period is certain, in order to facilitate subsequent calculations, the data of the historical period can be preprocessed. Specifically, multiple pre-calculation methods can be pre-set. Compared with the first calculation method, the pre-calculation method can be a simple calculation, such as finding the sum or product of multiple fields. The pre-calculation method is set by itself. Continuing with the above example, A*B can be a pre-calculation method. For each pre-calculation method, the preset offline calculation engine obtains the field values ​​of each field involved in the pre-calculation method in the previous historical period of the new current period from the preset database, and pre-calculates the field values ​​of the previous historical period through the pre-calculation method to obtain the pre-calculation result. The pre-calculation result and the generation time of the data corresponding to the pre-calculation result are stored in the preset view, which is convenient for subsequent calculations and can improve the efficiency of subsequent calculations.

[0100] When obtaining the first indicator value corresponding to each drill-down indicator in the historical time period based on the data in the first virtual table and the preset database, the preset view can be queried. If it is determined that there is a target pre-calculation method in at least one pre-calculation method included in the preset view, the target pre-calculation methods are integrated to obtain the first calculation method. The integration processing here can be mathematical splicing of each target calculation method (such as addition, subtraction, multiplication, division, etc.). The first calculation method can be obtained after formula conversion of each target calculation method. Then, the target pre-calculation result obtained based on each target pre-calculation method in the historical time period is obtained from the preset view. Specifically, the target historical period corresponding to the historical time period can be determined first, and the pre-target pre-calculation results of each target pre-calculation method in each target historical period are obtained. Each target pre-calculation result is integrated to obtain the first indicator value corresponding to the drill-down indicator in the historical time period.

[0101] This embodiment of the present application provides a possible implementation method, which queries a preset view, and then further includes:

[0102] If it is determined that each target pre-calculation result does not exist in at least one pre-calculation result included in the preset view, a SQL (Structured Query Language) statement set is generated according to the multiple fields included in the first virtual table, the first calculation method, and the historical time period;

[0103] Execute the SQL statement set on the preset database to obtain the first indicator value corresponding to the drill-down indicator in the historical time period.

[0104] In an embodiment of the present application, after determining that each target pre-calculation result does not exist in at least one pre-calculation result included in a preset view, or that all target pre-calculation results do not exist, a SQL statement set can be generated according to multiple fields included in the first virtual table, the first calculation method, and the historical time period.

[0105] The present application provides a possible implementation method for generating a SQL statement set, including:

[0106] Parsing the first virtual table to obtain a table identifier of at least one target physical table corresponding to each field in the first virtual table, a type of at least one target physical table, and a connection relationship between at least one target physical table;

[0107] A SQL statement set is obtained based on a table identifier of at least one target physical table, a type of at least one target physical table, a connection relationship between at least one target physical table, a first calculation method between multiple fields, and a historical time period.

[0108] The first virtual table can be expanded layer by layer in a traversal manner, and finally expanded to the target physical table of each atom. The target physical table contains the fields required for calculating the drill-down indicators. The DataModel object is used to describe the data during the expansion process. The data is described through the node Vertex (vertex representation table, which can be a virtual table or a physical table), node attributes (node ​​attributes include the type of data table, and the type of data table is any one of the fact table and dimension table) and edge Edge (edge ​​representation The connection relationship between tables, including the connection relationship between virtual tables and virtual tables, the connection relationship between virtual tables and physical tables, the connection relationship between physical tables and physical tables, and the connection relationship between physical tables) is used for data description. Finally, the table identifier and type of each target physical table, the association relationship between each target physical table, and the fields required in the physical table need to be determined.

[0109] The table identifier can uniquely identify the physical table, and the table identifier can be a table name.

[0110] The type of physical table can be either fact table or dimension table.

[0111] The connection relationship between physical tables can be an association method between two or more tables. This connection relationship allows joint queries to be performed between multiple tables to obtain richer and more complex data.

[0112] The main connection relationships (join relationship types) are as follows:

[0113] Inner Join: Inner Join is one of the most common join types and it returns only the rows that satisfy the join condition. This means that results are returned only when there is a match in the values ​​of the join columns in both tables.

[0114] Outer Join: An outer join allows all rows from one table to be returned, even if there are no matching rows in the other table. Outer joins are divided into three types: Left Outer Join, Right Outer Join, and Full Outer Join, depending on which table's rows are included in the result.

[0115] Self Join: A self join is a table joined with itself and is usually used when you need to compare data between different rows in a table.

[0116] Cross Join: A cross join returns the Cartesian product of two tables, that is, all possible combinations of the two tables. This join does not require any join conditions, so it returns every row in the first table combined with every row in the second table.

[0117] Natural Join: A natural join is an automatic connection based on the similarity of the column names between two tables. It automatically matches columns with the same name and returns matching rows.

[0118] Of course, other connection modes may also be included, which are not limited thereto, and the connection relationship to be selected is determined according to the actual scenario.

[0119] A set of SQL statements for querying drill-down indicators can be generated based on the table identifier of at least one target physical table, the type of at least one target physical table, the connection relationship between at least one target physical table, and the first calculation method between multiple fields. The table identifier of the above-mentioned target physical table, the type of at least one target physical table, the connection relationship between at least one target physical table, and the first calculation method between multiple fields can be substituted into a preset SQL statement generation tool to obtain the SQL statement set. By executing the SQL statement set, the indicator value of the drill-down indicator in the historical time period can be obtained.

[0120] The embodiment of the present application provides a possible implementation method, wherein the second virtual table includes multiple fields and a second calculation method between the multiple fields; the real-time calculation engine includes at least one message queue; each message queue corresponds to each field;

[0121] According to the data in the second virtual table and the real-time computing engine, the second indicator value corresponding to each drill-down indicator in the current time period is obtained, including:

[0122] Obtaining a queue identifier of at least one target message queue corresponding to each field in the second virtual table; generating a calculation operator for obtaining a drill-down indicator from a real-time calculation engine based on the queue identifier of the target message queue and the second calculation method;

[0123] Obtain a preset consumption strategy; the consumption strategy is any one of starting consumption from the earliest data saved in the corresponding message queue, starting consumption from the latest data saved in the message queue, and starting consumption from the data saved in the corresponding message queue at a preset time;

[0124] According to the calculation operator, the current time period and the preset consumption strategy, the second indicator value corresponding to each drill-down indicator in the current time period is obtained.

[0125] The second calculation method in the second virtual table of the embodiment of the present application is a job for processing real-time data in the real-time computing engine. Therefore, the second calculation job is also called a "real-time computing job". The real-time computing engine can use engines such as Flink. The second virtual table includes multiple fields, each field has a corresponding message queue (topic), and each topic in the real-time computing engine can store field values ​​of one or more fields. The field name of the corresponding field of the message queue can be used as the identifier of the message queue. The queue identifier of each target message queue that needs to be accessed can be determined according to the multiple fields in the second virtual table. Based on the queue identifier of the target message queue and the second calculation method between the multiple fields, a calculation operator for obtaining drill-down indicators from the real-time computing engine is generated. The calculation operator can be generated using a preset tool (such as Power BI). The second indicator value corresponding to each drill-down indicator in the current time period can be obtained according to the calculation operator, the current time period and the preset consumption strategy.

[0126] Specifically, the preset consumption strategy can be any one of starting consumption from the earliest data saved in the corresponding message queue, starting consumption from the latest data saved in the message queue, and starting consumption from the data at a preset time saved in the corresponding message queue. Based on the consumption strategy, the data of the current time period can be obtained from the message queue in the computing engine, and the data of the current time period can be calculated according to the computing operator to obtain the second indicator value corresponding to each drill-down indicator in the current time period.

[0127] In fact, in order to ensure the real-time performance of the second indicator value, the second indicator value may be configured to be updated in real time, where real time may be every 1 second, 3 seconds, 5 seconds, and so on.

[0128] The embodiment of the present application provides a possible implementation method, which obtains a first virtual table pre-created for the index to be queried, and also includes:

[0129] Configure the first virtual table in the following way:

[0130] Configure the data source and definition information of the first virtual table, where the definition information of the first virtual table includes the table identifier of the first virtual table, the field name and field type of each field in the first virtual table;

[0131] A first calculation method between fields in the first virtual table is configured.

[0132] The data source of the first virtual table is the preset database, which is an offline data source. When configuring the data source, you can configure the data source to inject the Server IP address, user name, password, access protocol, and other content.

[0133] Configuring the definition information of the first virtual table includes editing the table name of the first virtual table, the field names and field types of each field required for calculating the drill-down index. The multiple fields may include the first time column field; the generation time of the first time column field data. The generation time of each data record in the first virtual table belongs to the historical period. Processing the data in the historical period belongs to batch processing, which indicates that the first virtual table is a batch processing table (Batch).

[0134] In addition, you also need to configure the indicator logic definition. Configuring the indicator logic definition means configuring the first calculation method between the fields in the first virtual table. The first calculation method indicates the field name and calculation function that need to be calculated, usually including any one or more of sum, count, avg, count-distinct, etc., without restriction.

[0135] The embodiment of the present application provides a possible implementation method, which obtains a second virtual table pre-created for the index to be queried, and also includes:

[0136] Configure the second virtual table in the following way:

[0137] Configure the data source, definition information and consumption strategy of the data in the data source of the second virtual table; the definition information of the second virtual table includes the table identifier of the second virtual table, the field name and field type of each field in the second virtual table;

[0138] Configure a second calculation method between the fields in the first virtual table.

[0139] Just like configuring the first virtual table, configuring the second virtual table also requires configuring a data source. The data source of the second virtual table is the real-time computing engine. Specifically, it is the queue identifier (the queue identifier can be the queue name) of the message queue where the corresponding field in the real-time computing engine is located.

[0140] In addition, since real-time data will be stored in message queues (kafka, rabbitmq, etc.), the data will not be saved all the time like in a database. Therefore, you can choose a consumption strategy when using data, including: Oldest: start consuming from the earliest data saved in the corresponding message queue; Newest: start consuming from the latest data saved in the message queue; Fixed preset time: start consuming from the data saved at the preset time in the corresponding message queue.

[0141] In addition, you also need to configure the minimum time granularity for updating real-time indicators. The minimum time granularity is a smaller time range, which is intended to present "real-time performance". For example, in the current cycle, the minimum time granularity can be 1s, 5s, and 10s. Here you can set the sliding window function and set parameters such as the sliding length and step size. This indicates that the second virtual table is a real-time table (Stream).

[0142] In fact, after configuring the first virtual table and the second virtual table, the system will automatically verify whether the structures of the two tables are consistent. The verification content includes whether the number of table fields, field types, and field order are consistent. After ensuring that the data structures of the two data sources are consistent (or compatible), the system can save the two virtual tables as a stream-batch integrated virtual table.

[0143] like Figure 2 As shown, it exemplarily shows an architectural diagram of a method for querying an indicator provided in an embodiment of the present application, including an XEngine configuration module, an XEngine computing module, a query module, a real-time data source, and an offline data source, wherein the offline data source refers to a preset database, and the real-time data source refers to a real-time computing engine.

[0144] The XEngine configuration module needs to configure offline virtual tables and real-time virtual tables. The offline virtual table is the first virtual table mentioned above, and the real-time virtual table is the second virtual table mentioned above. The data source of the offline virtual table is configured as the offline data source, and the data source of the real-time virtual table is configured as the real-time data source. The offline virtual table and the real-time virtual table provide the queryer with a streaming-batch integrated virtual table, so that the queryer can query the real-time index, query the offline index, or query the index values ​​of the real-time index and the offline index at the same time based on the streaming-batch integrated virtual table.

[0145] The XEngine calculation module can expand the first virtual table to obtain offline calculation jobs for each field in the first virtual table. The offline calculation job is the aforementioned first calculation method. The second virtual table can be expanded to obtain real-time calculation jobs between each field in the second virtual table. The real-time calculation job is the aforementioned second calculation method.

[0146] The query module may obtain query conditions for the indicator to be queried, where the query conditions include a query time period, each drill-down indicator of the indicator to be queried, and a first aggregated metric of each drill-down indicator.

[0147] If the query module determines that the query time period includes both the current time period and the historical time period, the current time period is a time period in the current cycle, and the historical time period is a time period in at least one historical cycle, then a first virtual table and a second virtual table pre-created for the indicator to be queried are obtained.

[0148] The query module can access the stream computing engine and the offline computing engine in the XEngine computing module. The offline computing engine is connected to the offline data source. The offline computing engine can obtain the first indicator value corresponding to each drill-down indicator in the historical time period according to the first virtual table and the data in the preset database.

[0149] The stream computing engine is connected to the real-time data source. The stream computing engine can obtain the second indicator value corresponding to each drill-down indicator in the current time period according to the data in the second virtual table and the real-time computing engine.

[0150] The present application embodiment provides a device for querying an indicator, such as Figure 3 As shown, the index query device 30 may include:

[0151] A first acquisition module 310 is used to acquire a query condition of the indicator to be queried, where the query condition includes a query time period, each drill-down indicator of the indicator to be queried, and a first aggregated metric of each drill-down indicator;

[0152] The processing module 320 is used to obtain a first virtual table and a second virtual table pre-created for the indicator to be queried if it is determined that the query time period includes both the current time period and the historical time period, the current time period is a time period in the current cycle, and the historical time period is a time period in at least one historical cycle; the data source of the first virtual table is a preset database, and the data source of the second virtual table is a real-time computing engine; the first virtual table and the second virtual table have the same table structure;

[0153] The second acquisition module 330 is used to obtain the first indicator value corresponding to each drill-down indicator in the historical time period according to the data in the first virtual table and the preset database; and obtain the second indicator value corresponding to each drill-down indicator in the current time period according to the data in the second virtual table and the real-time calculation engine;

[0154] The aggregation module 340 is used to aggregate the first indicator value and the second indicator value of each drill-down indicator according to the first aggregation metric of each drill-down indicator, and use the aggregated indicator value as the indicator value of the indicator to be queried.

[0155] A possible implementation method is provided in an embodiment of the present application, wherein the first virtual table includes multiple fields and a first calculation method between the multiple fields;

[0156] The second acquisition module includes:

[0157] A query submodule is used to query a preset view. If it is determined that at least one pre-calculation method included in the preset view contains a target pre-calculation method, and each target pre-calculation method is integrated to obtain a first calculation method, then the target pre-calculation result obtained in the historical time period based on each target pre-calculation method is obtained from the preset view; when a new current period is generated, for each pre-calculation method, the preset offline calculation engine obtains the field value of each field involved in the pre-calculation method in the previous historical period of the new current period from the preset database, performs pre-calculation processing on the field value of the previous historical period through the pre-calculation method, obtains the pre-calculation result, and stores the pre-calculation result in the preset view;

[0158] The integration submodule is used to integrate the target pre-calculation results of each target pre-calculation method in the target historical time period to obtain the first indicator value corresponding to the drill-down indicator in the historical time period.

[0159] A possible implementation method is provided in an embodiment of the present application, where the second acquisition module further includes:

[0160] A SQL statement set generation submodule, configured to generate an SQL statement set according to a plurality of fields included in the first virtual table, a first calculation method, and a historical time period if it is determined that the target pre-calculation result does not exist in at least one pre-calculation result included in the preset view;

[0161] The first indicator value obtaining submodule is used to execute a set of SQL statements on a preset database to obtain a first indicator value corresponding to the drill-down indicator in a historical time period.

[0162] A possible implementation method is provided in an embodiment of the present application, and the SQL statement set generation submodule is specifically used to parse the first virtual table, obtain the table identifier of at least one target physical table corresponding to each field in the first virtual table, the type of at least one target physical table, and the connection relationship between at least one target physical table; based on the table identifier of at least one target physical table, the type of at least one target physical table, the connection relationship between at least one target physical table, the first calculation method between multiple fields, and the historical time period, obtain the SQL statement set.

[0163] A possible implementation method is provided in an embodiment of the present application, wherein the second virtual table includes multiple fields and a second calculation method between the multiple fields; the real-time calculation engine includes at least one message queue; each message queue corresponds to each field;

[0164] The second acquisition module includes:

[0165] A queue identification acquisition submodule, used to acquire the queue identification of at least one target message queue corresponding to each field in the second virtual table; based on the queue identification of the target message queue and the second calculation method, generate a calculation operator for acquiring a drill-down indicator from the real-time calculation engine;

[0166] The consumption strategy acquisition submodule is used to acquire a preset consumption strategy; the consumption strategy is any one of starting consumption from the earliest data saved in the corresponding message queue, starting consumption from the latest data saved in the message queue, and starting consumption from the data saved in the corresponding message queue at a preset time;

[0167] The second indicator value acquisition submodule is used to obtain the second indicator value corresponding to each drill-down indicator in the current time period according to the calculation operator, the current time period and the preset consumption strategy.

[0168] A possible implementation method is provided in an embodiment of the present application. The device also includes a first configuration module, which is used to configure the first virtual table in the following manner: configure the data source and definition information of the first virtual table, the definition information of the first virtual table includes the table identifier of the first virtual table, the field name and field type of each field in the first virtual table; configure the first calculation method between each field in the first virtual table.

[0169] A possible implementation method is provided in an embodiment of the present application. The device also includes a second configuration module, which is used to configure the second virtual table in the following manner: configure the data source, definition information and consumption strategy of the data in the data source of the second virtual table; the definition information of the second virtual table includes the table identifier of the second virtual table, the field name and field type of each field in the second virtual table; configure the second calculation method between each field in the first virtual table.

[0170] The device of the embodiments of the present application can execute the method provided by the embodiments of the present application, and the implementation principles are similar. The actions performed by each module in the device of each embodiment of the present application correspond to the steps in the method of each embodiment of the present application. For the detailed functional description of each module of the device, please refer to the description in the corresponding method shown in the previous text, which will not be repeated here.

[0171] In the embodiments of the present application, the term "module" or "unit" refers to a computer program or a part of a computer program that has a predetermined function and works together with other related parts to achieve a predetermined goal, and can be implemented in whole or in part by using software, hardware (such as processing circuits or memories), or a combination thereof. Similarly, a processor (or multiple processors or memories) can be used to implement one or more modules or units. In addition, each module or unit can be part of an overall module or unit that includes the function of the module or unit.

[0172] An embodiment of the present application provides an electronic device, including a memory, a processor, and a computer program stored in the memory, and the processor executes the above-mentioned computer program to implement the steps of the indicator query method.

[0173] In an alternative embodiment, an electronic device is provided, such as Figure 4 As shown, Figure 4 The electronic device 4000 shown includes: a processor 4001 and a memory 4003. The processor 4001 and the memory 4003 are connected, such as through a bus 4002. Optionally, the electronic device 4000 may also include a transceiver 4004, which may be used for data interaction between the electronic device and other electronic devices, such as data transmission and / or data reception. It should be noted that in actual applications, the transceiver 4004 is not limited to one, and the structure of the electronic device 4000 does not constitute a limitation on the embodiments of the present application.

[0174] Processor 4001 may be a CPU (Central Processing Unit), a general-purpose processor, a DSP (Digital Signal Processor), an ASIC (Application Specific Integrated Circuit), an FPGA (Field Programmable Gate Array) or other programmable logic devices, transistor logic devices, hardware components or any combination thereof. It may implement or execute various exemplary logic blocks, modules and circuits described in conjunction with the disclosure of this application. Processor 4001 may also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of a DSP and a microprocessor, etc.

[0175] The bus 4002 may include a path to transmit information between the above components. The bus 4002 may be a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus. The bus 4002 may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 4 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.

[0176] The memory 4003 may be a ROM (Read Only Memory) or other types of static storage devices that can store static information and instructions, a RAM (Random Access Memory) or other types of dynamic storage devices that can store information and instructions, or an EEPROM (Electrically Erasable Programmable Read Only Memory), a CD-ROM (Compact Disc Read Only Memory) or other optical disk storage, optical disk storage (including compressed optical disk, laser disk, optical disk, digital versatile disk, Blu-ray disk, etc.), magnetic disk storage media, other magnetic storage devices, or any other medium that can be used to carry or store computer programs and can be read by a computer, without limitation herein.

[0177] The memory 4003 is used to store the computer program for executing the embodiment of the present application, and the execution is controlled by the processor 4001. The processor 4001 is used to execute the computer program stored in the memory 4003 to implement the steps shown in the above method embodiment.

[0178] Among them, the electronic equipment package may include but is not limited to mobile terminals such as mobile phones, laptops, 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 4 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.

[0179] An embodiment of the present application provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps and corresponding contents of the aforementioned method embodiment can be implemented.

[0180] It should be noted that the computer-readable medium mentioned above in the present disclosure may be a computer-readable signal medium or a computer-readable 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 present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present disclosure, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. 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. Computer readable signal media may also be any computer readable medium other than computer readable storage media, 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 appropriate medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.

[0181] The embodiments of the present application also provide a computer program product, including a computer program, which can implement the steps and corresponding contents of the aforementioned method embodiments when executed by a processor. The terms "first", "second", "third", "fourth", "1", "2", etc. (if any) in the specification and claims of this application and the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate so that the embodiments of the present application described herein can be implemented in an order other than the diagram or text description.

[0182] It should be understood that, although each operation step is indicated by arrows in the flowchart of the embodiment of the present application, the implementation order of these steps is not limited to the order indicated by the arrows. Unless clearly stated herein, in some implementation scenarios of the embodiment of the present application, the implementation steps in each flowchart can be performed in other orders according to demand. In addition, some or all of the steps in each flowchart may include multiple sub-steps or multiple stages based on actual implementation scenarios. Some or all of these sub-steps or stages may be executed at the same time, and each sub-step or stage in these sub-steps or stages may also be executed at different times respectively. In different scenarios of execution time, the execution order of these sub-steps or stages may be flexibly configured according to demand, and the embodiment of the present application does not limit this.

[0183] The above are only optional implementation methods for some implementation scenarios of the present application. It should be pointed out that for ordinary technicians in this technical field, without departing from the technical concept of the scheme of the present application, other similar implementation methods based on the technical ideas of the present application are also within the protection scope of the embodiments of the present application.

Claims

1. A method for querying an indicator, characterized in that: include: Acquire query conditions for the indicator to be queried, where the query conditions include a query time period, each drill-down indicator of the indicator to be queried, and a first aggregated metric of each drill-down indicator; If it is determined that the query time period includes both the current time period and the historical time period, the current time period is a time period in a current cycle, and the historical time period is a time period in at least one historical cycle, then a first virtual table and a second virtual table pre-created for the indicator to be queried are obtained; the data source of the first virtual table is a preset database, and the data source of the second virtual table is a real-time computing engine; the first virtual table and the second virtual table have the same table structure; According to the first virtual table and the data in the preset database, obtain the first indicator value corresponding to each drill-down indicator in the historical time period; according to the second virtual table and the data in the real-time calculation engine, obtain the second indicator value corresponding to each drill-down indicator in the current time period; According to the first aggregation metric of each drill-down indicator, the first indicator value and the second indicator value of each drill-down indicator are aggregated, and the aggregated indicator value is used as the indicator value of the indicator to be queried; Wherein, the first virtual table includes a plurality of fields and a first calculation method between the plurality of fields; The obtaining, according to the first virtual table and the data in the preset database, a first indicator value corresponding to each drill-down indicator in the historical time period includes: Query the preset view, if it is determined that at least one pre-calculation method included in the preset view has various target pre-calculation methods, and the various target pre-calculation methods are integrated to obtain the first calculation method, then obtain the target pre-calculation results obtained in the historical time period based on the various target pre-calculation methods from the preset view; when a new current period is generated, for each pre-calculation method, the preset offline calculation engine obtains the field values ​​of various fields involved in the pre-calculation method in the previous historical period of the new current period from the preset database, performs pre-calculation processing on the field values ​​of the previous historical period through the pre-calculation method, obtains the pre-calculation results, and stores the pre-calculation results in the preset view; The target pre-calculation results of each target pre-calculation method in the historical time period are integrated to obtain a first indicator value corresponding to the drill-down indicator in the historical time period.

2. The method according to claim 1, characterized in that The query preset view further includes: If it is determined that each target pre-calculation result does not exist in at least one pre-calculation result included in the preset view, generating an SQL statement set according to the multiple fields included in the first virtual table, the first calculation method, and the historical time period; The SQL statement set is executed on the preset database to obtain a first indicator value corresponding to the drill-down indicator in the historical time period.

3. The method according to claim 2, characterized in that The generating of the SQL statement set includes: Parsing the first virtual table to obtain a table identifier of at least one target physical table corresponding to each field in the first virtual table, a type of at least one target physical table, and a connection relationship between at least one target physical table; The SQL statement set is obtained based on the table identifier of the at least one target physical table, the type of the at least one target physical table, the connection relationship between the at least one target physical table, the first calculation method between the multiple fields, and the historical time period.

4. The method according to claim 1, characterized in that The second virtual table includes a plurality of fields and a second calculation method between the plurality of fields; the real-time calculation engine includes at least one message queue; each message queue corresponds to each field; The obtaining, according to the data in the second virtual table and the real-time computing engine, a second indicator value corresponding to each drill-down indicator in the current time period includes: Obtaining a queue identifier of at least one target message queue corresponding to each field in the second virtual table; generating a calculation operator for obtaining the drill-down indicator from the real-time calculation engine based on the queue identifier of the target message queue and the second calculation method; Obtain a preset consumption strategy; the consumption strategy is any one of starting consumption from the earliest data saved in the corresponding message queue, starting consumption from the latest data saved in the message queue, and starting consumption from the data saved in the corresponding message queue at a preset time; According to the calculation operator, the current time period and the preset consumption strategy, a second indicator value corresponding to each drill-down indicator in the current time period is obtained.

5. The method according to claim 1, characterized in that: The step of obtaining a first virtual table pre-created for the index to be queried further comprises: The first virtual table is configured in the following way: Configure a data source and definition information of a first virtual table, where the definition information of the first virtual table includes a table identifier of the first virtual table, a field name and a field type of each field in the first virtual table; A first calculation method between the fields in the first virtual table is configured.

6. The method according to claim 1, characterized in that A second virtual table pre-created for the index to be queried is obtained, wherein: The second virtual table is configured in the following way: Configure the data source, definition information and consumption strategy of the data in the data source of the second virtual table; the definition information of the second virtual table includes the table identifier of the second virtual table, the field name and field type of each field in the second virtual table; A second calculation method between the fields in the first virtual table is configured.

7. A device for querying an index, characterized in that: include: A first acquisition module, configured to acquire a query condition of the indicator to be queried, wherein the query condition includes a query time period, each drill-down indicator of the indicator to be queried, and a first aggregated metric of each drill-down indicator; a processing module, configured to obtain a first virtual table and a second virtual table pre-created for the indicator to be queried if it is determined that the query time period includes both a current time period and a historical time period, the current time period being a time period in a current cycle, and the historical time period being a time period in at least one historical cycle; the data source of the first virtual table is a preset database, and the data source of the second virtual table is a real-time computing engine; the first virtual table and the second virtual table have the same table structure; A second acquisition module is used to obtain the first indicator value corresponding to each drill-down indicator in the historical time period according to the first virtual table and the data in the preset database; and obtain the second indicator value corresponding to each drill-down indicator in the current time period according to the second virtual table and the data in the real-time calculation engine; an aggregation module, configured to aggregate the first indicator value and the second indicator value of each drill-down indicator according to the first aggregation metric of each drill-down indicator, and use the aggregated indicator value as the indicator value of the indicator to be queried; Wherein, the first virtual table includes a plurality of fields and a first calculation method between the plurality of fields; The second acquisition module is specifically used for: Query the preset view, if it is determined that at least one pre-calculation method included in the preset view has various target pre-calculation methods, and the various target pre-calculation methods are integrated to obtain the first calculation method, then obtain the target pre-calculation results obtained in the historical time period based on the various target pre-calculation methods from the preset view; when a new current period is generated, for each pre-calculation method, the preset offline calculation engine obtains the field values ​​of various fields involved in the pre-calculation method in the previous historical period of the new current period from the preset database, performs pre-calculation processing on the field values ​​of the previous historical period through the pre-calculation method, obtains the pre-calculation results, and stores the pre-calculation results in the preset view; The target pre-calculation results of each target pre-calculation method in the historical time period are integrated to obtain a first indicator value corresponding to the drill-down indicator in the historical time period.

8. An electronic device comprising a memory, a processor and a computer program stored in the memory, characterized in that: The processor executes the computer program to implement the steps of the method according to any one of claims 1 to 6.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.