Create quality rules for real-time metatables

Updated at:

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

Prerequisites

Add a monitoring object before configuring quality rules. For more information, see Add a monitoring object.

Permissions

  • A super administrator, quality administrator, real-time metatable owner, a user with a custom global role that includes the Quality Rule - Manage permission, or a user with a custom project role that includes the Project Quality Management - Quality Rule Management permission for the project where the metatable is located can configure schedules, alerts, and runtime configurations for quality rules.

  • Quality owners and standard users also need synchronous read permissions for the real-time metatable. To request permissions, see Apply for, Renew, and Return Table Permissions.

  • Supported operations depend on the object type. For details, see Quality Rule Operation Permissions.

Trial run vs. regular run

A trial run and a regular run differ in execution and result visibility. A trial run simulates a quality rule to verify its behavior without publishing results to the quality report. A regular run executes the quality rule at a specified time and publishes its results to the quality report.

Metatable rule types

Rule type

Description

Statistical trend monitoring

Verifies data values and data change trends.

Real-time multi-link comparison

For business scenarios requiring high reliability, use real-time dual- or triple-link quality rules to monitor data. If an anomaly occurs, operations staff can quickly switch to a different link or back up data. Real-time multi-link comparison quality rules can monitor issues such as data retention and statistical deviation.

Real-time and offline data reconciliation

A real-time and offline data reconciliation quality rule detects discrepancies between real-time and offline data that use the same statistical logic. A significant discrepancy may indicate a data quality issue.

Configure quality rules

  1. On the Dataphin home page, choose Governance > Data Quality from the top navigation bar.

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

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

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

    Parameter

    Description

    Basic information

    Rule name

    Enter a custom name for the quality rule.

    Rule severity

    You can select weak rule or strong rule.

    • If you select weak rule, an alert is triggered if the rule check fails, but downstream tasks are not blocked.

    • If you select strong rule, an alert is triggered if the rule check fails. If there are downstream tasks (in code check schedules or task-triggered schedules), they are blocked to prevent the propagation of poor-quality data. If there are no downstream tasks (such as in periodic quality schedules), only an alert is triggered.

    Description

    Enter a custom 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 vs. 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 depends on the template. It is a fundamental attribute of the template and can be used for description and filtering purposes.

    Rule configuration

    Rule configuration

    Configure the rule based on the selected Rule template. For more information, see Real-time metatable parameter configuration and Multi-link comparison parameter configuration.

    Check configuration

    Rule check

    • After checking a data quality rule, the system compares the result with the anomaly check configuration. The check fails if the conditions are met, triggering subsequent processes like alerting.

    • The available metrics for anomaly checks are determined by the template and its configuration. You can use multiple AND/OR conditions, but we recommend using no more than three.

    For more information, see Check configuration description.

    Business attribute configuration

    Attribute information

    How you specify business attributes depends on the attribute's configuration in the quality rule. For example, if the value type for the responsible department field is an enumeration (multi-select) with options like Big Data Department, Business Department, and Technology Department, then this attribute appears as a multi-select drop-down menu 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 a value of up to 256 characters when creating the quality rule.

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

    Range: This is typically used for continuous numerical values or dates. You can select one of four symbols: >, >=, <, or <=. For more information about attribute configuration, see Create and manage quality rule attributes.

    Scheduling attribute configuration

    Scheduling method

    You can select an existing schedule. If you have not decided on a scheduling method, you can configure it after creating the quality rule. To create a schedule, see Create a schedule.

  5. Click OK to save the quality rule configuration.

    You can click Preview SQL to view the changes in the SQL statement compared to the last saved version.

    Note
    • The Preview SQL button is disabled if required information is missing.

    • The left pane shows the SQL preview of the last saved configuration. If no configuration was saved, this pane is empty. The right pane shows the SQL preview of the current configuration.

Rule configuration list

On the rule configuration list page, you can view information about the configured metatable rules and perform operations such as viewing, editing, running a trial, running, and deleting them.

image

Area

Description

① Filter and search area

You can search for rules by object name or rule name.

You can filter rules by rule type, rule template, rule severity, trial run status, and activation status.

Note

If a business attribute is configured to be searchable or filterable and is enabled in the quality rule attribute configuration, you can use it to search or filter rules.

② List area

Displays a list of rule configurations, including Object type/Name, Rule name/ID, Trial run status, Activation status, Rule type, Rule template, Rule severity, Schedule type, Related knowledge base document, Last updated by, and Last updated time. Click the image icon before the refresh button to select the columns you want to display.

  • Activation status: We recommend performing a trial run before activating a rule. Activate rules that pass the trial run to avoid blocking online tasks with incorrect rules.

    • Once activated, the rule automatically runs on its configured schedule.

    • Once disabled, the rule no longer runs automatically but can still be run manually.

  • Related knowledge base document: Click View Details to view the knowledge base information associated with the rule. This includes the table name, check object, rule, and associated knowledge base document. You can also search, view, edit, and delete the knowledge base document. For more information, see View a knowledge base.

③ Operations area

You can perform operations such as 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 a rule.

  • Edit: After editing a rule, you must perform a trial run again.

  • Trial run: After a trial run, you can click the image icon to View Trial Run Log.

  • Run: After a run, you can view the check results in Check Records.

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

  • Associate knowledge base document: After associating a rule with a knowledge base document, you can view the associated information in quality rules and the governance workbench. You can select an unassociated knowledge base document. To create one, see Create a knowledge base.

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

④ Batch operations area

You can perform batch operations such as Trial run, Run, Configure scheduling, Enable, Disable, Modify business attributes, Associate knowledge base document, and Delete.

  • Trial run: Perform a trial run on multiple rules in batches. After the trial run, you can click the image icon to View Trial Run Log.

  • Run: Run multiple rules in batches. After the run, you can view the check results in Check Records.

  • Scheduling configuration: In the dialog box, you can filter schedules by schedule type or search by schedule name. You can also edit schedules and configure them for multiple quality rules in batches. You can only modify selected rules that are editable on the quality rule list page.

  • Enable: After enabling the activation status for multiple rules, the selected rules will automatically run according to their configured schedules. You can only enable selected rules that are editable on the quality rule list page.

  • Disable: After disabling the activation status for multiple rules, the selected rules will no longer run automatically but can be run manually. You can only disable selected rules that are editable on the quality rule list page.

  • Modify business attributes: You can modify business attributes in batches when the value type of the corresponding attribute field is single-select or multi-select.

    • If the value type is multi-select, you can append or modify attribute values.

    • If the value type is single-select, you can directly modify attribute values.

  • Associate knowledge base document: After a rule is associated with a knowledge base document, you can view the associated information in quality rules and the governance workbench. You can configure a knowledge base document for multiple monitoring objects in batches. To create one, see Create a knowledge base.

  • Delete: You can delete quality rule objects in batches. This action cannot be undone. Proceed with caution. You can only delete selected rules that are editable on the quality rule list page.

Create a schedule

Note
  • Each table supports a maximum of 20 schedules.

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

  • Duplicate schedules with identical configurations are automatically removed.

  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.

    Schedule type

    You can select timed schedule, data update-triggered schedule, or fixed task-triggered schedule.

    • Timed schedule: Performs periodic data quality checks based on a set schedule. This is suitable for scenarios where data generation times are relatively fixed.

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

      If the system time zone (the time zone in User Center) differs from the scheduling time zone (the time zone configured in Management Center > System Settings > Basic Settings), the rule runs according to the system time zone.

    • Data update-triggered schedule: When any code task runs, the system checks whether the task updates the specified check scope of the current table. This is suitable for tables whose modification tasks are not fixed or for tables that require close monitoring of every change.

      Note

      We recommend setting the check scope to the partitions updated by the task. For non-partitioned tables, the entire table is checked. The system automatically detects all data changes and performs the check to avoid omissions.

    • Fixed task-triggered schedule: This schedule type runs the configured quality rule before or after a specified task completes successfully. You can select tasks of the following engine types to trigger the quality rule: SQL, Offline Pipeline, Python, Shell, Virtual, Dlink, and Database SQL. This approach is ideal when table modification tasks are fixed.

      Note
      • You can only select tasks from the production environment for fixed task triggers. If the rule is a strong rule, a check failure may affect online tasks. Use this feature with caution based on your business requirements.

      • The supported engine types are MaxCompute.

      • Trigger condition: Select when to trigger the data quality check. Options include Trigger after all tasks run successfully, Trigger after each task runs successfully, and Trigger before each run of each task.

      • Triggering task: The following roles can select a task node in a production project to trigger the task. You can also search by node output name.

        • 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 in Prod/Basic projects can select task nodes from all production projects.

          Note

          If you select Trigger after all tasks run successfully, we recommend selecting tasks with the same scheduling cycle to avoid delays in rule execution and data quality check results.

    Scheduling conditions

    This is disabled by default. If enabled, the system evaluates the scheduling conditions before running the rule. The schedule runs only if the conditions are met; otherwise, the run is skipped.

    • Business Date/Execution Date: If the schedule type is Timed Schedule (which does not support execution date), Data Update-triggered Schedule, or Fixed Task-triggered Schedule, you can configure a date. You can select a General Calendar or a Custom Calendar. For information about how to create a custom calendar, see Create and manage public calendars.

      • If you select General Calendar, the available conditions are Month, Day of Week, and Date. Example:

        image

      • If you select Custom Calendar, the available conditions are Date Type and Tag. Example:

        image

    • Instance type: If the schedule type is data update-triggered schedule or fixed task-triggered schedule, you can configure the instance type. Options are periodic instance, backfill instance, and Manual Instance. 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 scheduling conditions to AND or OR.

  3. Click OK to save the scheduling configuration.

Scheduling configuration list

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

image.png

Area

Description

① Filter and search area

You can search for a schedule by its name.

You can filter by timed schedule, data update-triggered schedule, or fixed task-triggered schedule.

② List area

Displays the Schedule name, Schedule type, Last updated by, and Last updated time for each rule configuration.

③ Operations area

You can edit, clone, or delete a schedule.

  • Edit: Modify an existing schedule configuration.

    Important

    All rule configurations that reference this schedule will be updated synchronously. Proceed with caution.

  • Clone: Quickly copy a scheduling configuration.

  • Delete: You cannot delete a schedule that is referenced by a rule configuration.

Alert configuration

You can configure different notification methods for different rules to prioritize alerts based on severity. For example, you can use phone call alerts for strong rule failures and SMS alerts for weak rule failures. If a rule matches multiple alert configurations, you can set an activation policy.

Note

You can create a maximum of 20 alert configurations for a single monitoring 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

    Effective scope

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

    Note
    • For a single monitoring object, you can set one alert configuration for each of the three scopes: all rules, all strong rules, and all weak rules. Newly added rules will automatically match the corresponding alert configuration based on their rule severity. To change one of these configurations, you must edit the existing one.

    • The custom scope can include up to 200 existing rules for the current monitoring object.

    Alert configuration name

    The alert configuration name must be unique within a single monitoring object and can be up to 256 characters long.

    Alert recipient

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

    • Alert recipient: You can select Custom, On-call Schedule, or Quality Owner.

      You can configure up to 5 custom alert recipients and up to 3 on-call schedules.

    • Notification method: You can select Phone, Email, SMS, DingTalk as notification methods.

  3. Click OK to save the alert configuration.

Alert configuration list

After an alert configuration is created, you can sort, edit, or delete it from the alert configuration list.

image.png

No.

Description

① Sorting area

Configure the activation policy for when a quality rule matches multiple alert configurations:

  • The first matched alert configuration takes effect: When this policy is active, only the first matching alert configuration is triggered; all others are ignored. You can set the priority by sorting the alert configurations. Click Sort Rules, and then drag the image.png icon in front of the alert configuration name or use the icons in the Actions column to reorder. The icons from left to right are Move to Top and Move to Bottom. After reordering, click Finish Sorting.

    image.png

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

    For example, if you configure multiple alert configurations and select this option, the system merges alerts by notification method, alert recipient, and alert rule. If the alert recipient is the same and the alert recipient is Custom or Quality Owner, the alert messages are merged based on the merge policy.

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

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

② List area

Displays the name, effective scope, specific recipients for each alert type, and their corresponding notification methods for each alert configuration.

Effective scope: For custom alerts, you can view the configured object name and rule name. If the rule is deleted, the object name cannot be viewed. We recommend updating the alert configuration in this case.

image.png

③ Operations area

You can edit or delete an alert configuration.

  • Edit: Modify an existing alert configuration. If you change the alert recipients or notification methods, promptly inform the relevant personnel to avoid missing business-critical alerts.

  • Delete: After deletion, the rules that match this alert configuration will no longer trigger it. Proceed with caution.

Quality report

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

  • You can quickly filter check details by anomaly result, partition time, or by rule or object name keywords.

  • In the Actions column of the Rule Check Details list, click the image icon to view the rule check details for the quality rule.

  • In the Actions column of the Rule Check Details list, click the image icon to view the execution logs for the quality rule.

Quality rule permission management

  1. Click Permission Management to configure the Access to Details setting, which controls which members can view check records, quality rule details, and quality reports.

    Access to 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.

Quality rule runtime configuration

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

  • For a quality rule task that is retried upon failure, you can view the records of multiple retry attempts in the execution log on the check record details page.

  • All quality rules under a single monitoring object, including newly created ones and existing ones that have not yet run, will follow the latest runtime configuration.

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

    Parameter

    Description

    Effective scope

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

    Run timeout

    If a quality rule task's total runtime (which excludes time spent waiting for resources or scheduling) exceeds the configured threshold, the system terminates the task and marks it as failed. The default timeout is 1 hour. You can set a custom duration from 0 to 2 hours, with precision to two decimal places.

    Automatic retry upon failure

    You can configure failed quality rule tasks to retry automatically. This feature is disabled by default. If you enable it, you can set the Number of Retries and Retry Interval.

    • Number of Retries: The maximum number of automatic retries for a failed quality rule task. The default is 1, and you can set an integer from 1 to 3.

    • Retry Interval: The time interval between automatic retries. The default is 0 minutes, and 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 in the real-time metatable rule list. For more information, see Manage the monitoring object list.