CreateDataQualityRule

Updated at:

Creates a quality rule.

Note

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

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

No authorization for this operation. If you encounter issues with this operation, contact technical support.

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:

  • Normal

  • High

Valid values:

  • High :

    High.

  • Normal :

    Normal.

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

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

  • emr

  • cdh

  • hologres

  • analyticdb_for_postgresql

  • analyticdb_for_mysql

  • starrocks

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: the number of rows in the table.

  • Min: the minimum value of the field.

  • Max: the maximum value of the field.

  • Avg: the average value of the field.

  • DistinctCount: the number of unique values in the field.

  • DistinctPercent: the ratio of the number of unique values in the field to the total number of rows.

  • DuplicatedCount: the number of duplicate values in the field.

  • DuplicatedPercent: the ratio of the number of duplicate values in the field to the total number of rows.

  • TableSize: the size of the table.

  • NullValueCount: the number of rows where the field is null.

  • NullValuePercent: the ratio of rows where the field is null.

  • GroupCount: the number of rows corresponding to each value after aggregation by field value.

  • CountNotIn: the number of rows that do not match the enumerated values.

  • CountDistinctNotIn: the number of unique values that do not match the enumerated values.

  • UserDefinedSql: sample collection by using custom SQL statements.

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

  • Fluctation

  • FluctationDiscreate

  • Auto

  • Average

  • Variance

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:

  • Fluctuation increase greater than 0.01: $checkValue > 0.01

  • Fluctuation decrease greater than 0.01: $checkValue < -0.01

  • Absolute value of the fluctuation rate: abs($checkValue) > 0.01

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:

  • Fluctuation increase greater than 0.01: $checkValue > 0.01

  • Fluctuation decrease greater than 0.01: $checkValue < -0.01

  • Absolute value of the fluctuation rate: abs($checkValue) > 0.01

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:

  • Fluctuation increase greater than 0.01: $checkValue > 0.01

  • Fluctuation decrease greater than 0.01: $checkValue < -0.01

  • Absolute value of the fluctuation rate: abs($checkValue) > 0.01

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

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.