This topic describes the background information, limitations, and configuration methods of matching rules for validation objects.
Background information
When you create a data validation task, you can specify the validation objects by specifying objects, importing a CSV file, or configuring matching rules. When you configure matching rules, you can specify the validation objects by using wildcard rules and configure the object mapping logic between the source and the target. This way, you can easily and efficiently match the validation objects, thereby reducing the configuration complexity when you have a large number of validation objects.
The following table describes the wildcard rules supported for data validation.
| Category | Supported wildcard rule | Example | Description |
|---|---|---|---|
| Consistent source and target tables | *.* | kd_test*.person* | Verifies all tables in all databases that start with person in the source/target database that starts with kd_test. |
| Consistent source and target tables | *.<source table> | kd_test*.person | Verifies all tables named person in all databases that start with kd_test in the source/target database that starts with kd_test. |
| Consistent source and target tables | <source database>.* | kd_test.person* | Verifies all tables in the database named kd_test in the source/target database that start with person. |
| Consistent source and target tables | <source database>.<source table> | kd_test.person | Verifies the table named person in the database named kd_test in the source/target database. |
| Renamed source and target tables | <source database>.<source table>=<target database>.<target table> | kd_test.person=kd_test_new.person_new | Verifies the table named person in the database named kd_test in the source database with the table named person_new in the database named kd_test_new in the target database. |
| Renamed source and target tables | <source database>.*=<target database>.* | kd_test.person*=kd_test_new.person* | Verifies all tables that start with person in the database named kd_test in the source database with all tables that start with person in the database named kd_test_new in the target database. |
| Renamed source and target tables | *.<source table>=*.<target table> | kd_test*.person=kd_test_new*.person_new | Verifies all tables named person in all databases that start with kd_test in the source database with all tables named person_new in all databases that start with kd_test_new in the target database. |
| Aggregated source and target tables | <source database>.*=<target database>.<target table> | kd_test.person*=kd_test.person_all | Verifies all tables that start with person in the database named kd_test in the source database with the table named person_all in the database named kd_test in the target database. |
| Aggregated source and target tables | *.<source table>=<target database>.<target table> | kd_test*.person=kd_test_all.person | Verifies all tables named person in all databases that start with kd_test in the source database with the table named person in the database named kd_test_all in the target database. |
| Aggregated source and target tables | *.*=<target database>.<target table> | kd_test*.person*=kd_test_all.person_all | Verifies all tables that start with person in all databases that start with kd_test in the source database with the table named person_all in the database named kd_test_all in the target database. |
| Aggregated source and target tables | *.*=<target database>.* | kd_test*.person*=kd_test_all.person* | Verifies all tables that start with person in all databases that start with kd_test in the source database with all tables that start with person in the database named kd_test_all in the target database. |
| Aggregated source and target tables | *.*=*.<target table> | kd_test*.person*=kd_test*.person_all | Verifies all tables that start with person in all databases that start with kd_test in the source database with all tables named person_all in all databases that start with kd_test in the target database. |
The following rules apply to wildcard rules:
The target database name and table name cannot both use wildcard rules. For example,
kd_test*.person*=kd_test*.person*.If both the source and target databases use wildcard rules, the database-level expressions must be exactly the same.
If both the source and target tables use wildcard rules, the table-level expressions must be exactly the same.
If the target database uses a wildcard rule, the source database must use a wildcard rule.
If the target table uses a wildcard rule, the source table must use a wildcard rule.
Limitations
You can specify multiple rules for data validation. However, each rule must not contain line breaks or spaces.
The validation object rule cannot be empty, but the object exclusion rules can be empty.
When you select a validation object by using a matching rule, the table name cannot contain special characters (spaces, line breaks, or .|"'`()=;/&*?[][!]).
Data validation does not support mapping tables in the same database at the source to different databases at the target by using multiple matching rules. For example,
a.a* = b.a* & a.b* = c.b*.
Considerations
After you configure the validation object rules and the object exclusion rules, if the source table name is in the difference set between the validation object rule and the object exclusion rules, the object can be selected.
Note
The difference set is a new set that contains all elements that exist in the first set but do not exist in the second set.
If a table is configured with a renaming mapping rule, the renaming is prioritized. For example, if both
a.b[0-3]anda.b[3-5]=a.cexist, the tablea.b3is renamed toa.c.
Configure a matching rule
Create a data validation task and configure it to the Select Type & Objects step.
For more information, see Create a data validation task.
In the Select Type & Objects step, select the validation type and validation object.
You can select validation objects through two methods: Specify Objects and Match by Rule. This topic describes how to configure a matching rule.
In the Validation Objects section, select Match by Rule.
Enter Validation Object Rule and Object Exclusion Rules (optional). For more information about supported wildcard patterns, see Wildcards.
Click Verify.
After the validation is completed, you can click Preview to view the matching result. The wildcard validation object rules and the object exclusion rules that you specify apply only to tables. Matching Results contains the final objects, added objects, and reduced objects.
Objects Description Final The validation object that is finally matched by the configured matching rule. Added The validation object that is newly added in the final matching result compared with the matching result configured in the previous step. Reduced The validation object that is reduced in the final matching result compared with the matching result configured in the previous step.
Complete the subsequent task configuration as prompted.