Create Quality Rules For Real-Time Metatables

Updated at:

This topic explains how to create a quality rule for a real-time metatable.

Prerequisites

You can configure quality rules only after you add a monitored object. For more information about how to add a monitored object, see Add a monitored object.

Permissions

  • Super administrators, quality administrators, users with a custom global role that includes the Quality rule-Manage permission, users with a custom project-level role that includes the Project quality management-quality rule management permission for the project where the metatable resides, and real-time metatable owners can configure scheduling, alert configurations, and runtime configurations for quality rules.

  • Quality owners and general users must also have synchronous read permissions on the real-time metatable. To apply for these permissions, see Apply for, renew, and return table permissions.

  • The supported operations and permissions vary by object. For more information, see Permissions on quality rule operations.

Trial runs vs. runs

The difference between a trial run and a regular run lies in the execution method and where the results are displayed. A trial run is a simulated execution of a quality rule to verify its correctness and behavior. The results of a trial run are not displayed in the quality report. A run checks the quality rule according to its schedule, and the results are written to the quality report.

Metatable rule types

Rule type

Description

Statistical trend monitoring

Verifies data values and their trends over time.

Real-time multi-link comparison

In business-critical scenarios, you can use real-time dual-link or triple-link quality rules to monitor data. If an anomaly is detected, operations staff can promptly switch to or back up a data source. Real-time multi-link comparison quality rules help monitor issues such as data latency and statistical deviations.

Real-time and offline data verification

When real-time and offline data processing use the same statistical logic, a real-time and offline data verification quality rule can detect discrepancies between them. A significant difference may indicate a data quality issue.

Quality rule configuration

  1. On the Dataphin homepage, in the top navigation bar, choose Governance > Data Quality.

  2. In the left-side navigation pane, click Quality Rules. On the Real-time Metatables page, click the name of the target object to go to the Quality Rule Details page and configure the quality rule.

  3. On the Quality Rule Details page, click Create Quality Rule.

  4. In the Create Quality Rule dialog box, configure the parameters.

    Parameter

    Description

    Basic information

    Rule name

    Enter a name for the quality rule.

    Rule severity

    You can select weak rule or strong rule.

    • If you select a weak rule, an alert is triggered when the rule check fails, but downstream task nodes are not blocked.

    • If you select a strong rule, an alert is triggered when the rule check fails. If downstream tasks exist (for example, triggered by code check or task-triggered scheduling), they are blocked to prevent data contamination. If no downstream tasks exist (for example, with periodic quality scheduling), only an alert is triggered.

    Description

    Enter a description for the quality rule. The description can be up to 128 characters long.

    Rule template

    You can select a Consistency or Stability rule template.

    • Consistency: Includes Real-time and offline comparison and Real-time link comparison.

    • Stability: Includes Real-time statistical value check.

    For more information, see Real-time metatable template types.

    Rule type

    The rule type is associated with the rule template and serves as a fundamental attribute for description and filtering.

    Rule configuration

    Rule configuration

    Configure the rule based on the selected rule template. For more information, see Configure parameters for offline link comparison and Configure parameters for multi-link comparison.

    Verification configuration

    Rule verification

    • After a data quality rule is verified, the result is compared with the exception verification settings. If the conditions are met, the verification fails, and subsequent processes such as alerting are triggered.

    • The available metrics for exception verification are determined by the template and its configuration. You can combine multiple conditions by using AND or OR operators. Configure no more than three conditions.

    For more information, see Verification configuration description.

    Business attribute configuration

    Attribute information

    The input format for business attributes depends on how the quality rule attributes are configured. For example, if the value type for the responsible department field is an enumeration (multi-select) with available values like Big Data Department, Business Department, and Technology Department, this attribute appears as a multi-select drop-down list when you create a quality rule.

    If the value type for the rule owner field is custom input with a maximum length of 256 characters, you can enter up to 256 characters for this attribute when you create a quality rule.

    If the input method for an attribute field is Range, configure it as follows:

    Range: This is typically used for continuous numerical or date ranges. You can use the following operators: >, >=, <, and <=. For more information about attribute configuration, see Create and manage quality rule attributes.

    Scheduling configuration

    Scheduling method

    Select a pre-configured schedule. If you have not yet selected a scheduling method, you can configure one after creating the quality rule. To create a new schedule, see Create a schedule.

  5. Click OK to save the quality rule configuration.

    Click Preview SQL to compare the current configuration with the last saved version and view the SQL changes.

    Note
    • Preview SQL is unavailable because key information is incomplete.

    • The left pane previews the SQL of the last saved configuration, or is empty if none exists. The right pane previews the SQL of the current configuration.

Rule configuration list

On the rule configuration list page, you can view the configured metatable rules and perform operations such as view, edit, trial run, run, and delete.

image

Area

Description

① Filter and search area

Quickly search for rules by object or rule name.

Filter rules by rule type, rule template, rule severity, trial run status, or effective status.

Note

If a business attribute is enabled and configured as searchable or filterable, you can use it to search for or filter rules.

② List area

Displays rule configuration information, including Object type/name, Rule name/ID, Trial run status, Effective status, Rule type, Rule template, Rule severity, Scheduling type, Related knowledge base documents, and Last updated by/at. Click the image icon next to the refresh button to select the columns to display.

  • Effective status: Perform a trial run on a rule before you enable it. Enable only the rules that pass the trial run to avoid blocking production tasks with faulty rules.

    • After a rule is enabled, it is automatically run based on its configured schedule.

    • After a rule is disabled, it is not run automatically, but you can still run it manually.

  • Related knowledge base documents: Click View Details to see information about the associated knowledge base document, including the table name, verification object, rule, and the document itself. You can also search for, view, edit, or delete the knowledge base document. For more information, see View the knowledge base.

③ Actions area

You can perform the following operations: View, Clone, Edit, Trial Run, Run, Configure Scheduling, Associate Knowledge Base Document, and Delete.

  • View: View the details of the rule configuration.

  • Clone: Quickly clone the rule.

  • Edit: After you edit a rule, you must perform a new trial run.

  • Trial Run: After the trial run, you can click the image icon to view the trial run log.

  • Run: After the run, you can view the verification result in Verification Records.

  • Configure Scheduling: In the dialog box that appears, you can filter schedules by type or search for them by name. You can also edit schedules.

  • Associate Knowledge Base Document: After you associate a rule with a knowledge base document, you can view the association in the quality rule list and the governance workbench. You can select an unassociated knowledge base document. To create one, see Create and manage the knowledge base.

  • Delete: Deleting this quality rule object also deletes all quality rules under it. This operation cannot be undone.

④ Bulk actions area

You can perform the following operations in bulk: Trial Run, Run, Configure Scheduling, Enable, Disable, Modify Business Attributes, Associate Knowledge Base Document, and Delete.

  • Trial Run: Perform trial runs on multiple rules at once. After a trial run, you can click the image icon to view the trial run log.

  • Run: Run multiple rules at once. After the run, you can view the verification results in Verification Records.

  • Configure Scheduling: In the dialog box that appears, you can filter schedules by type or search for them by name. You can also edit schedules to apply a schedule to multiple quality rules at once. You can modify only the selected rules that are editable on the quality rule list page.

  • Enable: Enable multiple rules at once. The selected rules are then automatically run based on their configured schedules. You can enable only the selected rules that are editable on the quality rule list page.

  • Disable: Disable multiple rules at once. The selected rules are no longer run automatically, but you can still run them manually. You can disable only the selected rules that are editable on the quality rule list page.

  • Modify Business Attributes: You can modify business attributes in bulk if the value type of the corresponding attribute field is single-select or multi-select.

    • For multi-select attributes, you can append or replace values.

    • For single-select attributes, you can directly replace the value.

  • Associate Knowledge Base Document: After you associate rules with a knowledge base document, you can view the association in the quality rule list and the governance workbench. You can associate multiple monitored objects with a knowledge base document at once. To create one, see Create and manage the knowledge base.

  • Delete: Delete multiple quality rule objects at once. This operation cannot be undone. Proceed with caution. You can delete only the selected rules that are editable on the quality rule list page.

Create a schedule

Note
  • When you configure a schedule for a rule, you can select from the existing schedules for the current table. A maximum of 20 schedules can be created for each table.

  • A single rule can be associated with a maximum of 10 schedules.

  • If schedules have identical configurations, the system automatically deduplicates them.

  1. On the Quality Rule Details page, click the Scheduling Configuration tab, and then click Create Schedule to open the Create Schedule dialog box.

  2. In the Create Schedule dialog box, configure the parameters.

    Parameter

    Description

    Schedule name

    Enter a custom name for the schedule.

    Scheduling type

    The supported types are time-based scheduling, data update-triggered scheduling, and task-triggered scheduling.

    • Time-based scheduling: Runs data quality checks at scheduled times or intervals. This method is suitable for scenarios where data is generated at fixed times.

      Scheduling Cycle: Running quality rules consumes computing resources. We recommend that you avoid running multiple quality rules concurrently to prevent affecting production tasks. The available scheduling cycles are Day, Week, Month, Hour, and Minute.

      If the system time zone (the time zone in your user center) is different from the scheduling time zone (the time zone configured in Management Center > System Settings > Basic Settings), the rule runs based on the system time zone.

    • Data update-triggered scheduling: When any code task runs, the system checks whether the run updates the data within the specified verification scope for the current table. This method is suitable for tables that are modified by various tasks or for critical tables that require monitoring on every change.

      Note

      Set the verification scope to the partitions updated by the task. For non-partitioned tables, the entire table is verified. The system automatically detects all data changes and performs verifications to avoid omissions.

    • Task-triggered scheduling: Runs the configured quality rule before or after a specified task successfully runs. You can select tasks of the following types to trigger the rule: SQL, Offline-pipeline, Python, Shell, Virtual, and Dlink, Spark_jar, Hive_MR nodes, and database SQL nodes. This method is suitable for scenarios where the tasks that modify a table are fixed.

      Note
      • You can select only tasks from a production environment to trigger the rule. If the rule severity is strong and its check fails, production tasks may be affected. Use this feature with caution based on your business requirements.

      • Supported engine types include MaxCompute, E-MapReduce 3.X, E-MapReduce 5.x, CDH 5.X, CDH 6.X, FusionInsight 8.X, AsiaInfo DP 5.3, Cloudera Data Platform 7.x, Lindorm (compute engine), Transwarp TDH 6.x, and Transwarp TDH 9.3.x.

      • Trigger Timing: Select when to trigger the data quality check. You can choose from Trigger after all tasks successfully complete, Trigger after each successful run of each task, and Trigger before each run of each task.

      • Triggering Task: Select a task node from a production project to trigger the rule. You can also search for tasks by node output name. The following roles can select task nodes:

        • Project administrators of Prod/Basic projects, users with the O&M system role in Prod projects, users with the Developer system role in Basic projects, and users with a custom project role that includes the Project quality management-quality rule management permission in Prod/Basic projects can select task nodes from production projects.

        • Users with a custom global role that includes the Quality rule-Manage permission can select task nodes from all production projects.

          Note

          If you set the trigger timing to Trigger after all tasks successfully complete, select triggering tasks that have the same scheduling cycle as the rule. This practice prevents the rule from being delayed due to different scheduling cycles, which would delay the output of the check results.

    Scheduling conditions

    This feature is disabled by default. If you enable it, the system first checks whether the scheduling conditions are met before a quality rule is scheduled to run. The rule is scheduled only if the conditions are met. Otherwise, the scheduled run is skipped.

    • Business Date/Execution Date: If the scheduling type is time-based scheduling (Execution Date is not supported), data update-triggered scheduling, or task-triggered scheduling, you can configure date conditions. You can select a General Calendar or a Custom Calendar. For information about how to create a custom calendar, see Create a public calendar.

      • If you select General Calendar, you can set conditions based on Month, Day of the week, or Day of the month. For example:

        image

      • If you select Custom Calendar, you can set conditions based on Date Type or Tag. For example:

        image

    • Instance Type: If the scheduling type is data update-triggered scheduling or task-triggered scheduling, you can configure instance type conditions. You can select Cyclical Instance, Backfill Instance, or Manual Instance. For example:

      image

    Note
    • You must configure at least one rule. To add a rule, click the + Add Rule button.

    • You can configure a maximum of 10 scheduling conditions.

    • You can set the relationship between conditions to AND or OR.

  3. Click OK to save the schedule configuration.

Schedule configuration list

After you create a schedule, you can view, edit, clone, or delete it from the schedule configuration list.

image.png

Area

Description

① Filter and search area

Quickly search for schedules by name.

Filter by time-based scheduling, data update-triggered scheduling, or task-triggered scheduling.

② List area

This area displays schedule information, including Schedule name, Scheduling type, Last updated by, and Last update time.

③ Actions area

You can edit, clone, or delete schedules.

  • Edit: Modify a configured schedule.

    Important

    All rules that use this schedule will be updated with the changes. Proceed with caution.

  • Clone: Quickly duplicate a schedule configuration.

  • Delete: You cannot delete a schedule that is currently used by a rule.

Alert configuration

You can assign different alert methods to rules to differentiate their alerts. For example, you can configure phone call alerts for failed strong rules and SMS message alerts for failed weak rules. If a rule matches multiple alert configurations, you can set a policy to determine which configuration takes effect.

Note

You can create a maximum of 20 alert configurations for a single monitored object.

  1. On the Quality Rule Details page, click the Alert Configuration tab, and then click Create Alert Configuration to open the Create Alert Configuration dialog box.

  2. In the Create Alert Configuration dialog box, configure the parameters.

    Parameter

    Description

    Scope

    You can select All Rules, All Strong Rules, All Weak Rules, or Custom.

    Note
    • For a single monitored object, you can create one alert configuration for each of the following scopes: All Rules, All Strong Rules, and All Weak Rules. New rules automatically match the corresponding alert configuration based on their rule severity. To change one of these alert configurations, you can edit the existing one.

    • For a custom scope, you can select up to 200 existing rules under the current monitored object.

    Alert configuration name

    The alert configuration name must be unique for each monitored object and can be up to 256 characters long.

    Alert recipient

    Configure the alert recipients and alert methods. You must select at least one alert recipient and one alert method.

    • Alert Recipient: You can select Custom, On-duty Schedule, or Quality Owner.

      You can configure up to five custom alert recipients and up to three on-duty schedules.

    • Alert Method: You can select one or more of the following methods: Phone, Email, SMS, DingTalk, Lark, WeCom, Custom Channel. You can manage these channels in Channel Settings.

  3. Click OK to save the alert configuration.

Alert configuration list

After you configure alerts, you can sort, edit, or delete them from the alert configuration list.

image.png

Area

Description

① Sorting area

Configure an effective policy for when a quality rule matches multiple alert configurations:

  • First matched alert configuration takes effect: If you select this policy, only the first alert configuration that the rule matches takes effect. All other matched configurations are ignored. In this case, you can sort the configured alerts. Click Sort Rules, and then drag the image.png icon next to the alert configuration name to change its order, or use the icons in the Actions column to move it. The icons from left to right are: Move to Top and Move to Bottom. After you sort the alerts, click Finish Sorting.

    image.png

  • All alert configurations take effect: All alert configurations in the list apply to the quality rules under the current monitored object.

    For example, if you have multiple alert configurations and select this policy, the system merges alerts by alert method, alert recipient, and alert rule. As a special case, if the alert recipient is the same user and the alert recipient type is Custom or Quality Owner, the alert messages are merged based on the merging policy.

    Note
    • Alert merging is not supported for on-duty schedules.

    • If a quality owner is a user group, alert notifications are automatically sent to all members of the group.

② List area

This area displays the name, scope, specific recipients for each alert type, and their corresponding alert methods.

Scope: For custom alerts, you can view the configured object and rule names. If a rule is deleted, its name cannot be viewed. Update the alert configuration in this case.

③ Actions area

You can edit or delete configured alerts.

  • Edit: Modify a configured alert. If you change the alert recipient or method, promptly notify the relevant personnel to avoid missing business-critical alerts.

  • Delete: After you delete an alert configuration, the rules that it matches will no longer trigger alerts. Proceed with caution.

Quality report

Click Quality Report to view the Rule Verification Overview and Rule Verification Details for the current quality rule.

  • Quickly filter verification details by exception result, partition time, or by rule or object name keywords.

  • In the Actions column of the verification details list, click the image icon to view the verification details for a rule.

  • In the Actions column of the verification details list, click the image icon to view the execution log for a rule.

Quality rule permissions

  1. Click Permission Management to configure the View Details permission, which specifies which members can view verification record details, quality rule details, and quality reports.

    View Details: You can select All Members or Only members with quality management permissions for the current object.

  2. Click OK to save the permission management configuration.

Runtime configuration

Note
  • If a quality rule task times out, the system terminates it and marks its execution status as failed. You can view the corresponding execution log on the verification record details page.

  • If a quality rule task is configured for automatic retry on failure, you can view the records of all retry attempts in its execution log on the verification record details page.

  • The latest runtime configuration applies to all quality rules under a single monitored object, including new rules and existing rules that have not been run.

  1. Click the Runtime Configuration tab, and then click the Edit button at the bottom to configure the parameters.

    Parameter

    Description

    Scope

    You can select All Rules, All Strong Rules, All Weak Rules, or Custom.

    Run timeout

    If the total runtime of a quality rule task (the time from start to finish, excluding resource and scheduling wait times) exceeds the set threshold, the system automatically terminates the task and sets its status to failed. The default timeout is 1 hour. You can set a custom duration from 0 to 2 hours, with a precision of two decimal places.

    Automatic retry on failure

    For failed quality rule tasks, you can configure automatic retries based on the Number of Retries and Interval. This feature is disabled by default. Enable it to configure the settings.

    • Number of Retries: The maximum number of times the system automatically retries a failed quality rule task. The default is 1. You can set an integer from 1 to 3.

    • Interval: The time interval between each automatic retry. The default is 0 minutes. You can set an integer from 0 to 10 minutes.

  2. Click OK to save the runtime configuration.

Next steps

After you configure the quality rule, you can view it on the real-time metatable rule list page. For more information, see View the list of monitored objects.