When you manage data quality at scale, writing the same rule logic repeatedly for each table is error-prone and hard to maintain. Rule templates let you define custom SQL monitoring logic once and reuse it across as many tables as you need. When you update a template, only the rules that actively reference it are affected—monitoring rules created from earlier versions remain unchanged.
Prerequisites
Before you begin, ensure that you have:
DataWorks Enterprise Edition or a higher edition activated
Why use rule templates
| Recommendation | Benefit |
|---|---|
| Define SQL logic once in a template | Apply the same monitoring rule to multiple tables without rewriting SQL each time |
| Organize templates in folders | Group related templates by domain or team for easier discovery and reuse |
| Update templates centrally | Change a template's logic in one place; only rules that reference the changed template are affected |
Create a rule template
Log on to the DataWorks console. In the top navigation bar, select the target region. In the left-side navigation pane, choose Data Governance > Data Quality, select a workspace from the drop-down list, and click Go to Data Quality.
In the left-side navigation pane, choose Assets > Rule Template Library.
Click the
icon and select Create Folder.In the Create Folder dialog box, set the Name and Location parameters and click OK.
In the directory tree, right-click the folder and select Create Rule Template.
Note: You can also rename or delete the folder from the right-click menu.
In the Create Rule Template dialog box, configure the parameters.

Parameter Description Template Name The name of the rule template. Field The fields to monitor. Fixed to Custom SQL. Sampling Method The sampling method. Fixed to Custom SQL. Set Flag The SETclause of the SQL statement used to query the monitored fields. Separate multiple statements with commas (,). Do not add a semicolon (;) at the end of each statement.Check type The threshold type. Valid values: Numeric type and Fluctuation. Verification Method The comparison method for the check result. Options depend on the Check type value—see the table below. Custom SQL The SQL statement that queries the fields to monitor. Use ${tableName}as a placeholder for the table name. The query must return a single value that can be compared against a threshold.Location The folder in which to store the template. Verification methods and required thresholds by check type
The Verification Method options and the thresholds you must define when applying the template both depend on the Check type you select.
Check type Verification method options Thresholds required when applying Numeric type Compare with a specified value — the query must return a single COUNT or SUM value, which is compared against a fixed number Normal threshold + critical threshold Fluctuation Compare the current value with the average value of the last 7 days Normal threshold + warning threshold + critical threshold Fluctuation Compare the current value with the average value of the last 30 days Normal threshold + warning threshold + critical threshold Fluctuation Compare the current value with the value 1 day before Normal threshold + warning threshold + critical threshold Fluctuation Compare the current value with the value 7 days before Normal threshold + warning threshold + critical threshold Fluctuation Compare the current value with the value 30 days before Normal threshold + warning threshold + critical threshold Fluctuation The variance between the current value and the value 7 days before Normal threshold + warning threshold + critical threshold Fluctuation The variance between the current value and the value 30 days before Normal threshold + warning threshold + critical threshold Fluctuation Compare with the value 1, 7, and 30 days before Normal threshold + warning threshold + critical threshold Fluctuation Compare with the value of the previous cycle Normal threshold + warning threshold + critical threshold Custom SQL and the `${tableName}` placeholder
Use
${tableName}in your SQL to make the template reusable across tables. DataWorks substitutes the actual table name at runtime. The query must return a single value in a single row. For Numeric type checks, that value must be the output of COUNT or SUM.Click OK.
Manage a rule template
Click the name of a template in the Rule Template Library to open its details page. From there you can view, edit, delete, or copy the template.
| Action | Steps |
|---|---|
| View | Review the template's parameter settings, the rules that reference it (Application List tab), and its operation history (View Log tab). The View Log tab records the user, timestamp, and details of each operation. |
| Edit | Click Edit in the upper-right corner, update the parameters in the Edit Rule Template dialog box, and click OK. |
| Delete | Click Delete in the upper-right corner and confirm in the Delete Template message. |
| Copy | Click Copy in the upper-right corner. In the Clone Rule Template dialog box, set a new Template Name and Location, then click OK. |
Note: Changes to a custom rule take effect only for tasks that reference the changed custom rule. Existing tasks for which the original custom rule is applied are not affected.
Apply a rule template to a monitoring rule
From the Data Quality page, choose Configure Rules > Configure by Table in the left-side navigation pane.
In the Connection section, select the database where the table for which you want to configure rules resides. Find the target table by filtering on database type, database, and table name. Click the table name or click Rule Management in the Actions column to open the Table Quality Details page. The page lists all rules configured for the table. For rules not associated with a monitor, you can set the running mode directly from this page.

On the Rule Management tab, select a monitor and click Create Rule. The Create Rule panel opens.
Select your custom rule template. The FLAG parameter and SQL fields are populated automatically from the template. Set the Rule Name and configure thresholds based on the template's check type:
Check type Thresholds to configure Numeric type Normal threshold and critical threshold Fluctuation Normal threshold, warning threshold, and critical threshold 
Click Determine.