Indicator query method and apparatus, electronic device, and readable storage medium

By creating virtual tables for the metrics to be queried, the query logic for offline and real-time data is simplified, solving the cumbersome query problems in existing technologies and achieving efficient data processing and analysis.

WO2025260986A1PCT designated stage Publication Date: 2025-12-26BEIJING DIPEAK TECHNOLOGY CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
PCT/CN2025/093321
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2024-06-21
Filing Date
2025-05-08
Publication Date
2025-12-26

AI Technical Summary

Technical Problem

In data analysis scenarios, existing technologies require querying offline and real-time data separately, resulting in cumbersome query logic, high professional skill requirements, wasted human resources, and high data development complexity, making it difficult to meet business needs for timely metrics.

Method used

By creating a first virtual table and a second virtual table for the metrics to be queried, defining the acquisition and processing logic for offline and real-time data respectively, and providing a set of query conditions and aggregation methods, the query operation is simplified, enabling the query of metrics for historical and current time periods.

Benefits of technology

It simplifies query operations, saves human resources, reduces the difficulty and cost of data development, and improves data processing and analysis efficiency, making it suitable for various big data analysis scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2025093321_26122025_PF_FP_ABST
    Figure CN2025093321_26122025_PF_FP_ABST
Patent Text Reader

Abstract

Embodiments of the present application relate to the technical field of data processing, and provide an indicator query method and apparatus, an electronic device, and a readable storage medium. The method comprises: acquiring query conditions for an indicator to be queried; if a query time period comprises both a current time period and a historical time period, acquiring a first virtual table and a second virtual table which are pre-created for the indicator to be queried and have the same schema; on the basis of the first virtual table and data in a preset database, obtaining first indicator values of drill-down indicators within the historical time period; on the basis of the second virtual table and data in a real-time calculation engine, obtaining second indicator values of the drill-down indicators within the current time period; and on the basis of a first aggregation metric, performing aggregation processing on the first indicator values and the second indicator values of the drill-down indicators so as to obtain an indicator value of the indicator to be queried. In this way, indicator values obtained on the basis of data within a historical time period and data within a current time period can be obtained simultaneously simply by using a set of query conditions, thereby simplifying the query operation.
Need to check novelty before this filing date? Find Prior Art

Description

Indicator query methods, devices, electronic equipment, and readable storage media

[0001] This disclosure claims priority to Chinese Patent No. 202410810498.1, filed on June 21, 2024, entitled "Method, Apparatus, Electronic Device and Readable Storage Medium for Querying Indicators", the entire contents of which are incorporated herein by reference. Technical Field

[0002] This application relates to the field of data processing technology, and more specifically, to a method, apparatus, electronic device, and readable storage medium for querying indicators. Background Technology

[0003] In data analytics scenarios, industry reporting needs to provide users with business metrics (referred to as "metrics") that allow them to directly view business data. Metrics are key quantitative indicators used to measure business operations and are very important data analytics assets.

[0004] The data required for metric calculations are stored in different locations depending on whether it is offline or real-time. Offline data is usually written to a database, while real-time data is usually stored in a real-time computing engine and is not currently written to a database.

[0005] As business grows, data users have higher requirements for the timeliness of metrics. When querying business metrics, offline data and real-time data need to be queried separately using two sets of logic. The metrics also need to be calculated using two sets of logic. Furthermore, the queryer needs to manually combine the results of the two parts of the metrics. The query method is cumbersome, requires a high level of professional skills from the queryer, and is a waste of human resources. Summary of the Invention

[0006] This disclosure provides at least one method, apparatus, electronic device, and readable storage medium for querying an indicator.

[0007] In a first aspect, embodiments of this disclosure provide an electronic device, including: a processor, a memory, and a bus. The memory stores machine-readable instructions executable by the processor. When the electronic device is running, the processor communicates with the memory via the bus. When the machine-readable instructions are executed by the processor, a query method for indicators is performed. The query method for indicators includes:

[0008] Obtain the query conditions for the target indicator. The query conditions include the query time period, each drill-down indicator of the target indicator, and the first aggregated measure of each drill-down indicator.

[0009] If the query time period is determined to include both the current time period and the historical time period, where the current time period is the time period within the current period and the historical time period is the time period within at least one historical period, then the first virtual table and the second virtual table, which were pre-created for the queried metric, are obtained; the data source for the first virtual table is a preset database, and the data source for the second virtual table is a real-time computing engine; the first virtual table and the second virtual table have the same table structure.

[0010] Based on the data in the first virtual table and the preset database, obtain the first indicator value of each drill-down indicator in the historical time period; based on the data in the second virtual table and the real-time computing engine, obtain the second indicator value of each drill-down indicator in the current time period.

[0011] Based on the first aggregated measure of each drill-down indicator, the first and second indicator values ​​of each drill-down indicator are aggregated, and the aggregated indicator value is used as the indicator value of the indicator to be queried.

[0012] In one possible implementation, during the query method of the indicators executed by the processor, the first virtual table includes multiple fields and a first calculation method between the multiple fields;

[0013] The step of 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 includes:

[0014] If a preset view is queried and it is determined that at least one pre-calculation method included in the preset view contains various target pre-calculation methods, and the first calculation method is obtained after integration processing of the various target pre-calculation methods, then the target pre-calculation result obtained from the preset view based on each target pre-calculation method during the historical time period is obtained; 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 from the preset database in the previous historical period of the new current period, performs pre-calculation processing on the field values ​​of the previous historical period through the pre-calculation method to obtain the pre-calculation result, and stores the pre-calculation result in the preset view;

[0015] The target pre-calculation results of each target pre-calculation method are integrated and processed to obtain the first indicator value of the drilling index corresponding to the historical time period.

[0016] In one possible implementation, after querying the preset view, the processor is further configured to execute:

[0017] If it is determined that none of the target pre-calculation results are present in at least one of the pre-calculation results contained in the preset view, then an SQL statement set is generated based on the multiple fields contained in the first virtual table, the first calculation method, and the historical time period.

[0018] The SQL statement set is executed on the preset database to obtain the first indicator value of the drill-down indicator corresponding to the historical time period.

[0019] In one possible implementation, during the query method for metrics executed by the processor, the generation of the SQL statement set includes:

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

[0021] 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.

[0022] In one possible implementation, during the query method for metrics executed by the processor, the second virtual table includes multiple fields and a second calculation method between the multiple fields; the real-time computing engine includes at least one message queue; each message queue corresponds to a specific field.

[0023] The step of obtaining the second indicator value corresponding to each drill-down indicator in the current time period based on the second virtual table and the data in the real-time computing engine includes:

[0024] Obtain the queue identifier of at least one target message queue corresponding to each field in the second virtual table; based on the queue identifier of the target message queue and the second calculation method, generate a calculation operator for obtaining the drill-down index from the real-time computing engine;

[0025] Obtain a preset consumption strategy; the consumption strategy is any one of the following: starting consumption from the earliest data stored in the corresponding message queue, starting consumption from the latest data stored in the message queue, or starting consumption from data stored in the corresponding message queue at a preset time.

[0026] Based on 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.

[0027] In one possible implementation, during the query method for the metric executed by the processor, the process of obtaining the first virtual table pre-created for the metric to be queried further includes:

[0028] Configure the first virtual table as follows:

[0029] 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;

[0030] Configure the first calculation method between the fields in the first virtual table.

[0031] In one possible implementation, during the query method for the metric executed by the processor, a second virtual table pre-created for the metric to be queried is obtained, which further includes:

[0032] Configure the second virtual table as follows:

[0033] Configure the data source, definition information, and data consumption strategy 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;

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

[0035] Secondly, embodiments of this disclosure provide a method for querying indicators, including:

[0036] Obtain the query conditions for the indicator to be queried, which include the query time period, each drill-down indicator of the indicator to be queried, and the first aggregated metric of each drill-down indicator.

[0037] If it is determined that the query time period includes both the current time period and the historical time period, wherein the current time period is the time period located in the current cycle and the historical time period is the time period located in at least one historical cycle, then a first virtual table and a second virtual table pre-created for the queried indicator 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.

[0038] Based on the data in the first virtual table and the preset database, obtain the first indicator value of each drilling indicator corresponding to the historical time period; based on the data in the second virtual table and the real-time computing engine, obtain the second indicator value of each drilling indicator corresponding to the current time period.

[0039] Based on the first aggregated 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.

[0040] In one possible implementation, the first virtual table includes multiple fields and a first calculation method between the multiple fields;

[0041] The step of 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 includes:

[0042] If a preset view is queried and it is determined that at least one pre-calculation method included in the preset view contains various target pre-calculation methods, and the first calculation method is obtained after integration processing of the various target pre-calculation methods, then the target pre-calculation result obtained from the preset view based on each target pre-calculation method during the historical time period is obtained; 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 from the preset database in the previous historical period of the new current period, performs pre-calculation processing on the field values ​​of the previous historical period through the pre-calculation method to obtain the pre-calculation result, and stores the pre-calculation result in the preset view;

[0043] The target pre-calculation results of each target pre-calculation method are integrated and processed to obtain the first indicator value of the drilling index corresponding to the historical time period.

[0044] In one possible implementation, the query preset view further includes:

[0045] If it is determined that none of the target pre-calculation results are present in at least one of the pre-calculation results contained in the preset view, then an SQL statement set is generated based on the multiple fields contained in the first virtual table, the first calculation method, and the historical time period.

[0046] The SQL statement set is executed on the preset database to obtain the first indicator value of the drill-down indicator corresponding to the historical time period.

[0047] In one possible implementation, generating the SQL statement set includes:

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

[0049] 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.

[0050] In one possible implementation, the second virtual table includes multiple fields and a second calculation method between the multiple fields; the real-time computing engine includes at least one message queue; each message queue corresponds to a specific field.

[0051] The step of obtaining the second indicator value corresponding to each drill-down indicator in the current time period based on the second virtual table and the data in the real-time computing engine includes:

[0052] Obtain the queue identifier of at least one target message queue corresponding to each field in the second virtual table; based on the queue identifier of the target message queue and the second calculation method, generate a calculation operator for obtaining the drill-down index from the real-time computing engine;

[0053] Obtain a preset consumption strategy; the consumption strategy is any one of the following: starting consumption from the earliest data stored in the corresponding message queue, starting consumption from the latest data stored in the message queue, or starting consumption from data stored in the corresponding message queue at a preset time.

[0054] Based on 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.

[0055] In one possible implementation, the step of obtaining a first virtual table pre-created for the queried metric further includes:

[0056] Configure the first virtual table as follows:

[0057] 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;

[0058] Configure the first calculation method between the fields in the first virtual table.

[0059] In one possible implementation, obtaining a second virtual table pre-created for the queried metric further includes:

[0060] Configure the second virtual table as follows:

[0061] Configure the data source, definition information, and data consumption strategy 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;

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

[0063] Thirdly, embodiments of this disclosure provide an indicator query device, including:

[0064] The first acquisition module is used to acquire the query conditions of the indicator to be queried. The query conditions include the query time period, each drill-down indicator of the indicator to be queried, and the first aggregated metric of each drill-down indicator.

[0065] The processing module is configured to, if it is determined that the query time period includes both the current time period and the historical time period, wherein the current time period is the time period located in the current cycle and the historical time period is the time period located in at least one historical cycle, then obtain a first virtual table and a second virtual table pre-created for the queried indicator; 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.

[0066] The second acquisition module is used to obtain the first indicator value of each drill-down indicator in the historical time period based on the data in the first virtual table and the preset database; and to obtain the second indicator value of each drill-down indicator in the current time period based on the data in the second virtual table and the real-time computing engine.

[0067] The aggregation module is used to aggregate the first indicator value and the second indicator value of each drill-down indicator based on 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.

[0068] Fourthly, embodiments of this disclosure also provide a computer-readable storage medium storing a computer program that, when executed by a processor, performs the steps of the second aspect above, or any possible implementation of the second aspect.

[0069] Fifthly, embodiments of this disclosure also provide a computer program product including computer instructions stored in a computer-readable storage medium. When a processor of an electronic device reads the computer instructions from the computer-readable storage medium, the processor executes the computer instructions, causing the electronic device to perform steps implementing the method provided in the second aspect.

[0070] To make the above-mentioned objects, features and advantages of this disclosure more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings.

[0071] The beneficial effects of the technical solutions provided in this application are:

[0072] This application embodiment creates a first virtual table and a second virtual table for the metrics to be queried. The first virtual table defines the acquisition and processing logic for historical period data (i.e., offline data), and the second virtual table defines the acquisition and processing logic for current period data (i.e., real-time data). For the metric queryer, the queryer only needs to use one set of query conditions. The queryer does not need to understand the internal execution logic of the first and second virtual tables. By using one set of drill-down metrics and drill-down metric aggregation methods, the queryer can simultaneously obtain metrics generated based on offline data of historical time periods and real-time data of the current time period, simplifying the query operation and effectively saving human resources.

[0073] Furthermore, the embodiments of this application reduce the difficulty of data development and at least the cost of data development, and have broad application prospects. They can be applied to various big data analysis scenarios, improve the efficiency of data processing and analysis, and unleash the potential of data. Attached Figure Description

[0074] To more clearly illustrate the technical solutions of the embodiments of this disclosure, the accompanying drawings used in the embodiments will be briefly described below. These drawings are incorporated in and constitute a part of this specification. They illustrate embodiments conforming to this disclosure and, together with the specification, serve to explain the technical solutions of this disclosure. It should be understood that the following drawings only show some embodiments of this disclosure and should not be considered as limiting the scope. Those skilled in the art can obtain other related drawings based on these drawings without creative effort.

[0075] Figure 1 is a flowchart illustrating a method for querying an indicator provided in an embodiment of this application;

[0076] Figure 2 is a schematic diagram of the architecture of the query method for implementing indicators provided in the embodiments of this application;

[0077] Figure 3 is a schematic diagram of the structure of an index query device provided in an embodiment of this application;

[0078] Figure 4 is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation

[0079] To make the objectives, technical solutions, and advantages of the embodiments of this disclosure clearer, the technical solutions of the embodiments of this disclosure will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this disclosure, and not all of them. The components of the embodiments of this disclosure described and shown herein can generally be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of this disclosure is not intended to limit the scope of the claimed disclosure, but merely represents selected embodiments of this disclosure. All other embodiments obtained by those skilled in the art based on the embodiments of this disclosure without inventive effort are within the scope of protection of this disclosure.

[0080] To make the objectives, technical solutions, and advantages of this application clearer, the embodiments of this application will be described in further detail below with reference to the accompanying drawings.

[0081] First, let's introduce and explain several terms used in this application:

[0082] Physical Tables: Physical tables are the actual tables in a database that store data; they specifically correspond to the physical storage structure within the database system. A physical table contains actual data rows and columns, as well as corresponding physical attributes such as storage format, indexes, and partitions. In database / data warehouse and big data technology stacks, physical tables are the entities that persist and organize data. They are stored on disk and managed by the aforementioned systems for read and write operations. Physical tables can consist of a table structure and data rows, used to store and manipulate actual business data.

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

[0084] Fact table: A table in a data warehouse used to store business metrics. It contains factual data related to business processes, such as sales amount, quantity, and time. Fact tables are typically linked to dimension tables via the primary key of the dimension tables to provide a richer analytical perspective.

[0085] Dimension tables are tables used in a data warehouse to store dimensional data. They contain detailed business-related information, such as time, location, and product. Dimension tables typically contain a unique identifier (primary key) and descriptive attributes (such as name, description, and hierarchy). The purpose of dimension tables is to provide context and relationships for fact tables.

[0086] A virtual table is a special type of table where the table structure (schema) and physical data are separated. It is derived from one or more source tables. Logical tables define how data is queried using `Create Table As Select` and logically possess the characteristics of physical tables.

[0087] Stream-batch integration is a data computation model. Data computation is divided into batch computation and stream computation, which are typically performed separately, and the results are used separately. The purpose of stream-batch integration is to ensure that data users are unaware of the existence of the two parts of data, allowing them to access data from different time intervals at will.

[0088] Integrated stream-batch virtual table: This is a type of virtual table that logically aggregates offline and real-time data tables. It ensures that the format (number of fields, order, type) of the offline and real-time data tables is consistent. Then, it combines the data from the two virtual tables using the `Select * from Aunion B` method, forming a single virtual table that can access data at any point in time.

[0089] Materialized views are pre-computed and stored sets of query results created in a data warehouse. They are virtual tables that transform complex queries into simplified table structures based on predefined query rules and aggregate functions, improving query performance and response time. Materialized views are typically used in scenarios with frequent queries to reduce the computational overhead of those queries.

[0090] In the traditional system, enterprise IT personnel need to deploy two types of computing clusters, manually define two sets of indicators, write two sets of indicator calculation logic, and manually splice the 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, double the number of indicators, and low data accuracy. In the current context of real-time data, it is inefficient and redundant.

[0091] Specifically, the processing logic of the indicators consists of the following steps:

[0092] Data source definition;

[0093] Offline data table definition;

[0094] Real-time data format definition;

[0095] Offline indicator logic definition;

[0096] Real-time indicator logic definition;

[0097] Development of indicator calculation tasks;

[0098] The results of the indicator query are combined.

[0099] In this process, data developers need to define offline and real-time data sources separately. Data table or data structure definition refers to importing the physical tables corresponding to the data sources, while the real-time data source references the Topic's data schema, defining two sets of data models.

[0100] The definition of indicators requires defining two sets of indicator definitions for offline data tables and real-time data tables respectively. It is necessary to manually ensure that the data structure and indicator definitions of offline and real-time data are consistent.

[0101] The development of indicator calculation jobs (also known as calculation tasks or tasks) involves several steps, including developing calculation jobs for offline and real-time indicators, configuring job logic (including dimensions and metrics), allocating computing clusters, and deploying the jobs.

[0102] The reason for concatenating indicator query results is that the results of offline and real-time indicator calculations are written to different engines and storage. When querying indicators, it is necessary to manually concatenate the two parts of the results. The query logic needs to dynamically concatenate the results based on the user's query time range, dimension conditions, and aggregated metrics.

[0103] Traditional data metrics primarily revolve around offline metrics. Offline metrics typically summarize data from the previous day and display the results in T-1 timeframes (T represents the current day, and T-1 represents the previous day). Data users can usually see data from 8 to 12 hours ago. However, with business growth, data users have increasingly higher demands for the timeliness of metrics. They are no longer satisfied with only viewing data from T-1 days ago; they want to be able to view metrics from the most recent minutes or even seconds, and to select the time range for each metric. Furthermore, calculating metrics based on offline data and calculating metrics based on real-time data involves two separate logics, requiring the user to manually combine the results from both sources. This cumbersome query process increases both the development difficulty and the user's query complexity.

[0104] Based on the above research, this disclosure provides a method, apparatus, electronic device, and readable storage medium for querying indicators. By creating 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 historical period data (i.e., offline data), and the second virtual table defines the acquisition and processing logic of current period data (i.e., real-time data). For the indicator queryer, the queryer only needs to use one set of query conditions. The queryer does not need to understand the internal execution logic of the first and second virtual tables. By using a set of drill-down indicators and drill-down indicator aggregation methods, the queryer can simultaneously obtain indicators generated based on offline data of historical time periods and real-time data of the current time period, simplifying the query operation and effectively saving human resources.

[0105] Furthermore, the embodiments of this application reduce the difficulty of data development and at least the cost of data development, and have broad application prospects. They can be applied to various big data analysis scenarios, improve the efficiency of data processing and analysis, and unleash the potential of data.

[0106] It should be noted that similar labels and letters in the following figures indicate similar items. Therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures.

[0107] In this document, the term "and / or" merely describes a relationship, indicating that three relationships can exist. For example, A and / or B can represent three cases: A alone, A and B simultaneously, and B alone. Furthermore, the term "at least one" in this document means any combination of at least two of any one or more elements. For example, including at least one of A, B, and C can mean including any one or more elements selected from the set consisting of A, B, and C.

[0108] It is understood that before using the technical solutions disclosed in the various embodiments of this disclosure, the personal information involved in this disclosure (including but not limited to attribute information, facial images, etc.) is obtained with the user's authorization. Specifically, it may be by sending a prompt message requesting authorization to the user through pop-up windows on the page, information push, etc., and obtaining the above personal information after the user agrees to the authorization.

[0109] The technical solutions of this application and their effects are described below through several exemplary embodiments. It should be noted that the following embodiments can be referenced, borrowed from, or combined with each other. Identical terms, similar features, and similar implementation steps in different embodiments will not be repeated.

[0110] This application provides a method for querying indicators, as shown in Figure 1. The method includes:

[0111] Step S101: Obtain the query conditions for the indicator to be queried. The query conditions include the query time period, each drill-down indicator of the indicator to be queried, and the first aggregated metric of each drill-down indicator.

[0112] In this application embodiment, the query indicator refers to the business indicator to be queried. Business indicators (hereinafter referred to as "indicators") are key quantitative indicators used to measure the business operation status. They 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.

[0113] Different metrics exist in different business scenarios or business needs. For example, in the scenario of selling goods, metrics can be sales revenue and sales volume.

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

[0115] The query time period refers to a time period that business personnel intend to query. It can be the current time period, a historical time period, or both. The current time period refers to the time period within the current period. When the query time period is the current time period, the metric to be queried can be called a "historical metric". The historical time period can be a time period before the current period that is located in at least one historical period. When the query time period is a historical time period, the metric to be queried can be called a "current metric".

[0116] There is no limit to the duration of each cycle; it can be 1 day, 1 hour, 10 minutes, etc. It is worth noting that the current time period and the historical time period do not have to be a complete cycle. The current time period can be a part of the current cycle. Specifically, assuming the duration of a cycle is 1 day, the current cycle can be any period from the start of today to the current time. Usually, it is the period from the start of the current cycle to the current time.

[0117] The historical time period can be a part of a certain historical cycle or a period composed of multiple historical cycles. This application does not limit this.

[0118] In business analytics, drill-down refers to the process of further breaking down and analyzing raw metrics to gain a deeper understanding and insight. Drill-down can help identify potential problems, discover new opportunities, and guide decision-making and action.

[0119] Taking sales revenue as an example, drill-down to the sales revenue metric can typically be done in one or more of the following ways:

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

[0121] Drill down by product: Break down sales revenue into sales revenue for various products or product categories to understand the sales performance of each product.

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

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

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

[0125] Of course, in actual business scenarios, drill-down can also be performed based on other types of metrics, and this application embodiment does not limit this.

[0126] In this application embodiment, the drill-down indicator of the query indicator refers to the indicator obtained after drilling down the query indicator. The query indicator is the original indicator, and the drill-down indicator is the indicator obtained after drilling down the indicator. Drill-down of the query indicator can be performed on the query indicator according to one or more drill-down methods required by the actual business scenario. Drill-down of the query indicator can be performed on the query indicator at any granularity (e.g., provincial, municipal, district, etc.) to obtain multiple drill-down indicators. There is no limitation on this.

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

[0128] The first aggregate measure of drill-down metrics refers to combining multiple drill-down metrics to generate a more comprehensive assessment or understanding of the metric being queried. The first aggregate measure includes, but is not limited to, summation, weighted average, weighted summation, and composite index. In actual business scenarios, any one or more first aggregate measures can be selected based on the actual situation of the metric being queried.

[0129] Specifically, suppose the query metric is "total sales revenue of product A in all provinces of Southwest China in spring". Suppose there are three provinces in Southwest China: A, B and C. Then the drill-down metrics can be the sales revenue of product A in province A in spring, the sales revenue of product A in province B in spring, and the sales revenue of product A in province C in spring. The first aggregation measure of each drill-down metric can be determined based on "total sales revenue" and is "sum".

[0130] In addition, query conditions can include other information, such as filtering conditions. Filtering conditions can be used to filter drill-down indicators that do not meet the preset conditions, and there are no restrictions on other information in the query conditions.

[0131] Step S102: If it is determined that the query time period includes both the current time period and the historical time period, where the current time period is the time period in the current cycle and the historical time period is the time period in at least one historical cycle, then obtain the first virtual table and the second virtual table that were pre-created for the queried indicator.

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

[0133] In this embodiment of the application, both the first virtual table and the second virtual table are virtual tables, not physical tables. Many fields in the first virtual table and the second virtual table are the same fields, which allows the queryer to query both the first virtual table and the second virtual table at the same time. Many fields in the first virtual table correspond to fields in the physical tables in the preset database, and many 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 an "integrated stream and batch virtual table" to the outside world.

[0134] In this embodiment, after obtaining the query time period for the metric to be queried, the type of the query time needs to be determined. Specifically, there are three types: current time period, historical time period, and current time period + historical time period. The current time period is the time period within the current cycle, and the historical time period is the time period within at least one historical cycle. When calculating the metric value of the business indicator within the historical time period, data written to a preset database is used; this data is "offline data." When calculating the metric value of the business indicator within the current time period, data from the real-time computing engine is used; this data is "real-time data," and the data in the real-time computing engine has not yet been written to the preset database.

[0135] The preset database can be a database for storing business data, a single-machine database, or a distributed database; this application embodiment does not impose any restrictions on this.

[0136] If the query time period is determined to include both the current time period and the historical time period, the query time period will be split into two time periods: the current time period and the historical time period. The first virtual table and the second virtual table created in advance for the metric to be queried will be obtained.

[0137] In fact, the first and second virtual tables have the same table structure. Specifically, many fields in the first and second virtual tables are the same. When configuring the first and second virtual tables, the system automatically verifies whether the structures of the two tables are consistent, including whether the number of fields, field types, and field order are consistent. Once the data structures of the two data sources are ensured to be consistent (or compatible), the system can save the two virtual tables as a unified stream and batch processing virtual table.

[0138] The calculation of drill-down metrics requires the use of some fields in the data table and the calculation methods between these fields. The calculation methods between the various fields can be defined according to the actual business scenario, and there are no restrictions on this.

[0139] Step S103: Based on the data in the first virtual table and the preset database, obtain the first indicator value corresponding to each drill-down indicator in the historical time period; based on the data in the second virtual table and the real-time computing engine, obtain the second indicator value corresponding to each drill-down indicator in the current time period.

[0140] The first and second virtual tables in this application embodiment provide a table structure. The first and second virtual tables do not actually store data. The first virtual table can be used to access a preset database to obtain offline data in the preset database, and the second virtual table can be used to access a real-time computing engine to obtain real-time data in the real-time computing engine.

[0141] The offline data in the preset database is the field value corresponding to each field in the first virtual table. The first virtual table also includes the first calculation method between each field (related to actual needs, such as summation, product, 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.

[0142] 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 lead to different calculation formulas). The first calculation method and the second calculation method are set according to the actual business scenario. The field values ​​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.

[0143] Step S104: Based on the first aggregated metric of each drill-down metric, aggregate the first and second metric values ​​of each drill-down metric, and use the aggregated metric value as the metric value of the metric to be queried.

[0144] In this embodiment of the application, after obtaining the first indicator value corresponding to each drilling indicator in the historical time period and the second indicator value corresponding to each drilling indicator in the current time period, the first indicator value and the second indicator value of each drilling indicator can be aggregated according to the first aggregation metric of each drilling indicator (summing, averaging, variance, etc., which can be determined according to the actual situation) to obtain the aggregated indicator value, which is the indicator value of the indicator to be queried.

[0145] This application embodiment creates a first virtual table and a second virtual table for the metrics to be queried. The first virtual table defines the acquisition and processing logic for historical period data (i.e., offline data), and the second virtual table defines the acquisition and processing logic for current period data (i.e., real-time data). For the metric queryer, the queryer only needs to use one set of query conditions. The queryer does not need to understand the internal execution logic of the first and second virtual tables. By using one set of drill-down metrics and drill-down metric aggregation methods, the queryer can simultaneously obtain metrics generated based on historical period data and current period real-time data, simplifying the query operation and effectively saving human resources.

[0146] Furthermore, the embodiments of this application reduce the difficulty of data development and at least the cost of data development, and have broad application prospects. They can be applied to various big data analysis scenarios, improve the efficiency of data processing and analysis, and unleash the potential of data.

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

[0148] If the query time period of the indicator to be queried corresponds to a current time period, then the 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 based on the second virtual table, and the second indicator value is used as the indicator value of the indicator to be queried.

[0149] Since many fields in the first and second virtual tables are the same (although the subsequent time column fields may indicate that data is retrieved in different time periods, they can all be represented as time column fields and can be regarded as the same fields), this indicates that the two have the same table structure. This means 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, the query logic is the same for the queryer, which simplifies the query operation and effectively saves human resources.

[0150] This application provides a possible implementation method in which the first virtual table includes multiple fields and a first calculation method between the multiple fields;

[0151] Based on the data in the first virtual table and the preset database, obtain the first indicator values ​​for each drill-down indicator in the historical time period, including:

[0152] If the preset view is queried and it is determined that each target pre-calculation method exists in at least one of the pre-calculation methods contained in the preset view, and the first calculation method is obtained after the integration of each target pre-calculation method, then the target pre-calculation results obtained from the preset view based on each target pre-calculation method in the historical time period are obtained. 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 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.

[0153] 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 of the drilling index in the historical time period.

[0154] In this embodiment of the application, each field in the first virtual table corresponds to a 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, it is also called an "offline calculation job." The "offline calculation job" can be executed by an offline calculation engine, such as Hive or Spark. In addition, the first virtual table may also include the physical table's access path, connection relationship, filtering conditions, and field sorting.

[0155] This application embodiment also includes a preset view. The real-time computing engine can periodically write data to the preset database. Specifically, when a new current period is generated, the real-time computing engine can write the data of the previous historical period of the new current period to the preset database. If the preset database is partitioned by period, each partition corresponds to the data of one period. When a new partition is generated, the data in this new partition is the data of the previous historical period.

[0156] Furthermore, since the data for each historical period is fixed, preprocessing can be performed on the historical period data to facilitate subsequent calculations. Specifically, multiple pre-calculation methods can be preset. Compared to the first calculation method, the pre-calculation method can be a simple calculation, such as calculating the sum or product of multiple fields. The pre-calculation method is set by the user. Continuing the previous example, A*B can be a pre-calculation method. For each pre-calculation method, the preset offline calculation engine retrieves the field values ​​of each field involved in the pre-calculation method from the preset database in the previous historical period of the new current period. The field values ​​of the previous historical period are pre-calculated using the pre-calculation method to obtain the pre-calculation result. The pre-calculation result and the generation time of the corresponding data are stored in the preset view to facilitate subsequent calculations and improve the efficiency of subsequent calculations.

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

[0158] This application embodiment provides a possible implementation, which involves querying a preset view, and then further includes:

[0159] If it is determined that the target pre-calculation results are not present in at least one of the pre-calculation results contained in the preset view, then an SQL (Structured Query Language) statement set is generated based on the multiple fields contained in the first virtual table, the first calculation method, and the historical time period.

[0160] Execute a set of SQL statements on a preset database to obtain the first indicator value of the drill-down indicator in the historical time period.

[0161] In this embodiment of the application, after determining that at least one pre-calculated result contained in the preset view does not contain any of the target pre-calculated results, or does not contain all of the target pre-calculated results, an SQL statement set can be generated based on multiple fields contained in the first virtual table, the first calculation method, and the historical time period.

[0162] This application provides a possible implementation for generating a set of SQL statements, including:

[0163] Parse the first virtual table to obtain the table identifier of at least one target physical table, the type of at least one target physical table, and the connection relationship between at least one target physical table for each field in the first virtual table;

[0164] A set of SQL statements is obtained 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.

[0165] The first virtual table can be expanded layer by layer through traversal, eventually reaching the target physical table for each atom. The target physical table contains the fields required to calculate drill-down metrics. During the expansion process, DataModel objects are used for data description, which is achieved through nodes (Vertex representation table, which can be either a virtual table or a physical table), node attributes (including the data table type, which can be either a fact table or a dimension table), and edges (the connection relationships between edge representation tables, including connections between virtual tables, between virtual tables and physical tables, between physical tables, and between physical tables). Finally, the table identifier, type, relationships between target physical tables, and required fields in each physical table need to be determined.

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

[0167] The physical table can be a fact table or a dimension table.

[0168] The join relationship between physical tables can be a way of associating two or more tables. This join relationship allows for joint queries to be performed across multiple tables in order to obtain richer and more complex data.

[0169] The main types of join relationships are as follows:

[0170] Inner Join: An inner join is one of the most common join types. It only returns rows that satisfy the join condition. This means that a result is only returned if the value of the join column matches in both tables.

[0171] Outer Join: An outer join allows you to return all rows from one table, even if there are no matching rows in the other table. There are three types of outer joins: left outer join, right outer join, and full outer join, depending on which table's rows are included in the result.

[0172] Self-join: A self-join is a join between the same table and itself. It is usually used when you need to compare data between different rows in a table.

[0173] 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 a combination of every row in the first table with every row in the second table.

[0174] Natural Join: A natural join automatically joins two tables based on the similarity of their column names. It automatically matches columns with the same name and returns matching rows.

[0175] Of course, other connection methods can also be included, and there are no restrictions on this. The connection relationship to be selected should be determined according to the actual scenario.

[0176] Based on the table identifier of at least one target physical table, the type of at least one target physical table, the join relationship between at least one target physical table, and the first calculation method between multiple fields, a set of SQL statements for querying drill-down metrics can be generated. The table identifier of one target physical table, the type of at least one target physical table, the join 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. Executing the SQL statement set can obtain the metric value of the drill-down metrics in the historical time period.

[0177] This application provides a possible implementation method, in which the second virtual table includes multiple fields and a second calculation method between the multiple fields; the real-time computing engine includes at least one message queue; each message queue corresponds to each field.

[0178] Based on the data from the second virtual table and the real-time computing engine, obtain the second indicator values ​​for each drill-down indicator in the current time period, including:

[0179] Obtain the queue identifier of at least one target message queue corresponding to each field in the second virtual table; based on the queue identifier of the target message queue and the second calculation method, generate a calculation operator for obtaining drill-down metrics from the real-time computing engine;

[0180] Obtain the preset consumption strategy; the consumption strategy can be any one of the following: start consuming from the earliest data stored in the corresponding message queue, start consuming from the latest data stored in the message queue, or start consuming from the data stored in the corresponding message queue at a preset time.

[0181] Based on the calculation operator, the current time period, and the preset consumption strategy, obtain the second indicator value corresponding to each drill-down indicator in the current time period.

[0182] The second calculation method in the second virtual table of this application embodiment is a job that processes real-time data in a real-time computing engine. Therefore, the second calculation job is also called a "real-time computing job". The real-time computing engine can be an engine such as Flink. The second virtual table includes multiple fields, and each field has a corresponding message queue (topic). Each topic in the real-time computing engine can store the 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 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 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). 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 can be obtained.

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

[0184] In fact, to ensure the real-time nature of the second indicator value, it can be configured to be updated in real time. Here, "real-time" can mean every 1 second, 3 seconds, 5 seconds, etc.

[0185] This application embodiment provides a possible implementation method, which involves obtaining a first virtual table pre-created for the metric to be queried, and prior to this, includes:

[0186] Configure the first virtual table as follows:

[0187] 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;

[0188] Configure the first calculation method between the fields in the first virtual table.

[0189] The data source for the first virtual table is a preset database, which is an offline data source. When configuring the data source, you can configure the data source injection server IP address, username, password, access protocol, and other information.

[0190] Configure the definition information of the first virtual table, including editing the table name of the first virtual table, the field names and field types of each field required for calculating drill-down indicators, and the first time column field can be included among the multiple fields; the generation time of the data in the first time column field, the generation time of each data record in the first virtual table belongs to the historical period, and the processing of historical period data belongs to batch processing, which indicates that the first virtual table belongs to the batch table.

[0191] In addition, the indicator logic definition also needs to be configured. Configuring the indicator logic definition means configuring the first calculation method between each field in the first virtual table. The first calculation method indicates the field name to be calculated and the calculation function, which usually includes any one or more of sum, count, avg, count-distinct, etc., without restriction.

[0192] This application provides a possible implementation method for obtaining a second virtual table pre-created for the metric to be queried, which further includes:

[0193] Configure the second virtual table as follows:

[0194] Configure the data source, definition information, and data consumption strategy 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;

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

[0196] Similar to configuring the first virtual table, configuring the second virtual table also requires configuring the data source. The data source for the second virtual table is the real-time computing engine, specifically the queue identifier (which can be the queue name) of the message queue where the corresponding field in the real-time computing engine resides.

[0197] In addition, since real-time data is stored in message queues (Kafka, RabbitMQ, etc.), unlike databases which are permanently stored, consumption strategies can be selected when using the data, including: Oldest: start consuming from the oldest data stored in the corresponding message queue; Newest: start consuming from the latest data stored in the message queue; Fixed preset time: start consuming from the data stored in the corresponding message queue at a preset time.

[0198] In addition, the minimum time granularity for updating real-time metrics needs to be configured. The minimum time granularity is a small time range designed to present "real-time" characteristics. For example, in the current period, the minimum time granularity can be 1s, 5s, or 10s. Here, a sliding window function can be set to configure parameters such as the sliding length and step size, indicating that the second virtual table is a real-time table (Stream).

[0199] In fact, after configuring the first and second virtual tables, the system will automatically verify whether the structures of the two tables are consistent. The verification includes whether the number of table fields, field types, and field order are consistent. Once the data structures of the two data sources are ensured to be consistent (or compatible), the system can save the two virtual tables as a single virtual table for both batch and stream processing.

[0200] As shown in Figure 2, it exemplarily illustrates the architecture of the query method for implementing metrics provided in the embodiments of this application, including an XEngine configuration module, an XEngine calculation module, a query module, a real-time data source, and an offline data source. The offline data source refers to a preset database, and the real-time data source refers to a real-time computing engine.

[0201] The XEngine configuration module requires configuring 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. Configure the data source of the offline virtual table as an offline data source, and the data source of the real-time virtual table as a real-time data source. The offline and real-time virtual tables provide a unified stream and batch virtual table to the queryer, allowing the queryer to query real-time indicators, query offline indicators, or query the indicator values ​​of both real-time and offline indicators simultaneously based on the unified stream and batch virtual table.

[0202] 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 jobs are the aforementioned first calculation method. It can also expand the second virtual table to obtain real-time calculation jobs between each field in the second virtual table. The real-time calculation jobs are the aforementioned second calculation method.

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

[0204] If the query module determines that the query time period includes both the current time period and the historical time period, wherein the current time period is the time period located in the current cycle and the historical time period is the time period located in at least one historical cycle, then it obtains the first virtual table and the second virtual table that were pre-created for the queried indicator.

[0205] The query module can access the stream computing engine and offline computing engine in the XEngine computing module. The offline computing engine connects to offline data sources and can obtain 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.

[0206] The stream computing engine connects to a real-time data source. Based on the data in the second virtual table and the real-time computing engine, the stream computing engine can obtain the second indicator value corresponding to each drill-down indicator in the current time period.

[0207] Those skilled in the art will understand that, in the above-described method of the specific implementation, the order in which each step is written does not imply a strict execution order and does not constitute any limitation on the implementation process. The specific execution order of each step should be determined by its function and possible internal logic.

[0208] This application embodiment provides an indicator query device, as shown in FIG3. The indicator query device 30 may include:

[0209] The first acquisition module 310 is used to acquire the query conditions of the indicator to be queried. The query conditions include the query time period, each drill-down indicator of the indicator to be queried, and the first aggregated measure of each drill-down indicator.

[0210] The processing module 320 is used to obtain a first virtual table and a second virtual table pre-created for the queried indicator if it is determined that the query time period includes both the current time period and the historical time period, where the current time period is the time period located in the current period and the historical time period is the time period located in at least one historical period; 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.

[0211] The second acquisition module 330 is used to obtain the first indicator value of each drill-down indicator in the historical time period based on the data in the first virtual table and the preset database; and to obtain the second indicator value of each drill-down indicator in the current time period based on the data in the second virtual table and the real-time computing engine.

[0212] The aggregation module 340 is used to aggregate the first and second index values ​​of each drill-down index based on the first aggregated metric of each drill-down index, and use the aggregated index value as the index value of the index to be queried.

[0213] This application provides a possible implementation method in which the first virtual table includes multiple fields and a first calculation method between the multiple fields;

[0214] The second acquisition module includes:

[0215] The query submodule is used to query the preset view. If it is determined that there is a target pre-calculation method among at least one pre-calculation method contained in the preset view, and the first calculation method is obtained after the integration of each target pre-calculation method, then the target pre-calculation result obtained from the preset view based on each target pre-calculation method in the historical time period is obtained. 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 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 result, and stores the pre-calculation result in the preset view.

[0216] The integration submodule is used to integrate the target pre-calculation results of various target pre-calculation methods in the target historical time period to obtain the first indicator value of the drilling indicator in the historical time period.

[0217] This application embodiment provides a possible implementation, and the second acquisition module further includes:

[0218] The SQL statement set generation submodule is used to generate an SQL statement set based on multiple fields contained in the first virtual table, the first calculation method, and the historical time period if it is determined that there is no target pre-calculated result in at least one pre-calculated result contained in the preset view.

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

[0220] This application provides a possible implementation method in which the SQL statement set generation submodule is specifically used to parse the first virtual table and obtain the table identifier of at least one target physical table, the type of at least one target physical table, and the connection relationship between at least one target physical table corresponding to each field in the first virtual table; and obtain the SQL statement set 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.

[0221] This application provides a possible implementation method, in which the second virtual table includes multiple fields and a second calculation method between the multiple fields; the real-time computing engine includes at least one message queue; each message queue corresponds to each field.

[0222] The second acquisition module includes:

[0223] The queue identifier acquisition submodule is used to acquire the queue identifier of at least one target message queue corresponding to each field in the second virtual table; based on the queue identifier of the target message queue and the second calculation method, a calculation operator is generated for acquiring drill-down metrics from the real-time computing engine;

[0224] The consumption strategy acquisition submodule is used to acquire preset consumption strategies. The consumption strategy can be any one of the following: starting consumption from the earliest data stored in the corresponding message queue, starting consumption from the latest data stored in the message queue, or starting consumption from the data stored in the corresponding message queue at a preset time.

[0225] 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 based on the calculation operator, the current time period, and the preset consumption strategy.

[0226] This application provides a possible implementation method. The device further includes a first configuration module, which is used to configure a first virtual table in the following ways: configuring the data source and definition information of the first virtual table, wherein 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; and configuring a first calculation method between each field in the first virtual table.

[0227] This application provides a possible implementation method. The device further includes a second configuration module, which is used to configure the second virtual table in the following ways: configuring the data source, definition information, and data consumption strategy 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; and configuring the second calculation method between each field in the first virtual table.

[0228] The apparatus in this application embodiment can execute the method provided in this application embodiment, and the implementation principle is similar. The actions performed by each module in the apparatus of each embodiment of this application correspond to the steps in the method of each embodiment of this application. For detailed functional descriptions of each module of the apparatus, please refer to the descriptions in the corresponding methods shown above, which will not be repeated here.

[0229] In this application embodiment, the terms "module" or "unit" refer to a computer program or part of a computer program that has a predetermined function and works with other related parts to achieve a predetermined goal, and can be implemented wholly or partially using software, hardware (such as processing circuitry or memory), or a combination thereof. Similarly, a processor (or multiple processors or memory) can be used to implement one or more modules or units. Furthermore, each module or unit can be part of an overall module or unit that includes the functionality of that module or unit.

[0230] This application provides an electronic device, including a memory, a processor, and a computer program stored in the memory. The processor executes the computer program to implement the steps of a query method for indicators.

[0231] In one optional embodiment, an electronic device is provided, as shown in FIG4. The electronic device 4000 shown in FIG4 includes a processor 4001 and a memory 4003. The processor 4001 and the memory 4003 are connected, for example, via a bus 4002. Optionally, the electronic device 4000 may further include a transceiver 4004, which can be used for data interaction between the electronic device and other electronic devices, such as sending and / or receiving data. It should be noted that in practical applications, the transceiver 4004 is not limited to one type, and the structure of the electronic device 4000 does not constitute a limitation on the embodiments of this application.

[0232] 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 can implement or execute the 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 computational functions, such as including one or more microprocessor combinations, a combination of a DSP and a microprocessor, etc.

[0233] Bus 4002 may include a pathway for transmitting information between the aforementioned components. Bus 4002 may be a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus, etc. Bus 4002 can be divided into address bus, data bus, control bus, etc. For ease of illustration, only one thick line is used to represent it in Figure 4, but this does not indicate that there is only one bus or one type of bus.

[0234] The memory 4003 may be ROM (Read Only Memory) or other types of static storage devices capable of storing static information and instructions, RAM (Random Access Memory) or other types of dynamic storage devices capable of storing information and instructions, or EEPROM (Electrically Erasable Programmable Read Only Memory), CD-ROM (Compact Disc Read Only Memory) or other optical disc storage, optical disc storage (including compressed optical discs, laser discs, optical discs, digital universal optical discs, Blu-ray discs, etc.), magnetic disk storage media, other magnetic storage devices, or any other medium capable of carrying or storing computer programs and capable of being read by a computer, without limitation herein.

[0235] The memory 4003 stores computer programs that execute embodiments of this application, and its execution is controlled by the processor 4001. The processor 4001 executes the computer programs stored in the memory 4003 to implement the steps shown in the foregoing method embodiments.

[0236] The electronic device 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), and in-vehicle terminals (e.g., in-vehicle navigation terminals), as well as fixed terminals such as digital TVs and desktop computers. The electronic device shown in Figure 4 is merely an example and should not be construed as limiting the functionality and scope of use of the embodiments of this disclosure.

[0237] This application provides a computer-readable storage medium storing a computer program. When the computer program is executed by a processor, it can implement the steps and corresponding content of the aforementioned method embodiments.

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

[0239] This application also provides a computer program product, including a computer program that, when executed by a processor, can implement the steps and corresponding content of the aforementioned method embodiments. The terms "first," "second," "third," "fourth," "1," "2," etc. (if present) in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in a sequence other than that shown in the figures or text descriptions.

[0240] It should be understood that although arrows indicate various operation steps in the flowcharts of this application's embodiments, the order in which these steps are implemented is not limited to the order indicated by the arrows. Unless explicitly stated herein, in some implementation scenarios of this application's embodiments, the implementation steps in each flowchart can be executed in other orders as required. Furthermore, some or all steps in each flowchart, based on the actual implementation scenario, may include multiple sub-steps or multiple stages. Some or all of these sub-steps or stages can be executed at the same time, and each sub-step or stage can also be executed at different times. In scenarios where execution times differ, the execution order of these sub-steps or stages can be flexibly configured according to requirements, and this application's embodiments do not limit this.

[0241] The above are only optional implementation methods for some implementation scenarios of this application. It should be noted that for those skilled in the art, other similar implementation methods based on the technical concept of this application, without departing from the technical concept of this application, also fall within the protection scope of the embodiments of this application.

Claims

1. An electronic device, comprising: The device includes a processor, a memory, and a bus. The memory stores machine-readable instructions executable by the processor. When the electronic device is running, the processor communicates with the memory via the bus. When the machine-readable instructions are executed by the processor, a query method for indicators is performed. The query method includes the following steps: Obtain the query conditions for the indicator to be queried, which include the query time period, each drill-down indicator of the indicator to be queried, and the 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, wherein the current time period is the time period located in the current cycle and the historical time period is the time period located in at least one historical cycle, then a first virtual table and a second virtual table pre-created for the queried indicator 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. Based on the data in the first virtual table and the preset database, obtain the first indicator value of each drilling indicator corresponding to the historical time period; based on the data in the second virtual table and the real-time computing engine, obtain the second indicator value of each drilling indicator corresponding to the current time period. Based on the first aggregated 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.

2. The electronic device according to claim 1, characterized in that, During the query method for the metrics executed by the processor, the first virtual table includes multiple fields and a first calculation method between the multiple fields; The step of 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 includes: If a preset view is queried and it is determined that at least one pre-calculation method included in the preset view contains various target pre-calculation methods, and the first calculation method is obtained after integration processing of the various target pre-calculation methods, then the target pre-calculation result obtained from the preset view based on each target pre-calculation method during the historical time period is obtained; 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 from the preset database in the previous historical period of the new current period, performs pre-calculation processing on the field values ​​of the previous historical period through the pre-calculation method to obtain the pre-calculation result, and stores the pre-calculation result in the preset view; The target pre-calculation results of each target pre-calculation method are integrated and processed to obtain the first indicator value of the drilling index corresponding to the historical time period.

3. The electronic device according to claim 2, characterized in that... After querying the preset view, the processor is also used to execute: If it is determined that none of the target pre-calculation results are present in at least one of the pre-calculation results contained in the preset view, then an SQL statement set is generated based on the multiple fields contained 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 the first indicator value of the drill-down indicator corresponding to the historical time period.

4. The electronic device according to claim 3, characterized in that, During the query method for metrics executed by the processor, the generation of the SQL statement set includes: Parse the first virtual table to obtain the table identifier of at least one target physical table, the type of at least one target physical table, and the connection relationship between at least one target physical table corresponding to each field in the first virtual 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.

5. The electronic device according to claim 1, characterized in that, During the query method for metrics executed by the processor, the second virtual table includes multiple fields and a second calculation method between the multiple fields; the real-time computing engine includes at least one message queue; each message queue corresponds to a specific field. The step of obtaining the second indicator value corresponding to each drill-down indicator in the current time period based on the second virtual table and the data in the real-time computing engine includes: Obtain the queue identifier of at least one target message queue corresponding to each field in the second virtual table; based on the queue identifier of the target message queue and the second calculation method, generate a calculation operator for obtaining the drill-down index from the real-time computing engine; Obtain a preset consumption strategy; the consumption strategy is any one of the following: starting consumption from the earliest data stored in the corresponding message queue, starting consumption from the latest data stored in the message queue, or starting consumption from data stored in the corresponding message queue at a preset time. Based on 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.

6. The electronic device according to claim 1, characterized in that, During the query method for the metric executed by the processor, prior to obtaining the first virtual table pre-created for the metric to be queried, the process further includes: Configure the first virtual table as follows: 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 the fields in the first virtual table.

7. The electronic device according to claim 1, characterized in that, During the query method for the metric executed by the processor, the process of obtaining a second virtual table pre-created for the metric to be queried includes, prior to: Configure the second virtual table as follows: Configure the data source, definition information, and data consumption strategy 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 a second calculation method between the fields in the first virtual table.

8. A method for querying an indicator, characterized in that, include: Obtain the query conditions for the indicator to be queried, which include the query time period, each drill-down indicator of the indicator to be queried, and the 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, wherein the current time period is the time period located in the current cycle and the historical time period is the time period located in at least one historical cycle, then a first virtual table and a second virtual table pre-created for the queried indicator 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. Based on the data in the first virtual table and the preset database, obtain the first indicator value of each drilling indicator corresponding to the historical time period; based on the data in the second virtual table and the real-time computing engine, obtain the second indicator value of each drilling indicator corresponding to the current time period. Based on the first aggregated 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.

9. The method according to claim 8, characterized in that, The first virtual table includes multiple fields and a first calculation method between the multiple fields; The step of 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 includes: If a preset view is queried and it is determined that at least one pre-calculation method included in the preset view contains various target pre-calculation methods, and the first calculation method is obtained after integration processing of the various target pre-calculation methods, then the target pre-calculation result obtained from the preset view based on each target pre-calculation method during the historical time period is obtained; 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 from the preset database in the previous historical period of the new current period, performs pre-calculation processing on the field values ​​of the previous historical period through the pre-calculation method to obtain the pre-calculation result, and stores the pre-calculation result in the preset view; The target pre-calculation results of each target pre-calculation method are integrated and processed to obtain the first indicator value of the drilling index corresponding to the historical time period.

10. The method according to claim 9, characterized in that, The query preset view then includes: If it is determined that none of the target pre-calculation results are present in at least one of the pre-calculation results contained in the preset view, then an SQL statement set is generated based on the multiple fields contained 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 the first indicator value of the drill-down indicator corresponding to the historical time period.

11. The method according to claim 10, characterized in that, The generated SQL statement set includes: Parse the first virtual table to obtain the table identifier of at least one target physical table, the type of at least one target physical table, and the connection relationship between at least one target physical table corresponding to each field in the first virtual 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.

12. The method according to claim 8, characterized in that, The second virtual table includes multiple fields and a second calculation method between the multiple fields; the real-time computing engine includes at least one message queue; each message queue corresponds to a specific field. The step of obtaining the second indicator value corresponding to each drill-down indicator in the current time period based on the second virtual table and the data in the real-time computing engine includes: Obtain the queue identifier of at least one target message queue corresponding to each field in the second virtual table; based on the queue identifier of the target message queue and the second calculation method, generate a calculation operator for obtaining the drill-down index from the real-time computing engine; Obtain a preset consumption strategy; the consumption strategy is any one of the following: starting consumption from the earliest data stored in the corresponding message queue, starting consumption from the latest data stored in the message queue, or starting consumption from data stored in the corresponding message queue at a preset time. Based on 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.

13. The method according to claim 8, characterized in that, Prior to obtaining the first virtual table pre-created for the metric to be queried, the process also includes: Configure the first virtual table as follows: 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 the fields in the first virtual table.

14. The method according to claim 8, characterized in that, The process includes retrieving a second virtual table pre-created for the metric to be queried, prior to which the following steps are also taken: Configure the second virtual table as follows: Configure the data source, definition information, and data consumption strategy 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 a second calculation method between the fields in the first virtual table.

15. A device for querying an indicator, characterized in that, include: The first acquisition module is used to acquire the query conditions of the indicator to be queried. The query conditions include the query time period, each drill-down indicator of the indicator to be queried, and the first aggregated metric of each drill-down indicator. The processing module is configured to, if it is determined that the query time period includes both the current time period and the historical time period, wherein the current time period is the time period located in the current cycle and the historical time period is the time period located in at least one historical cycle, then obtain a first virtual table and a second virtual table pre-created for the queried indicator; 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. The second acquisition module is used to obtain the first indicator value of each drill-down indicator in the historical time period based on the data in the first virtual table and the preset database; and to obtain the second indicator value of each drill-down indicator in the current time period based on the data in the second virtual table and the real-time computing engine. The aggregation module is used to aggregate the first indicator value and the second indicator value of each drill-down indicator based on 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.

16. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, performs the steps of the method as described in any one of claims 8 to 14.

Citation Information

Patent Citations

  • Data processing method and system, electronic equipment and readable storage medium

    CN115510113A

  • Batch flow integrated data processing method, device and equipment

    CN117743317A

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

    CN118394800A

  • Connecting real-time data sets to historical data

    US20230376481A1