Configure data quality tests
In DataWorks Data Studio, you can configure data quality monitoring rules for data development nodes to validate the data tables they produce. This feature deeply integrates the definition and testing of quality rules into the SQL development workflow, addressing common issues such as delayed rule configuration, late discovery of data problems, and high rule maintenance costs in traditional approaches.
Feature overview
Overview
When you edit a SQL node in the DataWorks IDE, you can configure data quality rules directly for the output data tables of that node. The rules are defined in YAML format and bound to the SQL code. They can be tested during development, submitted and deployed together with the node, and automatically executed during scheduled runs.
-
Test during development: Test and validate quality rules during the coding phase.
-
Synchronized versioning: Quality rules are part of the node code and are versioned and deployed together with the node.
-
Validate in production: Deployed rules are automatically executed during scheduled runs to ensure reliable data output.
Relationship with Data Quality
The Data Quality module under Data Governance also supports configuring monitoring rules on data tables, and provides rich rule templates and the ability to bind rules to scheduled tasks. Its relationship with the Data Studio quality test feature is as follows:
Positioning differences
-
In-IDE rules: Lightweight rules that evolve with code versions, suitable for validation scenarios tightly coupled with specific node logic.
-
Data Quality Center: Provides global, cross-task unified data quality governance capabilities.
Working together
-
In the IDE's Quality Test feature, you can directly reference and reuse rule templates created in Data Quality, ensuring rule consistency and improving configuration efficiency.
-
If you configure rules for the same data table in both the IDE and Data Quality, both sets of rules take effect and run independently.
Recommendation: To avoid duplicate configurations and redundant alerts, choose one primary method to manage rules for a data table based on your actual governance scenario.
Usage notes
Currently, only MaxCompute SQL nodes support configuring data quality rules directly.
Configuration guide
Entry point
-
Go to Data Studio and open a MaxCompute SQL node that contains data output logic (such as
INSERT OVERWRITE). -
On the toolbar above the node editor, click Quality Test. The Quality Test tab automatically opens at the bottom of the IDE.
Write quality rules
Quality rules are defined using the YAML-based Data Quality Spec. Both AI-generated and manually written rules are supported.
AI-generated rules (recommended)
This feature uses AI to significantly reduce the complexity of writing rules.
-
On the Quality Test tab, click the AI Generation Rules button.
-
Enter an instruction in the dialog, for example: Check that the id column is not null.
-
After analysis, the system generates recommended rules in the editor. Click Accept to use them directly or modify them as needed.
Manually writing rules (script mode)
For scenarios that require precise control over rules, you can define them by writing YAML code.
- datasets: # If the node has multiple output tables, you can set multiple datasets to configure quality rules for different tables
- type: Table
dataSource:
name: odps_first
tables:
- table1 # Currently only one table is supported, wildcards are not supported
filter: partition:dt=${bizdate} # Supports filtering by where condition (no need to enter the where keyword) or by partition (fixed prefix "partition:").
rules:
- templateId: SYSTEM:field:null_value:fixed # A table can support multiple rules, you can select the "Rule Template" on the left to quickly insert and modify the variables in the template.
fields:
- id
pass:
- when = 0
name: Number of null value rows in field id is 0
severity: High
identity: dq_suggestion_monitor_spec_Number of null value rows in field id is 0
- templateId: #
- datasets:
#...
-
Data quality monitoring rules follow the DataWorks Data Quality Spec. For details, see: Data quality configuration.
-
Click a rule template on the right to automatically insert a complete rule snippet into the editor, then adjust it as needed.
You can configure rules visually in the rule template library in Data Quality.
-
The blocking and restriction behavior of strong and weak rules configured here on downstream tasks is fully consistent with that of Data Quality. For details, see: Data quality rules.
The editor provides rich assistance features to improve efficiency:
-
Syntax highlighting: Uses colors to distinguish YAML keywords, rule names, functions, table names, and column names.
-
Auto-completion: As you type, suggests keywords, built-in rule templates, and table and column names available in the current context.
-
Real-time validation: Highlights YAML syntax errors in real time and validates whether referenced table names and column names exist. Nonexistent objects are underlined with a wavy line.
YAML is sensitive to indentation. Follow the indentation syntax rules carefully.
Testing and validation
After configuring rules, you can run tests directly in the IDE to verify their effectiveness without waiting for scheduled runs.
-
Testing methods:
-
Standalone test: In the QualityTest panel, click Test Run to trigger a test run for all rules or a single rule.
-
Linked test: In the QualityTest panel, select Trigger quality check after node success, and then click Run on the top toolbar of the IDE. The system first runs the SQL code and then runs the quality test after the SQL succeeds.
-
Workflow test: On the workflow DAG page, click the Run button on the toolbar above the workflow, or run a single specified script. The system also runs the task code and quality test in sequence.
-
-
View results:
Run results are displayed directly in the QualityTest panel. Click the structured logs in the upper-right corner to view the filtered results of quality rule runs. For rules with red exceptions, click to view details and jump to the run records in Data Quality.
Deployment and scheduling
Deployment and version management
-
Submit and deploy: When you submit and deploy a node, the YAML rules configured in the Quality Test panel are deployed to the production environment as part of the node.
-
Version comparison: On the Quality Configuration tab, you can view the rule configuration of the current version and perform a Diff against historical versions to track every change to the rules.
Scheduled runs in production
Quality rules deployed to production are automatically triggered each time the task is scheduled to run.
-
Execution timing: Quality rule validation runs automatically after the associated SQL node succeeds. The final status of the node instance depends on both the SQL execution result and the quality validation result.
-
Blocking mechanism:
-
Strong rules (
severity: High): If a strong rule fails validation (red exception), the entire node instance fails, which blocks downstream tasks. -
Weak rules (
severity: Normal or unset): If a weak rule fails validation, it does not block the node, and the node instance still succeeds.
-
-
Alert notifications: Regardless of whether a rule blocks the node, whenever the validation result is abnormal (red exception, orange exception, or validation failure), the system sends an email alert to the node owner.
NoteThe alert method cannot be changed at this time.