CreateDataQualityRule
Creates a quality rule.
This API has been deprecated. We recommend migrating to dataworks-public(2024-05-18) - CreateDataQualityScan for enhanced functionality and continued support. While the deprecated API remains temporarily accessible, no further updates or bug fixes will be provided.
Operation description
You must purchase DataWorks Basic Edition or a later edition to use this feature.
Try it now
Test
RAM authorization
Request parameters
|
Parameter |
Type |
Required |
Description |
Example |
| Name |
string |
Yes |
The name of the rule. |
The table cannot be empty. |
| ProjectId |
integer |
Yes |
The ID of the DataWorks workspace. |
10726 |
| Enabled |
boolean |
No |
Specifies whether the quality rule is enabled. |
true |
| Severity |
string |
No |
The severity level of the rule for business operations, which corresponds to strong and weak rules on the page. Valid values:
Valid values:
|
Normal |
| Description |
string |
No |
The description of the rule. The description can be up to 500 characters in length. |
this is a odps _sql task |
| Target |
object |
Yes |
The object monitored by the rule. |
|
| Type |
string |
No |
The monitored object type. Valid values:
|
Table |
| DatabaseType |
string |
Yes |
The type of the database to which the table belongs. This parameter is required when the dataset is of the table type. Valid values:
|
maxcompute |
| TableGuid |
string |
Yes |
The unique ID of the table to which the rule applies in Data Map. |
odps.unit_test.tb_unit_test |
| PartitionSpec |
string |
No |
The partition settings of the partitioned table. |
ds=$[yyyymmdd-1] |
| TemplateCode |
string |
Yes |
The unique identifier of the rule template referenced by the rule. |
SYSTEM:table:table_count:fixed |
| SamplingConfig |
object |
No |
The settings required for sample collection. |
|
| Metric |
string |
No |
The name of the sampling metric. This parameter is not required when a template is used. Valid values:
|
Count |
| MetricParameters |
string |
No |
The parameters required for sample collection. |
{ "Columns": [ "id", "name" ] , "SQL": "select count(1) from table;"} |
| SettingConfig |
string |
No |
The runtime parameter setting statements that are inserted and executed before the sampling statements are executed. The statements can be up to 1,000 characters in length. Only MaxCompute is supported. |
SET odps.sql.udf.timeout=600s; SET odps.sql.python.version=cp27; |
| SamplingFilter |
string |
No |
The conditions used to filter out unneeded data during sampling. The conditions can be up to 16,777,215 characters in length. |
id IS NULL |
| CheckingConfig |
object |
No |
The sample check settings. |
|
| Type |
string |
No |
The threshold calculation method. This parameter is not required when a template is used. Valid values:
|
Fixed |
| ReferencedSamplesFilter |
string |
No |
For some types of thresholds, reference samples must be queried, and the values of the reference samples are aggregated to obtain the threshold for comparison. This parameter specifies an expression that represents the query method for the reference samples. |
{ "bizdate": [ "-1", "-7", "-1m" ] } |
| Thresholds |
object |
No |
The threshold settings. |
|
| Expected |
object |
No |
The expected threshold settings. |
|
| Operator |
string |
No |
The comparison operator. Valid values:
|
> |
| Value |
string |
No |
The threshold value. |
100.0 |
| Expression |
string |
No |
The threshold expression. For fluctuation rules, you must use an expression to represent the fluctuation threshold. Examples:
You can also use an expression to configure the threshold for fixed value rules. If both are configured, the expression takes precedence over Operator and Value. |
$checkValue <= 0.01 |
| Warned |
object |
No |
The threshold settings for common warnings. |
|
| Operator |
string |
No |
The comparison operator. Valid values:
|
> |
| Value |
string |
No |
The threshold value. |
100.0 |
| Expression |
string |
No |
The threshold expression. For fluctuation rules, you must use an expression to represent the fluctuation threshold. Examples:
You can also use an expression to configure the threshold for fixed value rules. If both are configured, the expression takes precedence over Operator and Value. |
$checkValue > 0.01 |
| Critical |
object |
No |
The threshold settings for critical warnings. |
|
| Operator |
string |
No |
The comparison operator. Valid values:
|
> |
| Value |
string |
No |
The threshold value. |
100.0 |
| Expression |
string |
No |
The threshold expression. For fluctuation rules, you must use an expression to represent the fluctuation threshold. Examples:
You can also use an expression to configure the threshold for fixed value rules. If both are configured, the expression takes precedence over Operator and Value. |
$checkValue > 0.05 |
| ErrorHandlers |
array<object> |
No |
The list of handlers for quality rule check issues. |
|
|
object |
No |
The handler for quality rule check issues. |
||
| Type |
string |
No |
The handler type. Valid values:
|
SaveErrorData |
| ErrorDataFilter |
string |
No |
If the rule is a custom SQL rule, you must specify an SQL statement to filter the problematic data. |
SELECT * FROM tb_api_log WHERE id IS NULL |
Response elements
|
Element |
Type |
Description |
Example |
|
object |
The return value. |
||
| RequestId |
string |
The ID of the API request. |
691CA452-D37A-4ED0-9441 |
| Id |
integer |
The ID of the rule. |
19715 |
Examples
Success response
JSON format
{
"RequestId": "691CA452-D37A-4ED0-9441\n",
"Id": 19715
}
Error codes
See Error Codes for a complete list.
Release notes
See Release Notes for a complete list.