Table data updating method and device

The table data update method of double writing and double partitioning solves the problems of data inconsistency and limited update caused by creation time partitioning in the existing technology, realizes real-time updating when the offline historical table data is not processed, and expands the update applicability. scenarios and ensure data consistency.

CN118626501APending Publication Date: 2024-09-10BEIJING WODONG TIANJUN INFORMATION TECH CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410822542.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-24
Publication Date
2024-09-10

AI Technical Summary

Technical Problem

The table data update method of existing dimension tables is based on creation time partition writing, which can easily lead to data inconsistency and update errors. The completion of offline historical table data processing is a prerequisite for update, which limits the applicable scenarios of the update.

Method used

Using the double-write and double-partition method, the table data of the current period is synchronously stored in the current period and the next period partition, including snapshots of historical table data, and the snapshots are replaced when the offline historical table data processing is completed to achieve offline historical table data and current Dual writing of real-time table data, allowing updates while pending processing is complete.

Benefits of technology

It avoids update errors caused by abnormal partition fields, expands the applicable scenarios for table data update, and ensures the consistency and real-time nature of data.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118626501A
    Figure CN118626501A
Patent Text Reader

Abstract

The invention discloses a table data updating method and device, and relates to the technical field of computers. According to one specific embodiment, the method comprises the steps that in response to a received table data summarization request, table data of a current time period are synchronously stored in a current time period partition and a next time period partition of a database respectively, and the current time period partition further comprises historical table data snapshots; in response to the received information that the processing of the offline historical table data of the current time period is completed, replacing the historical table data snapshot in the partition of the current time period with the offline historical table data of the current time period, storing the historical table data in the partition of the current time period, and storing the offline historical table data of the current time period in the partition of the next time period; and according to a received table data updating acquisition request, performing updating processing on each piece of table data stored in the partition in the current time period, and acquiring the updated table data. According to the embodiment, the influence on table data updating caused by partition field exception is avoided, and the application scene of table data updating is expanded.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a method and device for updating table data. Background Art

[0002] In the field of data processing, a dimension table is a table that records information related to a business dimension. It is mainly used to describe various dimensional information in the business, such as user account attributes, validity period of promotional activities, etc. Usually, the table data in the dimension table changes dynamically, and the table data in the dimension table needs to be continuously updated to obtain the latest and full dimension table data. The existing dimension table data update method mainly uses offline historical table data initialization and then superimposes the current incremental table data to update the entire dimension table data.

[0003] In the process of implementing the present invention, the inventors found that the prior art has the following problems:

[0004] Considering that the existing dimension table data update method mainly writes offline historical table data and current incremental data partitions into the database based on the creation time of the dimension table business row, if the value of the creation time is modified, it will lead to inconsistent table data content or even table data update errors; and considering that offline historical table data processing requires a certain amount of time, the premise of table data update is that the offline historical table data processing is completed, otherwise the table data cannot be updated, which limits the applicable scenarios of table data update. Summary of the invention

[0005] In view of this, an embodiment of the present invention provides a method and device for updating table data, which realizes the dual-write dual-partition table data update of offline historical table data and current real-time table data, avoids the impact of partition field abnormalities on table data update, and when the offline historical table data is not processed, in addition to the table data of the current time period, the current time period partition also has a snapshot of the historical table data, so that the table data can be updated smoothly, expanding the applicable scenarios of table data update.

[0006] To achieve the above object, according to a first aspect of an embodiment of the present invention, a method for updating table data is provided, comprising:

[0007] In response to receiving a table data aggregation request, the table data of the current period is synchronously stored in the current period partition and the next period partition of the database respectively, wherein the current period partition also includes a historical table data snapshot;

[0008] In response to receiving the information that the offline history table data of the current period has been processed, the history table data snapshot in the current period partition is replaced with the offline history table data of the current period, and stored in the current period partition, and the offline history table data of the current period is stored in the next period partition, so that the offline history table data of the current period and the table data of the current period are used as the history table data snapshot of the next period partition;

[0009] According to the received table data update acquisition request, each table data stored in the current time period partition is updated to acquire the updated table data.

[0010] Optionally, when the time of receiving the table data update acquisition request is earlier than the time of completion of offline historical table data processing for the current time period, the various table data stored in the current time period partition are updated, including: merging and updating the historical table data snapshot stored in the current time period partition and the table data for the current time period; when the time of receiving the table data update acquisition request is not earlier than the time of completion of offline historical table data processing for the current time period, the various table data stored in the current time period partition are updated, including: merging and updating the offline historical table data for the current time period stored in the current time period partition and the table data for the current time period.

[0011] Optionally, when the database is a column-based database, each table data stored in the current time period partition is updated to obtain the updated table data, including: using the table engine of the column-based database, according to preset fields, merging and updating each table data stored in the current time period partition to generate updated table data.

[0012] Optionally, the table data of the current period, the snapshot of the historical table data in the partition of the current period, and the data in the offline historical table data of the current period have a source field for data tracing.

[0013] Optionally, the method further includes: regularly clearing the data in the updated table data according to a preset data retention time.

[0014] Optionally, before synchronously storing the table data of the current time period into the current time period partition and the next time period partition of the database respectively, the method further includes: filtering the table data of the current time period according to a preset business filtering logic to obtain the table data valid for the current time period, so as to synchronously store the table data valid for the current time period into the current time period partition and the next time period partition respectively; or, before using the offline historical table data of the current time period to replace the historical table data snapshot in the current time period partition and storing it in the current time period partition, and before storing the offline historical table data of the current time period into the next time period partition, the method further includes: The method includes: filtering the offline history table data of the current time period according to the preset business filtering logic to obtain the offline valid history table data of the current time period; using the offline history table data of the current time period to replace the history table data snapshot in the current time period partition, storing it in the current time period partition, and storing the offline history table data of the current time period in the next time period partition, including: using the offline valid history table data of the current time period to replace the history table data snapshot in the current time period partition, storing it in the current time period partition, and storing the offline valid history table data of the current time period in the next time period partition.

[0015] According to a second aspect of an embodiment of the present invention, a method for updating table data is provided, comprising:

[0016] According to the received table data update acquisition request, the table data is data of multiple associated sub-tables, and for each associated sub-table, the table data is updated according to any method described in the first aspect of the embodiment of the present invention;

[0017] According to the association relationship between each of the associated sub-tables, an association operation is performed on the corresponding updated table data to obtain a response result of the table data update acquisition request.

[0018] According to a third aspect of an embodiment of the present invention, there is provided a device for updating table data, comprising:

[0019] The current table data partition storage module is used to synchronously store the table data of the current period into the current period partition and the next period partition of the database in response to receiving the table data summary request, wherein the current period partition also includes the historical table data snapshot;

[0020] The offline table data partition storage module is used to replace the historical table data snapshot in the current period partition with the offline historical table data of the current period in response to receiving the information that the offline historical table data of the current period has been processed, store it in the current period partition, and store the offline historical table data of the current period in the next period partition, so that the offline historical table data of the current period and the table data of the current period are used as the historical table data snapshot of the next period partition;

[0021] The update table data acquisition module updates the table data stored in the current time period partition according to the received table data update acquisition request, and acquires the updated table data.

[0022] According to a fourth aspect of an embodiment of the present invention, there is provided an electronic device for updating table data, including:

[0023] one or more processors;

[0024] a storage device for storing one or more programs,

[0025] When the one or more programs are executed by the one or more processors, the one or more processors implement the method provided in the first aspect of the embodiment of the present invention.

[0026] According to a fifth aspect of an embodiment of the present invention, there is provided a computer-readable medium having a computer program stored thereon, wherein when the program is executed by a processor, the method provided in the first aspect of the embodiment of the present invention is implemented.

[0027] An embodiment of the invention has the following advantages or beneficial effects: in response to receiving a table data aggregation request, the table data of the current period is synchronously stored in the current period partition and the next period partition of the database, and the current period partition also includes a snapshot of historical table data; in response to receiving information that the offline historical table data of the current period has been processed, the offline historical table data of the current period is used to replace the snapshot of historical table data in the current period partition, and stored in the current period partition, and the offline historical table data of the current period is stored in the next period partition, so that the offline historical table data of the current period and the table data of the current period are used as the snapshot of historical table data of the next period partition; according to the received table data update acquisition request, each table data stored in the current period partition is updated and processed to obtain the updated table data. The technical solution realizes a table data update method of dual-writing and dual-partitioning offline historical table data and current real-time table data, avoids the influence of partition field abnormality on table data update, and when the offline historical table data is not processed, in addition to the table data of the current period, there is also a snapshot of historical table data in the current period partition, so that the table data can be updated smoothly, which expands the applicable scenarios of table data update. BRIEF DESCRIPTION OF THE DRAWINGS

[0028] The accompanying drawings are used to better understand the present invention and do not constitute an improper limitation of the present invention.

[0029] Figure 1 is a schematic diagram of the main process of the method for updating table data according to an embodiment of the present invention;

[0030] Figure 2 It is a schematic diagram of the principle of the table data updating method according to an embodiment of the present invention;

[0031] Figure 3 is a schematic diagram of main modules of a device for updating table data according to an embodiment of the present invention;

[0032] Figure 4 is an exemplary system architecture diagram to which embodiments of the present invention may be applied;

[0033] Figure 5 It is a schematic diagram of the structure of a computer system of a terminal device or a server suitable for implementing an embodiment of the present invention. DETAILED DESCRIPTION

[0034] It should be noted that in the technical solution of the present invention, the collection / collection, update, analysis, use, transmission, storage and other aspects of user personal information involved are in compliance with the provisions of relevant laws and regulations, are used for legal and reasonable purposes, are not shared, leaked or sold outside of these legal uses, and are subject to supervision and management by national regulatory authorities. Necessary measures should be taken for user personal information to selectively block the use or access to personal information data to prevent illegal access to such personal information data, ensure that persons who have access to personal information data comply with the provisions of relevant laws and regulations, and ensure the security of user personal information. In addition, once these user personal information data are no longer needed, the risks should be minimized by limiting or even prohibiting data collection and / or deleting data.

[0035] The following is a description of exemplary embodiments of the present invention in conjunction with the accompanying drawings, including various details of the embodiments of the present invention to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, for clarity and conciseness, the description of well-known functions and structures is omitted in the following description.

[0036] Considering that the existing table data update method mainly writes offline historical table data and current incremental data partitions into the database based on the creation time of the dimension table business row, if the value of the creation time is modified, it will lead to inconsistent table data content or even table data update errors; and considering that offline historical table data processing requires a certain amount of time, the premise of table data update is that the offline historical table data processing is completed, otherwise the table data cannot be updated, which limits the applicable scenarios of table data update and cannot meet practical applications well.

[0037] In order to solve the above problems existing in the prior art, the present invention proposes a method for updating table data. Based on two partitions of the database (current time period partition and next time period partition), the table data of the current time period is stored in the current time period partition and the next time period partition respectively, wherein the current time period partition also contains a snapshot of historical table data; when the offline historical table data of the current time period is processed, the offline historical table data of the current time period is used to replace the snapshot of historical table data in the current time period partition, and stored in the current time period partition and the next time period partition, so as to update the table data according to the table data stored in the current time period partition. A table data update method for dual-writing and dual-partitioning offline historical table data and current real-time table data is implemented, which avoids the influence of abnormal partition fields on table data update, and when the offline historical table data is not processed, in addition to the table data of the current time period, there is also a snapshot of historical table data in the current time period partition, so that the table data can be updated smoothly, which expands the applicable scenarios of table data update.

[0038] In the introduction to the embodiments of the present invention, the terms and their meanings are as follows:

[0039] Flink CDC: It is a database-based log CDC (Change Data Capture) technology that implements integrated full and incremental reading capabilities.

[0040] JDBC sink: A method provided by Flink to submit data to the database in batches and at a scheduled time.

[0041] Spark - a fast, general-purpose, and scalable big data analytics engine.

[0042] Hive - a data warehouse tool based on Hadoop.

[0043] ClickHouse - a column-oriented database management system (DBMS) for online analytical processing (OLAP).

[0044] ReplacingMergeTree: It is a table engine in ClickHouse database, which is used to implement data insertion and update operations based on primary keys;

[0045] INNER JOIN: inner join, performs the join operation of two tables;

[0046] LEFT JOIN: Left join, based on the left table, performs the join operation of two tables;

[0047] TTL: Time-to-Live duration.

[0048] Figure 1 is a schematic diagram of the main process of the method for updating table data according to an embodiment of the present invention. Figure 1 As shown, the table data updating method according to the embodiment of the present invention includes the following steps S101 to S103.

[0049] Step S101 : in response to receiving a table data aggregation request, the table data of the current period is synchronously stored in the current period partition and the next period partition of the database respectively, wherein the current period partition also includes a historical table data snapshot.

[0050] Specifically, in order to solve the problems existing in the existing table data update, the embodiment of the present invention adopts the data update idea of ​​dual partition and dual write, and the collected table data of the current period is synchronously stored in the current period partition and the next period partition of the database respectively. Specifically, the table data of the current period is captured in real time through Flink CDC technology, and then Flink JDBC sink is used to synchronously write the table data of the current period to the current period partition and the next period partition pre-divided by the database, wherein the current period partition also contains the historical table data snapshot relative to the current period. It can be understood that at this time, the table data of the current period and the historical table data snapshot are stored in the current period partition, that is, the current period partition stores the latest data of the full dimension table of the current period.

[0051] In addition, it can be understood that the current time period partition and the next time period partition are defined as specified time intervals according to specific business needs. The time interval can be 12 hours, the current time period partition is 0:00-12:00, and the next time period partition is 12:00-24:00. It can also be two partitions with different time intervals. For example, 0:00-9:00 is defined as the current time period partition, and 9:00-24:00 is the next time period partition. The embodiment of the present invention preferably uses one day as the time interval, which is divided into the current day partition and the tomorrow partition.

[0052] According to one embodiment of the present invention, before synchronously storing the table data of the current time period into the current time period partition and the next time period partition of the database respectively, the method further includes: filtering the table data of the current time period according to a preset business filtering logic, and obtaining the table data valid for the current time period, so as to synchronously store the table data valid for the current time period into the current time period partition and the next time period partition respectively.

[0053] Specifically, considering that the update of table data involves a lot of data, in order to improve the update efficiency, before the table data of the current period is synchronously stored in the current period partition and the next period partition of the database, the business filtering logic is clarified according to business needs, and the business filtering logic is used to filter the effective business data of all table data in the current period to obtain the table data valid in the current period. For example, the attribute information of all users with the highest membership level is required, and the determination of the membership level is used as the business filtering logic to obtain the attribute information of all users with the highest level of membership. Then, the filtered table data valid in the current period is synchronously stored in the current period partition and the next period partition according to the above method.

[0054] According to another embodiment of the present invention, the table data of the current period and the data in the historical table data snapshot in the partition of the current period have a source field for data tracing.

[0055] Specifically, in order to facilitate debugging in development iterations and tracing the source when problems occur in updates, the embodiment of the present invention adds an additional source field data_source_flag to the table data of the current period and the data in the historical table data snapshot. This source field is mainly used to identify whether the data comes from data stored in real time in the current period or data stored after offline processing.

[0056] In addition, it can be understood that when the table data of the current time period or the table data valid for the current time period is synchronously stored in the current time period partition and the next time period partition of the database respectively, it is possible to verify whether the table data is successfully written to the database. If there is an exception, necessary exception handling and log recording can be performed according to the source field of the abnormal data to troubleshoot the problem.

[0057] Step S102, in response to receiving the information that the offline historical table data of the current time period has been processed, the offline historical table data of the current time period is used to replace the historical table data snapshot in the current time period partition, and stored in the current time period partition, and the offline historical table data of the current time period is stored in the next time period partition, so that the offline historical table data of the current time period and the table data of the current time period are used as the historical table data snapshot of the next time period partition.

[0058] Specifically, the offline historical table data of the current period is processed by the offline data warehouse, and after the processing is completed, the completion information is sent to the table data summary system of the dimension table. The table data summary system uses Spark to import the offline historical table data of the historical (T-1) partition in the offline Hive table into the current period partition, and replaces the historical table data snapshot with the offline historical table data, and stores it in the current period partition accordingly. Successively, the offline historical table data is also imported into the next period partition. It should be noted that in the process of importing table data into the corresponding partition, data verification, data type conversion, data cleaning, and format conversion operations are required to ensure the successful import of data in the Hive table.

[0059] The embodiment of the present invention defines the current time period partition as the T partition, and the next time period partition as the T+1 partition. Based on the above-mentioned operation of dual-writing the table data of the current time period and the offline historical table data of the current time period into the T partition and the T+1 partition, the offline historical table data of the current time period (offline T-1) and the table data of the current time period (real-time T) are stored in the T partition, that is, the T partition has complete and full dimension table information; accordingly, in the next current time period, the offline T-1 and real-time T stored in the T+1 partition constitute the historical table data snapshot of the next current time period.

[0060] The embodiment of the present invention uses a dual-area dual-write table data update method to temporarily retain the historical table data snapshot as a transitional data when the offline historical table data is not generated, so as to ensure that the current latest data of the full dimension table is always available in the T partition of the current period. It can be understood that the data content of the historical table data snapshot and the offline historical table data should be consistent in theory, but considering the different data sources, there may be some minor differences, so the historical table data snapshot is a transitional data when the offline historical table data is not generated, and the standard is still based on the offline historical table data.

[0061] According to an embodiment of the present invention, before using the offline historical table data of the current time period to replace the historical table data snapshot in the current time period partition, storing it in the current time period partition, and storing the offline historical table data of the current time period in the next time period partition, the method also includes: filtering the offline historical table data of the current time period according to a preset business filtering logic to obtain offline valid historical table data of the current time period; using the offline historical table data of the current time period to replace the historical table data snapshot in the current time period partition, storing it in the current time period partition, and storing the offline historical table data of the current time period in the next time period partition, including: using the offline valid historical table data of the current time period to replace the historical table data snapshot in the current time period partition, storing it in the current time period partition, and storing the offline valid historical table data of the current time period in the next time period partition.

[0062] Specifically, similar to the above, in order to improve the update efficiency, before using the offline history table data of the current period to replace the snapshot of the history table data in the partition of the current period, storing it in the partition of the current period, and storing the offline history table data of the current period in the partition of the next period, the business filtering logic is clarified according to business needs, and the business filtering logic is used to filter the effective business data of the offline history table data of the current period to obtain the offline effective history table data of the current period. Then, the filtered offline effective history table data is used to replace the snapshot of the history table data in the partition of the current period, and stored in the partition T of the current period, and at the same time or subsequently, the offline effective history table data of the current period is stored in the partition T+1 of the next period.

[0063] According to another embodiment of the present invention, the data in the offline history table data of the current period has a source field for data tracing.

[0064] Specifically, similar to the above, in order to facilitate debugging in development iterations and tracing when problems occur in updates, an additional source field data_source_flag is added to the offline historical table data of the current period to ensure that each data in the subsequently updated table data has a source field.

[0065] Step S103: According to the received table data update acquisition request, update processing is performed on each table data stored in the current time period partition to obtain updated table data.

[0066] Specifically, when a table data update acquisition request is received, the table data of the current period and the offline historical table data of the current period stored in the T partition of the current period are sorted, sorted, combined, and updated to obtain the updated full dimension table data at the current time.

[0067] According to one embodiment of the present invention, when the time of receiving the table data update acquisition request is earlier than the time of completing the processing of the offline historical table data of the current time period, the various table data stored in the current time period partition are updated, including: merging and updating the historical table data snapshot stored in the current time period partition and the table data of the current time period; when the time of receiving the table data update acquisition request is not earlier than the time of completing the processing of the offline historical table data of the current time period, the various table data stored in the current time period partition are updated, including: merging and updating the offline historical table data of the current time period stored in the current time period partition and the table data of the current time period.

[0068] Specifically, considering that the processing of offline historical table data takes time, it is inevitable that the time of receiving the table data update acquisition request is earlier than the time of completing the offline historical table data processing during the whole cycle of table data aggregation. For example, the offline data warehouse agrees to complete the offline instance table data processing at 6:00 a.m. every day. If the table data update acquisition request is received at 5:00, at this time, the current period T partition has the table data and the historical table data snapshot of the current period, then the table data (real-time T) of the current period and the historical table data snapshot are merged and updated to obtain the updated table data. Of course, in the case where the time of receiving the table data update acquisition request is not earlier than the time of completing the offline historical table data processing of the current period, at this time, the current period T partition has the offline historical table data (offline T-1) of the current period and the table data (real-time T) of the current period, and the offline T-1 and the real-time T are directly merged and updated to obtain the updated table data at this time.

[0069] In the embodiment of the present invention, the historical table data snapshot stored in the T partition of the current period is used to ensure that the table data can be updated smoothly no matter when a table data update acquisition request is received, and is no longer limited by whether the offline historical table data has been processed, thereby expanding the applicable scenarios of table data update.

[0070] According to another embodiment of the present invention, when the database is a column-based database, each table data stored in the current time period partition is updated to obtain the updated table data, including: using the table engine of the column-based database, according to preset fields, merging and updating each table data stored in the current time period partition to generate updated table data.

[0071] Specifically, the table data update method of the embodiment of the present invention is mainly based on the ClickHouse column database. When the table data of the current period and the offline historical table data are written to dual partitions, you can choose to use the batch insert function of ClickHouse (configure the number of data entries written in batches and the writing time interval) for batch merging to reduce network overhead and increase writing speed.

[0072] Furthermore, using ClickHouse's table engine ReplacingMergeTree, insert, sort, merge and update operations are performed on each table data according to the preset data modification time field modified_time. If the same primary key is found during the merge, the data with a larger value in the modified_time field will overwrite the data with a smaller value to achieve merge deduplication. The table engine ReplacingMergeTree maintains a version number for each row of data, which can be used to identify the update history of the table data, making it easier to perform version control. By using the Replacing MergeTree table engine and taking advantage of the features of ReplacingMergeTree, relevant update operations of table data can be easily implemented while maintaining the orderliness of table data, which is very useful for application scenarios that require frequent data updates and queries.

[0073] According to yet another embodiment of the present invention, the method further comprises: regularly clearing the data in the updated table data according to a preset data retention time.

[0074] Specifically, the embodiment of the present invention adopts a method of writing offline historical table data and table data of the current time period into two partitions respectively, so as to synchronize the latest full dimension table data to ClickHouse in real time. The embodiment of the present invention can set a shorter data retention time TTL as needed to regularly clean up the data in the updated table data, and flexibly control the length of time the data is retained in the dimension table. In the case where the current time period partition and the next time period partition of the embodiment of the present invention are the current partition and the tomorrow partition respectively, TTL is usually set to 3 to 7 days. In order to automatically delete expired data in a timely manner, free up storage space, and improve system performance, this is particularly important for scenarios with large-scale dimension tables and frequent updates, and can improve the resource utilization of the system.

[0075] Figure 2It is a schematic diagram of the principle of the table data update method of the embodiment of the present invention. The horizontal axis represents time, and the vertical axis represents partition. dt=T is used as the partition of the current period, and dt=T+1 is used as the partition of the next period. Looking at the direction of the horizontal axis of time, when a table data aggregation request is received, the table data of the current period, represented by real-time T in the figure, is synchronously stored in the dt=T partition and the dt=T+1 partition respectively, and the dt=T partition also contains the offline historical table data of the first two periods relative to the current period (offline T-2) and the table data of the previous period (real-time T-1), and the offline T-2 and real-time T-1 are snapshots of the historical table data of the current period. When the offline historical table data of the current period is processed, the offline historical table data (offline T-1) that has been processed is scheduled, and the offline T-1 is used to replace the offline T-2 and real-time T-1, and the offline T-1 is stored in the dt=T partition, and the offline T-1 is also stored in the dt=T+1 partition. At this time, the data aggregation of the double-write double partition is completed. Then, according to the received table data update acquisition request, the offline T-1 and real-time T currently stored in the dt=T partition are updated to obtain the updated table data. Of course, it is also possible that the time when the table data update acquisition request is received is earlier than the time when the offline T-1 processing of the current period is completed. In this case, it is necessary to merge and update the offline T-2 and real-time T-1 stored in the dt=T partition in the first column of the figure, and then merge and update the result of the merge and update processing with the real-time T stored therein to obtain the updated table data.

[0076] In addition, it can be seen from the figure that in the next current period, that is, T+1 in the figure, the table data of the current period T+1 (real-time T+1) will be synchronously stored in the current period dt=T+1 partition and the next period dt=T+2 partition according to the above method. Correspondingly, when the current period is T, the offline T-1 and real-time T stored in the dt=T+1 partition are used as the historical table data snapshot of the current period T+1.

[0077] The embodiment of the present invention adopts a dual-partition writing method for offline historical table data and table data of the current period, which can synchronize the latest full dimension table data to ClickHouse in real time. When a new field needs to be added to the dimension table, the dimension table structure can be directly modified online without the need to rebuild the entire dimension table as in the prior art. Because the table data update in the embodiment of the present invention is idempotent, it takes effect immediately after re-importing the table data of the newly added field, and does not affect normal online use during the period of adding the field, which makes it easier to iterate.

[0078] In addition, in the actual application of dimension tables, dimension tables are usually associated with fact tables. The table data updating method of the embodiment of the present invention can synchronize the latest full dimension table data to the ClickHouse database in real time. In the process of associating the dimension table and the fact table, there is no need to scan multiple partition data. It is only necessary to associate the updated dimension table corresponding to the latest partition. The association process with the fact table is simple and efficient.

[0079] Based on the above-mentioned table data updating method, the present invention also provides a method for updating table data that supports multiple associated sub-tables, including: upon receiving a table data update acquisition request, the table data is the data of multiple associated sub-tables, and for each associated sub-table, the table data is updated according to any method of the above-mentioned table data updating method; according to the association relationship between each of the associated sub-tables, the corresponding updated table data is associated, and a response result of the table data update acquisition request is obtained.

[0080] Specifically, in the scenario where multiple dimension tables are interrelated, multiple dimension tables are defined as multiple associated sub-tables. For each associated sub-table, the table data is updated according to the above table data update method, that is, the table data update method of a single dimension table, to obtain the updated table data corresponding to each associated sub-table. Then, according to the association relationship between each associated sub-table, the corresponding updated table data is associated. For the ClickHouse database, JOIN operations, such as INNER JOIN, LEFT JOIN, etc., can be used to perform association operations to obtain updated table data after multiple dimension tables are associated. It can be understood that before performing the above association operation, it is necessary to determine that all relevant table data have been successfully stored in the database, that is, the table data stored in the database is the latest data in the current period. Accordingly, after obtaining the updated table data after association, that is, the response result of the table data update acquisition request, it is best to verify the correctness of the updated table data obtained after association to verify whether it meets the expected needs. If an exception is found, trace the source field in the table data, handle the exception, and record the corresponding log.

[0081] The dual-write dual-partition table data update method of the embodiment of the present invention meets the needs of obtaining historical table data snapshots and current period real-time table data through current period partitioning and next period partitioning; and when business requirements change or new functional requirements arise, only a simple online modification of the dimension table is required to meet the requirements. By modifying the table structure online, the original data is retained when a new field is added, and the data of other existing fields will not be affected, which can ensure data integrity and business continuity, and can more efficiently update and iterate the table data of the dimension table, reducing system downtime and data migration costs, which is of great significance for quickly responding to business needs and maintaining system stability; at the same time, by directly setting the data retention time TTL value, there is no need to rely on field changes related to business time to determine whether the data is expired, which simplifies the operation process and reduces code complexity and error risks.

[0082] Figure 3 Schematic diagram of main modules of the apparatus for updating table data according to an embodiment of the present invention. Figure 3 As shown, the table data updating device 300 mainly includes a current table data partition storage module 301 , an offline table data partition storage module 302 and an updated table data acquisition module 303 .

[0083] The current table data partition storage module 301 is used to synchronously store the table data of the current period into the current period partition and the next period partition of the database in response to receiving the table data summary request, wherein the current period partition also includes the historical table data snapshot;

[0084] The offline table data partition storage module 302 is used to replace the snapshot of the historical table data in the partition of the current period with the offline historical table data of the current period in response to receiving the information that the processing of the offline historical table data of the current period is completed, store it in the partition of the current period, and store the offline historical table data of the current period in the partition of the next period, so that the offline historical table data of the current period and the table data of the current period are used as the snapshot of the historical table data of the partition of the next period;

[0085] The update table data acquisition module 303 updates the table data stored in the current time period partition according to the received table data update acquisition request, and acquires the updated table data.

[0086] According to an embodiment of the present invention, when the time of receiving the table data update acquisition request is earlier than the time of completing the processing of the offline historical table data of the current time period, the update table data acquisition module 303 is further used to: merge and update the historical table data snapshot stored in the current time period partition and the table data of the current time period; when the time of receiving the table data update acquisition request is not earlier than the time of completing the processing of the offline historical table data of the current time period, the update table data acquisition module 303 is further used to: merge and update the offline historical table data of the current time period stored in the current time period partition and the table data of the current time period.

[0087] According to another embodiment of the present invention, when the database is a column-based database, the update table data acquisition module 303 is further used to: use the table engine of the column-based database to merge and update the various table data stored in the current time period partition according to preset fields to generate updated table data.

[0088] According to another embodiment of the present invention, the table data of the current period, the historical table data snapshot in the partition of the current period, and the data in the offline historical table data of the current period have a source field for data tracing.

[0089] According to another embodiment of the present invention, the table data updating device 300 further includes a cleaning module (not shown in the figure) for regularly cleaning the data in the updated table data according to a preset data retention time.

[0090] According to another embodiment of the present invention, the table data updating device 300 further includes a data filtering module (not shown in the figure), which is used to: before synchronously storing the table data of the current time period into the current time period partition and the next time period partition of the database respectively, filter the table data of the current time period according to the preset business filtering logic to obtain the table data valid for the current time period, so as to synchronously store the table data valid for the current time period into the current time period partition and the next time period partition respectively; or, before replacing the historical table data snapshot in the current time period partition with the offline historical table data of the current time period, storing it in the current time period partition, and storing the offline historical table data of the current time period into the next time period partition, filter the offline historical table data of the current time period according to the preset business filtering logic to obtain the offline valid historical table data of the current time period; the offline table data partition storage module 302 is further used to: replace the historical table data snapshot in the current time period partition with the offline valid historical table data of the current time period, store it in the current time period partition, and store the offline valid historical table data of the current time period into the next time period partition.

[0091] Figure 4 is an exemplary system architecture diagram to which embodiments of the present invention can be applied.

[0092] like Figure 4 As shown, system architecture 400 may include terminal devices 401, 402, 403, network 404 and server 405. Network 404 is used to provide a medium for communication links between terminal devices 401, 402, 403 and server 405. Network 404 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.

[0093] Users can use terminal devices 401, 402, 403 to interact with server 405 through network 404 to receive or send messages, etc. Terminal devices 401, 402, 403 can be installed with various communication client applications, such as table data update applications, etc. (only for example).

[0094] The terminal devices 401 , 402 , and 403 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, and desktop computers.

[0095] The server 405 may be a server providing various services, such as a background management server (for example only) that supports table data updates performed by users using terminal devices 401, 402, and 403. In response to receiving a table data aggregation request, the background management server may synchronously store the table data of the current period in the current period partition and the next period partition of the database, respectively, wherein the current period partition also includes a snapshot of historical table data; in response to receiving information that the offline historical table data of the current period has been processed, the offline historical table data of the current period is used to replace the snapshot of historical table data in the current period partition, and store it in the current period partition, and the offline historical table data of the current period is stored in the next period partition, so that the offline historical table data of the current period and the table data of the current period are used as the snapshot of historical table data of the next period partition; according to the received table data update acquisition request, the table data stored in the current period partition is updated, the updated table data is acquired, and the processing result (for example, the updated table data, etc. - for example only) is fed back to the terminal device.

[0096] It should be noted that the table data updating method provided in the embodiment of the present invention is generally executed by the server 405 , and accordingly, the table data updating device is generally disposed in the server 405 .

[0097] It should be understood that Figure 4The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to the implementation requirements.

[0098] Reference below Figure 5 , which shows a schematic diagram of the structure of a computer system of a terminal device or a server suitable for implementing an embodiment of the present invention. Figure 5 The terminal device or server shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.

[0099] like Figure 5 As shown, the computer system 500 includes a central processing unit (CPU) 501, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 502 or a program loaded from a storage part 508 into a random access memory (RAM) 503. In the RAM 503, various programs and data required for the operation of the system 500 are also stored. The CPU 501, the ROM 502, and the RAM 503 are connected to each other via a bus 504. An input / output (I / O) interface 505 is also connected to the bus 504.

[0100] The following components are connected to the I / O interface 505: an input section 506 including a keyboard, a mouse, etc.; an output section 507 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 508 including a hard disk, etc.; and a communication section 509 including a network interface card such as a LAN card, a modem, etc. The communication section 509 performs communication processing via a network such as the Internet. A drive 510 is also connected to the I / O interface 505 as needed. A removable medium 511, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 510 as needed, so that a computer program read therefrom is installed into the storage section 508 as needed.

[0101] In particular, according to the embodiments disclosed in the present invention, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present invention include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 509, and / or installed from the removable medium 511. When the computer program is executed by the central processing unit (CPU) 501, the above-mentioned functions defined in the system of the present invention are executed.

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

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

[0104] The units involved in the embodiments of the present invention may be implemented by software or hardware. The units described may also be set in a processor, for example, it may be described as: a processor includes: a current table data partition storage module, an offline table data partition storage module and an update table data acquisition module.

[0105] Among them, the names of these modules do not constitute a limitation on the modules themselves in certain cases. For example, the update table data acquisition module can also be described as "a module used to update the various table data stored in the current time period partition according to the received table data update acquisition request, and obtain the updated table data."

[0106] On the other hand, the present invention also provides a computer-readable medium, which may be included in the device described in the embodiment; or may exist independently and not be assembled into the device. The computer-readable medium carries one or more programs, and when the one or more programs are executed by a device, the device includes: in response to receiving a table data aggregation request, synchronously storing the table data of the current period into the current period partition and the next period partition of the database, wherein the current period partition also includes a historical table data snapshot; in response to receiving information that the offline historical table data of the current period has been processed, using the offline historical table data of the current period to replace the historical table data snapshot in the current period partition, storing it in the current period partition, and storing the offline historical table data of the current period in the next period partition, so that the offline historical table data of the current period and the table data of the current period are used as the historical table data snapshot of the next period partition; according to the received table data update acquisition request, updating the various table data stored in the current period partition to obtain the updated table data.

[0107] The technical solution according to the embodiment of the present invention has the following advantages or beneficial effects: in response to receiving a table data aggregation request, the table data of the current period is synchronously stored in the current period partition and the next period partition of the database, and the current period partition also includes a snapshot of historical table data; in response to receiving information that the offline historical table data of the current period has been processed, the offline historical table data of the current period is used to replace the snapshot of historical table data in the current period partition, and the data is stored in the current period partition, and the offline historical table data of the current period is stored in the next period partition, so that the offline historical table data of the current period and the table data of the current period are used as the snapshot of historical table data of the next period partition; according to the received table data update acquisition request, each table data stored in the current period partition is updated and processed to obtain the updated table data. The technical solution realizes a table data update method for dual-writing and dual-partitioning offline historical table data and current real-time table data, avoids the influence of abnormal partition fields on table data update, and when the offline historical table data is not processed, in addition to the table data of the current period, there is also a snapshot of historical table data in the current period partition, so that the table data can be updated smoothly, which expands the applicable scenarios of table data update.

[0108] The specific implementation methods described herein do not constitute limitations on the scope of protection of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may occur depending on design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention shall be included in the scope of protection of the present invention.

Claims

1. A method for updating table data, characterized in that: include: In response to receiving a table data aggregation request, the table data of the current period is synchronously stored in the current period partition and the next period partition of the database respectively, wherein the current period partition also includes a historical table data snapshot; In response to receiving the information that the offline history table data of the current period has been processed, the history table data snapshot in the current period partition is replaced with the offline history table data of the current period, and stored in the current period partition, and the offline history table data of the current period is stored in the next period partition, so that the offline history table data of the current period and the table data of the current period are used as the history table data snapshot of the next period partition; According to the received table data update acquisition request, each table data stored in the current time period partition is updated to acquire the updated table data.

2. The method according to claim 1, characterized in that In the case that the time of receiving the table data update acquisition request is earlier than the time of completing the offline historical table data processing in the current period, Performing an update process on each table data stored in the current time period partition, including: merging and updating the historical table data snapshot stored in the current time period partition and the table data of the current time period; If the time of receiving the table data update acquisition request is not earlier than the time of completing the offline historical table data processing in the current period, The updating process is performed on each table data stored in the current time period partition, including: merging and updating the offline historical table data of the current time period stored in the current time period partition and the table data of the current time period.

3. The method according to claim 1, characterized in that In the case where the database is a column-based database, Updating each table data stored in the current time period partition to obtain updated table data includes: Using the table engine of the column-based database, the various table data stored in the current time period partition are merged and updated according to preset fields to generate updated table data.

4. The method according to claim 1, characterized in that: The table data of the current period, the historical table data snapshot in the partition of the current period, and the data in the offline historical table data of the current period have a source field for data tracing.

5. The method according to claim 1, characterized in that The method further comprises: According to the preset data retention time, the data in the updated table data is cleaned up regularly.

6. The method according to claim 1, characterized in that Before synchronously storing the table data of the current time period in the current time period partition and the next time period partition of the database respectively, the method further includes: According to the preset business filtering logic, the table data of the current time period is filtered to obtain the table data valid for the current time period, so as to synchronously store the table data valid for the current time period into the current time period partition and the next time period partition respectively; Alternatively, before replacing the snapshot of the historical table data in the current period partition with the offline historical table data of the current period and storing it in the current period partition, and before storing the offline historical table data of the current period in the next period partition, the method further includes: According to the preset business filtering logic, the offline history table data of the current period is filtered to obtain the offline valid history table data of the current period; Using the offline historical table data of the current time period to replace the historical table data snapshot in the current time period partition, storing it in the current time period partition, and storing the offline historical table data of the current time period in the next time period partition, including: using the offline valid historical table data of the current time period to replace the historical table data snapshot in the current time period partition, storing it in the current time period partition, and storing the offline valid historical table data of the current time period in the next time period partition.

7. A method for updating table data, characterized in that: include: Upon receiving a request for updating table data, the table data is data of multiple associated sub-tables, and for each associated sub-table, the table data is updated according to any method described in claims 1 to 6; According to the association relationship between each of the associated sub-tables, an association operation is performed on the corresponding updated table data to obtain a response result of the table data update acquisition request.

8. A device for updating table data, characterized in that: include: The current table data partition storage module is used to synchronously store the table data of the current period into the current period partition and the next period partition of the database in response to receiving the table data summary request, wherein the current period partition also includes the historical table data snapshot; The offline table data partition storage module is used to replace the historical table data snapshot in the current period partition with the offline historical table data of the current period in response to receiving the information that the offline historical table data of the current period has been processed, store it in the current period partition, and store the offline historical table data of the current period in the next period partition, so that the offline historical table data of the current period and the table data of the current period are used as the historical table data snapshot of the next period partition; The update table data acquisition module updates the table data stored in the current time period partition according to the received table data update acquisition request, and acquires the updated table data.

9. A mobile electronic device terminal, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 7.

10. A computer readable medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.