Data table processing method, device and equipment
Through the automated data cleaning method, metadata information is used to automatically generate cleaning tasks, which solves the inefficiency problem caused by manual configuration in the existing technology and achieves efficient data cleaning and cost saving.
Patent Information
- Application Number
- CN202011183142.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2019-04-28
- Publication Date
- 2024-08-23
- Estimated Expiration
- 2039-04-28
AI Technical Summary
In the existing technology, the data cleaning process requires manual configuration of cleaning tasks for each data table, resulting in low efficiency. Cleaning tasks for multiple data tables cannot be configured in batches at the same time, resulting in high processing efficiency and labor costs.
By sending the metadata information of the target data table in the database to the data cleaning equipment, the data is automatically copied to the intermediate table in the data warehouse, and cleaning tasks are automatically generated based on the metadata information to realize the automated data cleaning process.
It greatly shortens the time required for the cleaning process, improves processing efficiency, reduces the need for developers, saves labor costs, and supports batch cleaning of multiple data tables.
Smart Images

Figure CN112199366B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data processing technology, and in particular to a data table processing method, device and equipment. Background Art
[0002] At present, big data has received widespread attention. Through the analysis of big data, a lot of valuable information can be obtained. However, due to various influences in the data recording and management process, various data in big data inevitably have various quality problems, such as data loss, data duplication, data non-compliance, data incompleteness, data expiration, etc. There is a positive correlation between the value of big data and data quality. Therefore, in order to mine high-value information from big data, it is necessary to perform necessary processing on big data to improve the data quality of big data.
[0003] Data cleaning is one of the methods to improve the data quality of big data. In the related art, the process of data cleaning is: for each data table in the original database, manually configure the cleaning task of the data table, write the cleaning task into the manually written SQL script corresponding to the original data table through the Structured Query Language (SQL) statement, and then run the corresponding SQL script for each table to generate a standard table and store it in the original database. In this technology, the data cleaning process requires manual configuration of the cleaning task of each data table, which is time-consuming and therefore inefficient. Summary of the invention
[0004] In order to overcome the problems existing in the related art, the present invention provides a data table processing method, device and equipment.
[0005] According to a first aspect of an embodiment of the present invention, a data table processing method is provided, the method comprising:
[0006] Sending target metadata information of a target data table in a specified database to a data cleaning device so that the data cleaning device copies the content of the target data table to an intermediate table in a data warehouse according to the target metadata information; the target metadata information includes table field specified attributes;
[0007] After the copying is completed, a metadata modification instruction is sent to the data cleaning device, so that the data cleaning device modifies the table field specified attribute in the metadata information of the intermediate table according to the metadata modification instruction;
[0008] After the modification is completed, a metadata confirmation instruction is sent to the data cleaning device so that the data cleaning device confirms the metadata information of the intermediate table according to the metadata confirmation instruction.
[0009] According to a second aspect of an embodiment of the present invention, a data table processing device is provided, the device comprising:
[0010] A metadata information sending module, used to send target metadata information of a target data table in a specified database to a data cleaning device, so that the data cleaning device can copy the content of the target data table to an intermediate table in a data warehouse according to the target metadata information; the target metadata information includes table field specified attributes;
[0011] A metadata modification module, configured to send a metadata modification instruction to the data cleaning device after the copying is completed, so that the data cleaning device modifies a table field specified attribute in the metadata information of the intermediate table according to the metadata modification instruction;
[0012] The metadata confirmation module is used to send a metadata confirmation instruction to the data cleaning device after the modification is completed, so that the data cleaning device confirms the metadata information of the intermediate table according to the metadata confirmation instruction.
[0013] According to a third aspect of an embodiment of the present invention, there is provided a data table processing device, comprising a processor and a memory for storing executable instructions of the processor;
[0014] The processor is configured to:
[0015] Sending target metadata information of a target data table in a specified database to a data cleaning device so that the data cleaning device copies the content of the target data table to an intermediate table in a data warehouse according to the target metadata information; the target metadata information includes table field specified attributes;
[0016] After the copying is completed, a metadata modification instruction is sent to the data cleaning device, so that the data cleaning device modifies the table field specified attribute in the metadata information of the intermediate table according to the metadata modification instruction;
[0017] After the modification is completed, a metadata confirmation instruction is sent to the data cleaning device so that the data cleaning device confirms the metadata information of the intermediate table according to the metadata confirmation instruction.
[0018] The technical solution provided by the embodiment of the present invention may have the following beneficial effects:
[0019] The data table processing method provided by the embodiment of the present invention sends target metadata information of a target data table in a specified database to a data cleaning device, so that the data cleaning device copies the content of the target data table to an intermediate table in a data warehouse according to the target metadata information. After the copying is completed, a metadata modification instruction is sent to the data cleaning device, so that the data cleaning device modifies the table field specified attribute in the metadata information of the intermediate table according to the metadata modification instruction. After the modification is completed, a metadata confirmation instruction is sent to the data cleaning device, so that the data cleaning device confirms the metadata information of the intermediate table according to the metadata confirmation instruction. The primary key column of the intermediate table can be modified in the data warehouse to meet the needs of the same data table in different business scenarios.
[0020] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present specification. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the specification and, together with the description, serve to explain the principles of the specification.
[0022] Figure 1 This is an example diagram of an application scenario of the data cleaning method provided by an embodiment of the present invention.
[0023] Figure 2 It is a flowchart of a data cleaning method provided by an embodiment of the present invention.
[0024] Figure 3 It is a functional block diagram of a data cleaning device provided by an embodiment of the present invention.
[0025] Figure 4 It is a hardware structure diagram of the data cleaning device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0026] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present invention. Instead, they are merely examples of devices and methods consistent with some aspects of the embodiments of the present invention as detailed in the appended claims.
[0027] The terms used in the embodiments of the present invention are only for the purpose of describing specific embodiments of the present invention, and are not intended to limit the embodiments of the present invention. The singular forms of "a", "said" and "the" used in the embodiments of the present invention and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used herein refers to and includes any or all possible combinations of one or more associated listed items.
[0028] It should be understood that although the terms first, second, third, etc. may be used to describe various information in embodiments of the present invention, these information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of embodiments of the present invention, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".
[0029] Big data has important application value in all aspects. Corporate customers will use the analysis results of big data to make decisions, and these decisions can assist enterprises in adjusting their marketing strategies; ordinary consumers' demand for big data is mainly reflected in the ability to search for information on demand and provide friendly and reliable information recommendations, followed by providing high-level services; for a harmonious society, big data can bring a new lifestyle - smart city. The construction of a smart city is a complex system project, and big data will provide data support for it.
[0030] In order to obtain high-value information from big data, it is necessary to govern big data and improve its data quality. Data cleaning is one of the ways to govern big data.
[0031] Data cleaning refers to discovering and correcting identifiable data errors in a data table. Data cleaning can include checking data consistency, processing invalid values and missing values, etc. The data in a data warehouse is a collection of data for a certain subject. These data are extracted from multiple business systems and contain historical data. It is inevitable that some data are erroneous data and some data conflict with each other. These erroneous or conflicting data do not meet the requirements and are called "dirty data". The task of data cleaning is to filter out data that does not meet the requirements, put the data that meets the requirements in a standard table and return it to the original database for storage. Data that does not meet the requirements mainly includes three categories: incomplete data, erroneous data, and duplicate data.
[0032] At present, the data of many governments, institutions, and enterprises are still stored in traditional transactional databases, such as Mysql database, Oracle database, Pgsql database, etc. In the related technology, when performing data cleaning, a data warehouse is built directly on the original database in the form of SQL scripts. On the one hand, this will reduce the performance of the original database, and on the other hand, it is not convenient for systematic maintenance and tracking of data. In addition, since developers are required to manually configure cleaning tasks for each data table, and in most cases developers must constantly try to clearly know which cleaning operations need to be performed on this data table, the processing efficiency is very low. In addition, since the data tables are different, the corresponding cleaning tasks are also different, so the cleaning tasks can only be configured for each table separately, and it is impossible to batch configure cleaning tasks for multiple data tables at the same time, which further reduces the processing efficiency.
[0033] In actual applications, the amount of data that needs to be processed is very huge. The objects to be cleaned are often tens of thousands of tables, hundreds of thousands of partitions, and hundreds of TB of data. If such a large amount of data is processed using relevant technologies, a considerable number of developers are required, and the labor cost is very high.
[0034] The embodiment of the present invention provides a data cleaning method that can automatically generate cleaning tasks according to metadata information of a data table. There is no need to manually configure cleaning tasks, and the entire cleaning process is automated, which greatly shortens the time required for the cleaning process and improves processing efficiency. In addition, since the cleaning process does not require human participation, the demand for developers can be reduced, thereby saving labor costs.
[0035] Figure 1 is an example diagram of an application scenario of the data cleaning method provided by an embodiment of the present invention. Figure 1 , the server A is provided with an original database 1, and the server B is used to create a data warehouse, for example, using Hive (a data warehouse tool based on Hadoop) to create a data warehouse, copying the data table in the original database 1 to the data warehouse, and performing a cleaning operation on the table data in the data warehouse to generate a standard table and / or a problem table. The standard table is used to store data that meets the requirements and / or data that does not meet the requirements (also referred to as problem data in this article), and the problem table is used to store problem data.
[0036] Server B can use the data cleaning method provided in the embodiment of the present invention to clean data. Before cleaning, the following contents are pre-configured in server B:
[0037] 1. Data source connection information (address, user name, password, etc. of the device where the data source is located, for example Figure 1If the data source is the original database 1, the data source connection information is the address of server A, the user name and password for accessing the original database 1).
[0038] 2. The correspondence between table fields and standard data elements; the correspondence between standard data elements and cleaning rules; the correspondence between table fields and specified attributes; the correspondence between attributes and cleaning rules.
[0039] According to the first configuration content mentioned above, server B can access the original database 1 to extract metadata information of the data table from the original database 1 and copy the content of the data table to the local data warehouse of server B.
[0040] According to the second configuration content above, server B can automatically generate a cleaning task corresponding to the data table according to the extracted metadata information, so that server B automatically performs a cleaning operation on the data table in the local data warehouse according to the generated cleaning task.
[0041] The data cleaning method provided by the present invention is described in detail below through examples.
[0042] Figure 2 FIG. 1 is a flowchart of a data cleaning method provided by an embodiment of the present invention. Figure 2 As shown, the data cleaning method may include:
[0043] S201, extracting target metadata information of a target data table from a designated database, and copying the content of the target data table to an intermediate table in a data warehouse.
[0044] S202: Determine a target cleaning task of a target data table according to target metadata information, where the target cleaning task includes at least one cleaning rule.
[0045] S203, performing a cleaning operation on the intermediate table according to each cleaning rule in the target cleaning task to obtain a target standard table, wherein the target standard table at least includes data in the target data table that meets the requirements.
[0046] S204, sending the target standard table to the device where the designated database is located, so that the device stores the target standard table in the designated database.
[0047] The data cleaning method of the embodiment of the present invention can be applied to the aforementioned server B.
[0048] In step S201, the metadata information may include general metadata information, such as the table name, field name, field description, etc. of the data table, and may also include table field specified attributes, such as whether the field is a primary key, whether the field can be empty, etc.
[0049] The metadata information of each data table includes general metadata information, but not necessarily table field specified attributes. If one or more fields in a data table have specified attributes, the metadata information of the data table includes table field specified attributes; if all fields in a data table do not have specified attributes, the metadata information of the data table does not include table field specified attributes.
[0050] Here we take an example to illustrate the metadata information. Table 1 is a user table, and the content of Table 1 is as follows:
[0051] Table 1 User table
[0052] User ID number Username User age xxxxxxxxxxxxxxxxx1 Zhang San 25 xxxxxxxxxxxxxxxxx2 Li Si 36 …… …… ……
[0053] The metadata information of Table 1 is as follows:
[0054] Table name: user table;
[0055] Field name: User ID number; Type: String; Length: 0-18;
[0056] Field name: User name; Type: String; Length: 0-20;
[0057] Field name: User age; Type: String; Length: 0-20.
[0058] In an exemplary implementation process, in step S201, extracting target metadata information of a target data table from a specified database may include: calling a Java Database Connectivity (JDBC) interface to establish a connection with the specified database according to the connection information of the specified database configured by the user; calling the DatabaseMetaData interface provided by the JDBC driver package to query the columns of the target data table and obtain the table name, field name, field description, and field specified attributes of the target data table.
[0059] For example, field-specified properties may include: whether it is a primary key, whether the field can be empty, etc.
[0060] In an exemplary implementation process, in step S201, copying the content of the target data table to the intermediate table in the data warehouse may include:
[0061] According to the target metadata information, use the data warehouse tool to locally create an intermediate database with the same name as the designated database where the target data table is located, and create an intermediate table with the same table name and table structure as the target data table in the intermediate database;
[0062] Read the content data stored in the target data table, and write the read content data into the intermediate table.
[0063] The data warehouse tool may be Hive.
[0064] It should be noted that for all data tables in an original database, only one intermediate database needs to be created.
[0065] After all the contents of the target data table are copied to the intermediate table, the metadata information of the intermediate table is also stored locally (for example, in the aforementioned server B). When the metadata information does not include table field specified attributes, the metadata information of the intermediate table is exactly the same as the metadata information of the target data table. When the metadata information includes table field specified attributes, if the user has not modified the table field specified attributes of the intermediate table, the metadata information of the intermediate table is still exactly the same as the metadata information of the target data table; if the user has not modified the table field specified attributes of the intermediate table, the general metadata information in the metadata information of the intermediate table is the same as the general metadata information in the metadata information of the target data table, and the table field specified attributes in the metadata information of the intermediate table are different from the table field specified attributes in the metadata information of the target data table.
[0066] In the data cleaning device (such as the aforementioned server B), the general metadata information of the table and the table field specified attributes can be stored separately. The data cleaning device stores the general metadata information of the target data table, the general metadata information of the intermediate table, the table field specified attributes of the target data table, and the table field specified attributes of the intermediate table. Among them, the table field specified attributes are stored in the corresponding relationship between the table field and the specified attributes.
[0067] In an exemplary implementation process, after the content of the target data table is copied to the intermediate table in the data warehouse, the metadata information can also be confirmed according to the user's metadata confirmation instruction. At this time, the user has not modified the table field specified attribute of the table.
[0068] In an exemplary implementation process, after the contents of the target data table are copied to the intermediate table in the data warehouse, the table field specified attributes in the metadata information of the intermediate table can also be modified according to the user's metadata modification instructions; and after the modification, the metadata is confirmed according to the user's metadata confirmation instructions.
[0069] In many traditional transactional databases, many data tables use auto-increment columns as primary keys. These primary keys themselves have no business significance or value. Non-primary key fields in the data table, such as ID number, taxpayer number, invoice number, etc., are the master data in the industry. At this time, users can modify the primary key column of the intermediate table in the data warehouse according to this example. In special cases, when an original data table is referenced in different modeling operations, the fields used as primary keys are different. Therefore, a scenario identifier can be added to the primary key configuration. The scenario identifier is used to distinguish different application scenarios (GroupId).
[0070] In addition to the primary key, users can also set the specified columns of the intermediate table to be non-null through metadata modification instructions.
[0071] In an exemplary implementation process, reading the content data stored in the target data table and writing the read content data into the intermediate table may include: extracting the data in the target data table through a Java naming interface (JDBC Data Source), and importing the extracted data into the intermediate table through a Hive text insert (HiveContext Insert Into) SQL statement. The function of copying data can be implemented using a Spark application (App).
[0072] In step S202 , each data table corresponds to a cleaning task, and different data tables correspond to different cleaning tasks.
[0073] A cleaning task includes at least one cleaning rule, which is used to indicate the operation mode of cleaning the data table.
[0074] For example, the cleaning rules may be non-numeric value filtering rules, date standardization rules, value range filtering rules, and the like.
[0075] In an exemplary implementation process, step S202 may include:
[0076] From the established correspondence between table fields and standard data elements, find the target data elements that match the fields in the target metadata information;
[0077] Finding a first cleaning rule matching the target data element from the established correspondence between the standard data element and the cleaning rule;
[0078] A cleaning task is generated according to the first cleaning rule.
[0079] Data elements can be industry standard data elements stipulated by the state, or they can be proprietary data elements defined by enterprises or government agencies based on historical data and business scenarios. Data elements define the following requirements that fields should meet: data type, data format, value range, etc. These requirements are ultimately parsed into various standardized cleaning rules through the correspondence between standard data elements and cleaning rules.
[0080] For example, the metadata information in Table 1 above includes three fields: user ID number, user name, and user age. Assume that the corresponding relationship between the table fields and the standard data elements is shown in Table 2:
[0081] Table 2 Correspondence between table fields and standard data elements
[0082] Table fields Standard data element User ID number ID number Username String length User age Maximum and minimum values …… ……
[0083] It can be found from Table 2 that the standard data element corresponding to the field "User ID Number" is "ID Number", the standard data element corresponding to the field "User Name" is "String Length", and the standard data element corresponding to the field "User Age" is "Maximum and Minimum Values".
[0084] It is assumed that the correspondence between standard data elements and cleaning rules is shown in Table 3.
[0085] Table 3 Correspondence between standard data elements and cleaning rules
[0086]
[0087]
[0088] It can be found from Table 3 that the cleaning rules corresponding to the standard data element "ID number" are "ID number 15-digit to 18-digit rule" and "ID number legality filtering rule", the cleaning rule corresponding to the standard data element "string length" is "string length filtering", and the cleaning rule corresponding to the standard data element "maximum and minimum values" is "value range filtering rule".
[0089] The cleaning task corresponding to Table 1 includes four first cleaning rules: the rule of converting 15 digits of the ID card to 18 digits, the rule of filtering the legality of the ID card, the rule of filtering the string length, and the rule of filtering the value range.
[0090] Cleaning rules can include two types: filtering rules and standardization rules. For example, standardization rules include date standardization rules, synonym standardization rules, ID card standardization rules, etc.
[0091] In an exemplary implementation process, the target metadata information includes table field specified attributes, and step S202 may also include:
[0092] From the established correspondence between table fields and designated attributes, find the target attributes that match the fields in the target metadata information;
[0093] Finding a second cleaning rule matching the target attribute from the established correspondence between the attribute and the cleaning rule;
[0094] Generating a target cleaning task for a target data table according to the first cleaning rule includes: generating a target cleaning task for the target data table according to the first cleaning rule and the second cleaning rule.
[0095] For example, assume that the correspondence between the table fields and the specified attributes is as shown in Table 4.
[0096] Table 4 Correspondence between table fields and specified attributes
[0097] Table fields Specifying properties User ID number Primary key field Username Can the value be empty? User age none …… ……
[0098] From Table 4, we can find that the designated attribute corresponding to the field "User ID Number" in Table 1 is "Primary Key Field", and the designated attribute corresponding to the field "User Name" in Table 1 is "Whether the value can be empty". That is, there are two target attributes in Table 1: primary key field and whether the value can be empty.
[0099] The correspondence between the assumed attributes and the cleaning rules is shown in Table 5.
[0100] Table 5 Correspondence between attributes and cleaning rules
[0101]
[0102] It can be found from Table 5 that the cleaning rule corresponding to the attribute "primary key field" is the "de-duplication rule", and the cleaning rule corresponding to the attribute "whether the value can be empty" is the "empty value filtering rule".
[0103] The cleaning task corresponding to Table 1 also includes two second cleaning rules: a deduplication rule and a null value filtering rule.
[0104] In this way, the cleaning task corresponding to Table 1 finally includes 6 cleaning rules: ID card 15-digit to 18-digit rule, ID card legitimacy filtering rule, string length filtering, value range filtering rule, deduplication rule and null value filtering rule.
[0105] It can be seen that in step S202, the cleaning rules in the cleaning task are automatically obtained based on the extracted metadata information. There is no need for the user to drag different cleaning rules in the human-computer interaction interface or configure the cleaning task through SQL commands, so that the entire cleaning process can be automated and multiple data tables can be cleaned in batches, which is very flexible.
[0106] It should be noted that the above established correspondence between table fields and specified attributes refers to the correspondence between table fields and specified attributes of the intermediate table. In the case where the user modifies the specified attributes of the table fields of the intermediate table, the above established correspondence between table fields and specified attributes refers to the modified correspondence between the table fields and specified attributes.
[0107] Therefore, in an exemplary implementation process, before searching for target attributes matching each field in the target metadata information from the established correspondence between the table fields and the specified attributes, the method further includes:
[0108] Receiving attribute modification information of a specified field in the target metadata information, wherein the attribute modification information is used to indicate that a specified attribute of the specified field is modified to a specified attribute;
[0109] Modify the specified attribute of the specified field in the intermediate table according to the attribute modification information;
[0110] According to the modification of the designated attribute of the designated field, the corresponding relationship between the table field corresponding to the intermediate table and the designated attribute is updated;
[0111] The step of searching for target attributes matching each field in the target metadata information from the established correspondence between the table fields and the designated attributes includes searching for target attributes matching each field in the target metadata information from the updated correspondence between the table fields and the designated attributes.
[0112] In step S203, cleaning is performed on the intermediate table in the data warehouse. The content of the intermediate table is the same as the target data table. Therefore, performing a cleaning operation on the intermediate table is equivalent to performing a cleaning operation on the target data table. The cleaning result obtained from the intermediate table is the cleaning result of the target data table.
[0113] Perform cleaning operations on the intermediate table according to the cleaning rules in the cleaning task, which means that for each row of data in the intermediate table, use each cleaning rule in the cleaning task to clean it. If it is judged as dirty data according to any cleaning rule, write the row of data into the problem table, or write it into the standard table with the problem identification field; if it is judged not to be dirty data according to all cleaning rules, write the row of data into the standard table.
[0114] In one example, the cleaning process for the target row of the intermediate table corresponding to the target data table may be:
[0115] For each cleaning rule in the target cleaning task, read the data of the field corresponding to the cleaning rule from the target row of the intermediate table;
[0116] If the cleaning rule is a filtering rule, determine whether the read data is legal according to the cleaning rule; if the cleaning rule is a standardization rule, determine whether the read data needs to be standardized according to the cleaning rule;
[0117] If all filtering rules in the target cleaning task determine that the data is legal, and the data of the target row is standardized by all standardization rules in the target cleaning task or is determined not to require standardization, the data of the target row is determined not to be dirty data, and the data of the target row is written into the standard table;
[0118] If any filtering rule in the target cleaning task determines that the data is illegal, the data of the target row is determined to be dirty data, and the data of the target row is written into the problem table, or the data of the target row is written into the problem table with a problem identification field.
[0119] For example, the cleaning task corresponding to the above Table 1 includes 6 cleaning rules. Take the first row of data in the above Table 1 and the ID card legality filtering rules and the ID card 15-digit to 18-digit rule as examples to illustrate the cleaning process:
[0120] Read the data "xxxxxxxxxxxxxxxxx1" in the user ID number field of the first row of Table 1, and determine whether "xxxxxxxxxxxxxxxxx1" is legal according to the ID card legality filtering rules. If it is legal, perform the next step. If it is not legal, write all the data in the first row of Table 1 into the problem table, and end the data cleaning process for the first row;
[0121] Read the data "xxxxxxxxxxxxxxxxx1" in the user ID number field of the first row of Table 1, and determine whether "xxxxxxxxxxxxxxxxx1" needs to be converted according to the 15-digit to 18-digit ID number rule. If necessary, convert "xxxxxxxxxxxxxxxxx1" to an 18-digit ID number, and execute the next step after conversion; if no conversion is required, directly execute the next step;
[0122] …
[0123] In step S204, the target standard table may be sent to the device where the specified database is located through another Spark App. For example, in one example, step S204 may include:
[0124] The data in the standard table of the data warehouse is extracted through the Hive context select SQL statement, and the extracted data is written into the specified database through the insert into SQL statement of the java naming interface (JDBC Data Source).
[0125] After step S204, at least one table is added to the designated database: the target standard table. When the problem data is written into the problem table, the problem table is also sent to the designated database. At this time, two tables are added to the designated database: the target standard table and the problem table.
[0126] In an exemplary implementation process, the number of the target data table is at least one.
[0127] This example allows batch cleaning of multiple data tables, effectively shortening the overall cleaning time for the entire cleaning target data and further improving the processing efficiency of the cleaning process.
[0128] In an exemplary implementation process, the data cleaning method may further include:
[0129] In the process of performing the cleaning operation on the intermediate table, the problem data in the intermediate table and the problem identification field corresponding to the problem data are written into the standard table; or,
[0130] During the cleaning operation on the intermediate table, the problem data in the intermediate table is written into the problem table.
[0131] In this example, two processing methods are provided for problem data: one is to discard the problem data into the problem table; the other is to write the problem data into the standard table with the problem identification field.
[0132] In an example, there may be two problem identification fields: dirty flag (dirty_flag) and dirty type (dirty_type).
[0133] The value range of dirty_flag is 0 and 1. The dirty_flag is set to 1 for data that is judged as problematic data by the filtering rules and for data that fails to be converted by the standardization rules.
[0134] The value of dirty_type is a 128-bit binary string, which is all 0 by default. Each character has a value of 0 or 1, and the subscripts are 0 to 127 from left to right. Each character of dirty_type has a corresponding rule. For example, if a character is set to 1, it means that a certain rule determines that this value is illegal, and if it is set to 0, it means that a certain rule determines that this value is legal.
[0135] The processing of problematic data is not performed in the data warehouse.
[0136] When users need to process problem data, they can query the problem data in the following ways:
[0137] Method 1: When the question data is stored in the question table, you can use "Select * from question
[0138] "Table" command to query the data in the problem table;
[0139] Method 2: When the problem data is stored in the standard table, the problem data in the standard table can be queried through the "Select * from standard table where dirty_flag = '1'" command.
[0140] In an exemplary implementation process, the data cleaning method may further include:
[0141] In the process of performing the cleaning operation on the intermediate table, the problem data in the intermediate table is sent to the problem data backtracking device, so that the problem data backtracking device modifies the problem data to obtain the corrected data;
[0142] Write the correction data to the target standard table.
[0143] In this example, the corrected data is the data that meets the requirements after modifying the problem data. For example, if the ID card number in a record is 15 digits, and the ID card number in the standard data that meets the requirements should be 18 digits, then the modification method for the record is: modify the ID card number to 18 digits to obtain the corrected data.
[0144] The data cleaning method provided by the embodiment of the present invention extracts target metadata information of a target data table from a designated database, and copies the content of the target data table to an intermediate table in a data warehouse. According to the target metadata information, a target cleaning task of the target data table is determined, and the target cleaning task includes at least one cleaning rule. In the data warehouse, a cleaning operation is performed on the intermediate table according to each cleaning rule in the target cleaning task to obtain a target standard table corresponding to the target data table, and the target standard table is sent to a device where the designated database is located, so that the device stores the target standard table in the designated database. The cleaning task of the data table can be automatically generated according to the extracted metadata information, and the cleaning of the data table can be automatically completed according to the cleaning task. The entire cleaning process is automatically performed without manual intervention, and all data tables in the database or system can be cleaned in batches, which effectively shortens the time required for the cleaning process and improves the processing efficiency of data cleaning.
[0145] Based on the above method embodiments, the present invention also provides corresponding device, equipment and storage medium embodiments. For detailed implementation of the device, equipment and storage medium embodiments of the present invention, please refer to the corresponding description of the above method embodiment part.
[0146] Figure 3 is a functional block diagram of a data cleaning device provided by an embodiment of the present invention. Figure 3 As shown, in this embodiment, the data cleaning device may include:
[0147] An extraction and replication module 310 is used to extract target metadata information of a target data table from a specified database, and to replicate the content of the target data table to an intermediate table in a data warehouse;
[0148] A task determination module 320, configured to determine a target cleaning task for the target data table according to the target metadata information, wherein the target cleaning task includes at least one cleaning rule;
[0149] A cleaning module 330, configured to perform a cleaning operation on the intermediate table according to each cleaning rule in the target cleaning task to obtain a target standard table;
[0150] The sending module 340 is configured to send the target standard table to the device where the designated database is located, so that the device stores the target standard table in the designated database.
[0151] In an exemplary implementation process, the task determination module 320 is specifically used to:
[0152] From the established correspondence between table fields and standard data elements, find the target data elements that match the fields in the target metadata information;
[0153] Finding a first cleaning rule matching the target data element from the established correspondence between the standard data element and the cleaning rule;
[0154] A target cleaning task for the target data table is generated according to the first cleaning rule and the second cleaning rule.
[0155] In an exemplary implementation process, the target metadata information includes table field specified attributes, and the task determination module 320 is further used to:
[0156] From the established correspondence between table fields and designated attributes, find the target attributes that match the fields in the target metadata information;
[0157] Finding a second cleaning rule matching the target attribute from the established correspondence between the attribute and the cleaning rule;
[0158] When the task determination module 320 is used to generate the target cleaning task of the target data table according to the first cleaning rule, it is specifically used to generate the target cleaning task of the target data table according to the first cleaning rule and the second cleaning rule.
[0159] In an exemplary implementation, the apparatus further includes:
[0160] A modification information receiving module, used for receiving attribute modification information of a specified field in the target metadata information, wherein the attribute modification information is used for indicating that a specified attribute of the specified field is modified to a specified attribute;
[0161] An attribute modification module, used for modifying the specified attribute of the specified field in the intermediate table according to the attribute modification information;
[0162] A relationship updating module, used for updating the corresponding relationship between the table field corresponding to the intermediate table and the specified attribute according to the modification of the specified attribute of the specified field;
[0163] When the task determination module 320 is used to find the target attributes that match each field in the target metadata information from the established correspondence between the table fields and the specified attributes, it is specifically used to: find the target attributes that match each field in the target metadata information from the updated correspondence between the table fields and the specified attributes.
[0164] In an exemplary implementation process, the number of the target data table is at least one.
[0165] In an exemplary implementation, the apparatus further includes:
[0166] A data writing module is used to write the problem data in the intermediate table and the problem identification field corresponding to the problem data into the standard table during the process of performing a cleaning operation on the intermediate table; or to write the problem data in the intermediate table into the problem table during the process of performing a cleaning operation on the intermediate table.
[0167] In an exemplary implementation, the apparatus further includes:
[0168] The question table sending module is used to send the question table to the device where the designated database is located, so that the device stores the question table in the designated database.
[0169] In an exemplary implementation, the apparatus further includes:
[0170] In the process of performing the cleaning operation on the intermediate table, the problem data in the intermediate table is sent to the problem data backtracking device, so that the problem data backtracking device modifies the problem data to obtain the corrected data;
[0171] The correction data is written into the target standard table.
[0172] The embodiment of the present invention also provides a data cleaning device. Figure 4 FIG. 1 is a hardware structure diagram of a data cleaning device provided by an embodiment of the present invention. Figure 4As shown, the data cleaning device includes: an internal bus 401, and a memory 402, a processor 403 and an external interface 404 connected through the internal bus.
[0173] The processor 403 is configured to read the machine-readable instructions on the memory 402 and execute the instructions to implement the following operations:
[0174] Extract target metadata information of a target data table from a specified database, and copy the content of the target data table to an intermediate table in a data warehouse;
[0175] Determining a target cleaning task for the target data table according to the target metadata information, wherein the target cleaning task includes at least one cleaning rule;
[0176] In the data warehouse, a cleaning operation is performed on the intermediate table according to each cleaning rule in the target cleaning task to obtain a target standard table;
[0177] The target standard table is sent to the device where the designated database is located, so that the device stores the target standard table in the designated database.
[0178] In an exemplary implementation process, the processor 403 further executes the instructions to implement the following operations:
[0179] From the established correspondence between table fields and standard data elements, find the target data elements that match the fields in the target metadata information;
[0180] Finding a first cleaning rule matching the target data element from the established correspondence between the standard data element and the cleaning rule;
[0181] According to the first cleaning rule, a target cleaning task of the target data table is generated.
[0182] In an exemplary implementation process, the target metadata information includes table field specified attributes, and the processor 403 further executes the instructions to implement the following operations:
[0183] From the established correspondence between table fields and designated attributes, find the target attributes that match the fields in the target metadata information;
[0184] Finding a second cleaning rule matching the target attribute from the established correspondence between the attribute and the cleaning rule;
[0185] Generating the target cleaning task of the target data table according to the first cleaning rule specifically includes: generating the target cleaning task of the target data table according to the first cleaning rule and the second cleaning rule.
[0186] In an exemplary implementation process, the processor 403 further executes the instructions to implement the following operations:
[0187] Receiving attribute modification information of a specified field in the target metadata information, wherein the attribute modification information is used to indicate that a specified attribute of the specified field is modified to a specified attribute;
[0188] Modify the specified attribute of the specified field in the intermediate table according to the attribute modification information;
[0189] According to the modification of the designated attribute of the designated field, the corresponding relationship between the table field corresponding to the intermediate table and the designated attribute is updated;
[0190] The step of searching for target attributes that match each field in the target metadata information from the established correspondence between the table fields and the specified attributes is specifically: searching for target attributes that match each field in the target metadata information from the updated correspondence between the table fields and the specified attributes.
[0191] In an exemplary implementation process, the number of the target data table is at least one.
[0192] In an exemplary implementation process, the processor 403 further executes the instructions to implement the following operations:
[0193] In the process of performing the cleaning operation on the intermediate table, the problem data in the intermediate table and the problem identification field corresponding to the problem data are written into the standard table; or,
[0194] During the process of performing the cleaning operation on the intermediate table, the problem data in the intermediate table is written into the problem table.
[0195] In an exemplary implementation process, the processor 403 further executes the instructions to implement the following operations:
[0196] The question table is sent to the device where the designated database is located, so that the device stores the question table in the designated database.
[0197] In an exemplary implementation process, the processor 403 further executes the instructions to implement the following operations:
[0198] In the process of performing the cleaning operation on the intermediate table, the problem data in the intermediate table is sent to the problem data backtracking device, so that the problem data backtracking device modifies the problem data to obtain the corrected data;
[0199] The correction data is written into the target standard table.
[0200] The embodiment of the present invention further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a plurality of computer instructions, and when the computer instructions are executed, the following processing is performed:
[0201] Extract target metadata information of a target data table from a specified database, and copy the content of the target data table to an intermediate table in a data warehouse;
[0202] Determining a target cleaning task for the target data table according to the target metadata information, wherein the target cleaning task includes at least one cleaning rule;
[0203] In the data warehouse, a cleaning operation is performed on the intermediate table according to each cleaning rule in the target cleaning task to obtain a target standard table;
[0204] The target standard table is sent to the device where the designated database is located, so that the device stores the target standard table in the designated database.
[0205] In an exemplary implementation process, when the computer instructions are executed, the following processing is also performed:
[0206] From the established correspondence between table fields and standard data elements, find the target data elements that match the fields in the target metadata information;
[0207] Finding a first cleaning rule matching the target data element from the established correspondence between the standard data element and the cleaning rule;
[0208] According to the first cleaning rule, a target cleaning task of the target data table is generated.
[0209] In an exemplary implementation process, the target metadata information includes table field specified attributes, and the computer instructions further perform the following processing when executed:
[0210] From the established correspondence between table fields and designated attributes, find the target attributes that match the fields in the target metadata information;
[0211] Finding a second cleaning rule matching the target attribute from the established correspondence between the attribute and the cleaning rule;
[0212] Generating the target cleaning task of the target data table according to the first cleaning rule specifically includes: generating the target cleaning task of the target data table according to the first cleaning rule and the second cleaning rule.
[0213] In an exemplary implementation process, when the computer instructions are executed, the following processing is also performed:
[0214] Receiving attribute modification information of a specified field in the target metadata information, wherein the attribute modification information is used to indicate that a specified attribute of the specified field is modified to a specified attribute;
[0215] Modify the specified attribute of the specified field in the intermediate table according to the attribute modification information;
[0216] According to the modification of the designated attribute of the designated field, the corresponding relationship between the table field corresponding to the intermediate table and the designated attribute is updated;
[0217] The step of searching for target attributes that match each field in the target metadata information from the established correspondence between the table fields and the specified attributes is specifically: searching for target attributes that match each field in the target metadata information from the updated correspondence between the table fields and the specified attributes.
[0218] In an exemplary implementation process, the number of the target data table is at least one.
[0219] In an exemplary implementation process, when the computer instructions are executed, the following processing is also performed:
[0220] In the process of performing the cleaning operation on the intermediate table, the problem data in the intermediate table and the problem identification field corresponding to the problem data are written into the standard table; or,
[0221] During the process of performing the cleaning operation on the intermediate table, the problem data in the intermediate table is written into the problem table.
[0222] In an exemplary implementation process, when the computer instructions are executed, the following processing is also performed:
[0223] The question table is sent to the device where the designated database is located, so that the device stores the question table in the designated database.
[0224] In an exemplary implementation process, when the computer instructions are executed, the following processing is also performed:
[0225] In the process of performing the cleaning operation on the intermediate table, the problem data in the intermediate table is sent to the problem data backtracking device, so that the problem data backtracking device modifies the problem data to obtain the corrected data;
[0226] The correction data is written into the target standard table.
[0227] For the device and equipment embodiments, since they basically correspond to the method embodiments, the relevant parts can refer to the partial description of the method embodiments. The device embodiments described above are merely schematic, wherein the modules described as separate components may or may not be physically separated, and the components displayed as modules may or may not be physical modules, that is, they may be located in one place, or they may be distributed on multiple network modules. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this specification. A person of ordinary skill in the art can understand and implement it without paying creative labor.
[0228] The above is a description of a specific embodiment of the specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0229] Those skilled in the art will readily appreciate other embodiments of the specification after considering the specification and practicing the invention claimed herein. The specification is intended to cover any variations, uses or adaptations of the specification that follow the general principles of the specification and include common knowledge or customary techniques in the art that are not claimed in the specification. The specification and examples are to be considered exemplary only, and the true scope and spirit of the specification are indicated by the following claims.
[0230] It should be understood that the present description is not limited to the precise structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present description is limited only by the appended claims.
[0231] The above description is only a preferred embodiment of this specification and is not intended to limit this specification. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of this specification should be included in the scope of protection of this specification.
Claims
1. A data table processing method, It is characterized in that The method comprises: Sending target metadata information of a target data table in a specified database to a data cleaning device so that the data cleaning device copies the content of the target data table to an intermediate table in a data warehouse according to the target metadata information; the target metadata information includes table field specified attributes; After the copying is completed, a metadata modification instruction is sent to the data cleaning device, so that the data cleaning device modifies the table field specified attribute in the metadata information of the intermediate table according to the metadata modification instruction; the table field specified attribute includes at least one of the following: whether it is a primary key, whether the field can be empty; After the modification is completed, a metadata confirmation instruction is sent to the data cleaning device so that the data cleaning device confirms the metadata information of the intermediate table according to the metadata confirmation instruction.
2. The method according to claim 1, It is characterized in that The data cleaning device also determines a target cleaning task of the target data table according to the target metadata information, the target cleaning task including at least one cleaning rule, and performs a cleaning operation on the intermediate table according to each cleaning rule in the target cleaning task to obtain a target standard table; The method further comprises: The target standard table sent by the data cleaning device is received, and the target standard table is stored in the designated database.
3. The method according to claim 2, It is characterized in that Determining the target cleaning task of the target data table according to the target metadata information includes: The data cleaning device searches for target data elements that match each field in the target metadata information from the established correspondence between table fields and standard data elements; The data cleaning device searches out a first cleaning rule matching the target data element from the established correspondence between the standard data element and the cleaning rule; The data cleaning device generates a target cleaning task for the target data table according to a first cleaning rule.
4. The method according to claim 3, It is characterized in that After the data cleaning device searches out a first cleaning rule matching the target data element from the established correspondence between the standard data element and the cleaning rule, the data cleaning device further includes: The data cleaning device searches for target attributes that match each field in the target metadata information from the established correspondence between the table fields and the specified attributes; The data cleaning device searches for a second cleaning rule matching the target attribute from the established correspondence between the attribute and the cleaning rule; The data cleaning device generating the target cleaning task for the target data table according to the first cleaning rule includes: the data cleaning device generating the target cleaning task for the target data table according to the first cleaning rule and the second cleaning rule.
5. The method according to claim 2, It is characterized in that The data cleaning device, in the process of performing the cleaning operation on the intermediate table, writes the problem data in the intermediate table and the problem identification field corresponding to the problem data into the target standard table; Alternatively, in the process of performing a cleaning operation on the intermediate table, the problem data in the intermediate table is written into the problem table; The method further comprises: The problem table sent by the data cleaning device is received, and the problem table is stored in the designated database.
6. The method according to claim 1, It is characterized in that The data cleaning device copies the content of the target data table to an intermediate table in the data warehouse, including: The data cleaning device uses a data warehouse tool to locally create an intermediate database with the same name as the designated database where the target data table is located according to the target metadata information, and creates an intermediate table with the same table name and the same table structure as the target data table in the intermediate database; The data cleaning device reads the content data stored in the target data table, and writes the read content data into the intermediate table.
7. The method according to claim 1, It is characterized in that The metadata information includes general metadata information and table field specified attributes; the data cleaning device stores the general metadata information and table field specified attributes of the target data table separately, and stores the general metadata information and table field specified attributes of the intermediate table separately.
8. The method according to claim 2, It is characterized in that The data cleaning device cleans the target row of the intermediate table in the following steps: For each cleaning rule in the target cleaning task, read the data of the field corresponding to the cleaning rule from the target row of the intermediate table; If the cleaning rule is a filtering rule, determine whether the read data is legal according to the cleaning rule; if the cleaning rule is a standardization rule, determine whether the read data needs to be standardized according to the cleaning rule; If all filtering rules in the target cleaning task determine that the data is legal, and the data of the target row is standardized by all standardization rules in the target cleaning task or is determined not to require standardization, the data of the target row is determined not to be dirty data, and the data of the target row is written into the standard table; If any filtering rule in the target cleaning task determines that the data is illegal, the data of the target row is determined to be dirty data, and the data of the target row is written into the problem table, or the data of the target row is written into the problem table with a problem identification field.
9. The method according to claim 1, It is characterized in that Also includes: After confirming the metadata information of the intermediate table according to the metadata confirmation instruction, the data cleaning device adds a scenario identification bit in the configuration of the primary key of the intermediate table, and the scenario identification bit is used to distinguish different application scenarios.
10. A data table processing device, It is characterized in that The device comprises: A metadata information sending module, used to send target metadata information of a target data table in a specified database to a data cleaning device, so that the data cleaning device can copy the content of the target data table to an intermediate table in a data warehouse according to the target metadata information; the target metadata information includes table field specified attributes; A metadata modification module is used to send a metadata modification instruction to the data cleaning device after the copying is completed, so that the data cleaning device modifies the table field specified attribute in the metadata information of the intermediate table according to the metadata modification instruction; the table field specified attribute includes at least one of the following: whether it is a primary key, whether the field can be empty; The metadata confirmation module is used to send a metadata confirmation instruction to the data cleaning device after the modification is completed, so that the data cleaning device confirms the metadata information of the intermediate table according to the metadata confirmation instruction.
11. A data table processing device, It is characterized in that comprising a processor and a memory for storing executable instructions of the processor; The processor is configured to: Sending target metadata information of a target data table in a specified database to a data cleaning device, so that the data cleaning device copies the content of the target data table to an intermediate table in a data warehouse according to the target metadata information; The target metadata information includes table field specified attributes; After the copying is completed, a metadata modification instruction is sent to the data cleaning device, so that the data cleaning device modifies the table field specified attribute in the metadata information of the intermediate table according to the metadata modification instruction; the table field specified attribute includes at least one of the following: whether it is a primary key, whether the field can be empty; After the modification is completed, a metadata confirmation instruction is sent to the data cleaning device so that the data cleaning device confirms the metadata information of the intermediate table according to the metadata confirmation instruction.
