In Data Quality, you can manage a set of custom rule templates and use the rule templates to improve the efficiency of rule configuration.

Prerequisites

DataWorks Enterprise Edition or a more advanced edition is activated.

Background information

You can create a rule template on the Rule Templates and Monitoring Rules pages. After the rule template is created, you can manage and use it.

Create a rule template on the Rule Templates page

  1. Go to the Data Quality page.
    1. Log on to the DataWorks console.
    2. In the left-side navigation pane, click Workspaces.
    3. On the Workspaces page, find the workspace in which you want to create a rule template and click Data Analytics in the Actions column.
    4. On the DataStudio page, click the More icon icon in the upper-left corner and choose All Products > Data governance > Data Quality.
  2. On the Data Quality page, choose Configuration > Rule Templates in the left-side navigation pane.
  3. On the Rule Templates page, click the Create icon icon and select Create Folder.
  4. In the Create Folder dialog box, set the Name and Location parameters and click OK.
  5. Right-click the created folder and select Create Rule Template.
    You can also rename or delete a folder.
  6. In the Create Rule Template dialog box, set the parameters as required.
    Create a rule template
    Parameter Description
    Template Name The name of the rule template.
    Field The fields to be monitored. You can set this parameter only to Custom SQL.
    Sampling Method The statistical function of the rule. You can set this parameter only to Custom SQL.
    Set Flag The SET clause of the SQL statement that is used to query the fields to be monitored.
    Note Separate multiple statements with commas (,). You do not need to add a semicolon (;) at the end of each statement.
    Check type The threshold type of the rule. Valid values: Numeric type, Fluctuation.
    Verification Method The verification method of the rule. The verification methods that can be selected vary based on the threshold type.
    • If you set the Check type parameter to Numeric type, you can set this parameter only to Compare with a specified value.

      Only the value that is calculated by the COUNT or SUM function can be returned. The return value is compared with a specified value.

    • If you set the Check type parameter to Fluctuation, the valid values of this parameter are Compare the current value with the average value of the last 7 days, Compare the current value with the average value of the last 30 days, Compare the current value with the value 1 day before, Compare the current value with the value 7 days before, Compare the current value with the value 30 days before, The variance between the current value and the value 7 days before, The variance between the current value and the value 30 days before, Compare with the value 1, 7, and 30 days before, and Compare with the value of the previous cycle.
    • If you set the Check type parameter to Auto-Generated Threshold, you can set this parameter only to Dynamic threshold.
    Custom SQL The SQL statement that is used to query the fields to be monitored. You can use ${tableName} to specify a table name.
    Note Make sure that the return value is the value in a row of a column and can be compared with the specified threshold.
    Location The name of the folder in which you want to store the rule template.
  7. Click OK.

Create a rule template on the Monitoring Rules page

  1. Go to the Data Quality page.
  2. On the Data Quality page, click Monitoring Rules in the left-side navigation pane.
  3. On the Monitoring Rules page, select a compute engine or data store, find a table or topic, and then click View Monitoring Rules in the Actions column.
    Note In this example, a MaxCompute table is used.
  4. On the page that appears, select a partition filter expression and click the Custom Rules tab.
    Custom Rules
  5. On the Custom Rules tab, find the custom rule based on which you want to create a rule template and click Generate Template in the Actions column.
  6. In the Create Rule Template dialog box, set the parameters as required.
    Create a rule template
    Parameter Description
    Template Name The name of the rule template.
    Field The fields to be monitored. You can set this parameter only to Custom SQL.
    Sampling Method The statistical function of the rule. You can set this parameter only to Custom SQL.
    Set Flag The SET clause of the SQL statement that is used to query the fields to be monitored.
    Note Separate multiple statements with commas (,). You do not need to add a semicolon (;) at the end of each statement.
    Check type The threshold type of the rule. Valid values: Numeric type, Fluctuation.
    Verification Method The verification method of the rule. The verification methods that can be selected vary based on the threshold type.
    • If you set the Check type parameter to Numeric type, you can set this parameter only to Compare with a specified value.

      Only the value that is calculated by the COUNT or SUM function can be returned. The return value is compared with a specified value.

    • If you set the Check type parameter to Fluctuation, the valid values of this parameter are Compare the current value with the average value of the last 7 days, Compare the current value with the average value of the last 30 days, Compare the current value with the value 1 day before, Compare the current value with the value 7 days before, Compare the current value with the value 30 days before, The variance between the current value and the value 7 days before, The variance between the current value and the value 30 days before, Compare with the value 1, 7, and 30 days before, and Compare with the value of the previous cycle.
    • If you set the Check type parameter to Auto-Generated Threshold, you can set this parameter only to Dynamic threshold.
    Custom SQL The SQL statement that is used to query the fields to be monitored. You can use ${tableName} to specify a table name.
    Note Make sure that the return value is the value in a row of a column and can be compared with the specified threshold.
    Location The name of the folder in which you want to store the rule template.
  7. Click OK.
  8. In the left-side navigation pane, choose Configuration > Rule Templates to view the created rule template.

Manage a rule template

On the Rule Templates page, you can click the name of a rule template to go to the template details page. On this page, you can view, edit, delete, or copy the rule template.Manage a rule template
Action Description
View You can view the parameter settings and logs of the rule template and the rules that use the rule template.
  • The Application List tab displays the rules that use the rule template.
  • The View Log tab displays the operations logs of the rule template, including the user who performed each operation, the time when each operation was performed, and the operation details.
Edit Click Edit in the upper-right corner. In the Edit Rule Template dialog box, modify the parameters as required and click OK.
Delete Click Delete in the upper-right corner. In the Delete Template message, click OK.
Copy Click Copy in the upper-right corner. In the Clone Rule Template dialog box, set the Template Name and Location parameters and click OK.

Use a rule template

When you create a monitoring rule, you can select a custom rule template to create the rule based on the rule template.

  1. Go to the Data Quality page.
  2. On the Data Quality page, click Monitoring Rules in the left-side navigation pane.
  3. On the Monitoring Rules page, select a compute engine or data store, find a table or topic, and then click View Monitoring Rules in the Actions column.
    Note In this example, a MaxCompute table is used.
  4. On the page that appears, select a partition filter expression and click Create rules.
  5. On the Template Rules tab of the Create rules panel, click Add Monitoring Rule.
  6. Set the parameters for the rule. In this example, set the Rule Source parameter to Rule Templates and select a rule template. For more information about the parameter description, see Configure monitoring rules.
    Create rules
  7. Click Batch Create.