tencent cloud

文档反馈

CreateRule

最后更新时间:2024-06-21 15:11:56

1. API Description

Domain name for API request: wedata.tencentcloudapi.com.

Create quality rule interface

A maximum of 20 requests can be initiated per second for this API.

We recommend you to use API Explorer
Try it
API Explorer provides a range of capabilities, including online call, signature authentication, SDK code generation, and API quick search. It enables you to view the request, response, and auto-generated examples.

2. Input Parameters

The following request parameter list only provides API request parameters and some common parameters. For the complete common parameter list, see Common Request Parameters.

Parameter Name Required Type Description
Action Yes String Common Params. The value used for this API: CreateRule.
Version Yes String Common Params. The value used for this API: 2021-08-20.
Region Yes String Common Params. For more information, please see the list of regions supported by the product.
ProjectId No String Project ID
RuleGroupId No Integer Rule Group ID
Name No String Rule name
TableId No String Data Table ID
RuleTemplateId No Integer Rule Template List
Type No Integer Rule type 1.System Template, 2.Custom Definition Template, 3.Custom Definition SQL
QualityDim No Integer Quality Dimension of Rule (1: Accuracy, 2: Uniqueness, 3: Integrity, 4: Consistency, 5: Timeliness, 6: Validity)
SourceObjectDataTypeName No String Source Field Detailed Type, int, string
SourceObjectValue No String Source Field Name
ConditionType No Integer Detection Range 1.Whole Table 2.Conditional Scan
ConditionExpression No String Conditional Scan WHERE Condition Expression
CustomSql No String Custom Definition SQL
CompareRule No CompareRule Alert Trigger Condition
AlarmLevel No Integer Alert Trigger Level 1.Low, 2.Medium, 3.High
Description No String Rule Description
DatasourceId No String Data Source ID
DatabaseId No String Database ID
TargetDatabaseId No String Target Database Id
TargetTableId No String Target Table Id
TargetConditionExpr No String Target Filter Condition Expression
RelConditionExpr No String Source Field and Target Field Association Condition ON Expression
FieldConfig No RuleFieldConfig Custom Definition Template SQL Expression Field Replacement Parameter
TargetObjectValue No String Target Field Name CITY
SourceEngineTypes.N No Array of Integer Supported Execution Engine List for the Rule

3. Output Parameters

Parameter Name Type Description
Data Rule RuleNote: This field may return null, indicating that no valid value can be obtained.
RequestId String The unique request ID, generated by the server, will be returned for every request (if the request fails to reach the server for other reasons, the request will not obtain a RequestId). RequestId is required for locating a problem.

4. Example

Example1 Create quality rule interface

Create a single rule in the Quality Rule Group

Input Example

POST / HTTP/1.1
Host: wedata.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: CreateRule
<Common Request Parameters>{
    "ProjectId": "11114192353510111488",
    "RuleGroupId": 1,
    "Name": "autotest_s3mC",
    "TableId": "E-UEBWQB-XRjERluUg",
    "RuleTemplateId": 1,
    "Type": 1,
    "QualityDim": 1,
    "SourceObjectDataTypeName": "int",
    "SourceObjectValue": "age",
    "ConditionType": 1,
    "ConditionExpression": "pt=substring('${yyyyMMddHHmmss-1H}',1,10)",
    "CustomSql": "SELECT id,name FROM `at_hive_bj`.`at_hive_22`;",
    "CompareRule": {
        "Items": [
            {
                "CompareType": 1,
                "Operator": ">",
                "ValueComputeType": 1,
                "ValueList": [
                    {
                        "ValueType": 3,
                        "Value": "0"
                    }
                ]
            }
        ],
        "CycleStep": 1,
        "ComputeExpression": "0"
    },
    "AlarmLevel": 1,
"Description": "testing",
    "DatasourceId": "678990",
    "DatabaseId": "97yuhijbkh08y97uhi",
    "TargetDatabaseId": "97yuhijbkh08y97uhi",
    "TargetTableId": "E-UEBWQB-XRjERluUg",
    "TargetConditionExpr": "ct='${yyyy-mm-dd-1}'",
    "RelConditionExpr": "sourceTable.id=targetTable.id",
    "FieldConfig": {
        "TableConfig": [
            {
                "DatabaseId": "NW0VL_YYPESvi8w",
                "DatabaseName": "default",
                "TableId": "EHdPET2IKQ2KBhGw",
                "TableName": "dq_student",
                "TableKey": "table_1",
                "FieldConfig": [
                    {
                        "FieldKey": "table_1.column_1",
                        "FieldDataType": "int",
                        "FieldValue": "id"
                    }
                ]
            }
        ],
        "WhereConfig": [
            {
                "FieldKey": "param_1",
                "FieldDataType": "int",
                "FieldValue": "id"
            }
        ]
    },
    "TargetObjectValue": "value",
    "SourceEngineTypes": [
        2,
        4
    ]
}

Output Example

{
    "Response": {
        "Data": {
            "RuleId": 1,
            "RuleGroupId": 1,
            "TableId": "E-UEBWsQB-XRjERluUg",
            "TableName": "dq",
            "DatabaseId": "roeqgaBtT4m22RyjnMQ",
            "DatasourceId": 6789789,
            "Name": "testing",
            "Type": 1,
            "RuleTemplateId": 1,
            "RuleTemplateContent": "Description",
            "QualityDim": 1,
            "SourceObjectType": 1,
            "SourceObjectDataType": 1,
            "SourceObjectDataTypeName": "int",
            "SourceObjectValue": "age",
            "ConditionType": 1,
            "ConditionExpression": "pt=substring('${yyyyMMddHHmmss-1H}',1,10)",
            "CustomSql": "SELECT id,name FROM `at_hive_bj`.`at_hive_22`;",
            "CreateTime": "2024-02-22 21:49:55",
            "TableOwnerName": "AUTO_TEST",
            "SourceEngineTypes": [
                2,
                4,
                16
            ],
            "ExecStrategy": {
                "CycleStep": null,
                "CycleType": null,
                "DelayTime": null,
                "EndTime": null,
                "ExecEngineType": null,
                "ExecPlan": null,
                "ExecQueue": null,
                "ExecutorGroupId": null,
                "ExecutorGroupName": null,
                "MonitorType": 2,
                "RuleGroupId": null,
                "RuleId": 1263,
                "RuleName": "field_minimum_trigger_fail",
                "StartTime": null,
                "TaskAction": null,
                "Tasks": [
                    {
                        "TaskId": "20240205135835",
                        "TaskName": "at_qualire_task_1708606293AquG",
                        "WorkflowId": "1c2a85c6-d181-11eeb-b8cef68a6637"
                    }
                ]
            },
            "Subscription": {
                "Receivers": [
                    {
                        "ReceiverName": "yukzhang",
                        "ReceiverUserId": 100581064
                    }
                ],
                "RuleGroupId": null,
                "RuleId": 125,
                "RuleName": null,
                "SubscribeType": [
                    1
                ],
                "WebHooks": []
            },
            "CompareRule": {
                "Items": [
                    {
                        "CompareType": 1,
                        "Operator": ">",
                        "ValueComputeType": 1,
                        "ValueList": [
                            {
                                "ValueType": 3,
                                "Value": "0"
                            }
                        ]
                    }
                ],
                "CycleStep": 1
            },
            "AlarmLevel": 2,
            "Description": "testing",
            "Operator": "zhangsan",
            "TargetDatabaseId": "6788897uigygh967q23e",
            "TargetDatabaseName": "test",
            "TargetTableId": "y8o97hufe378qygfvbqd",
            "TargetTableName": "dq",
            "TargetConditionExpr": "ct='${yyyy-mm-dd-1}'",
            "RelConditionExpr": "sourceTable.id=targetTable.id",
            "FieldConfig": {
                "TableConfig": [
                    {
                        "DatabaseId": "NW0VL_YYPESvi8w",
                        "DatabaseName": "default",
                        "TableId": "EHdPET2IKQ2KBhGw",
                        "TableName": "dq_student",
                        "TableKey": "table_1",
                        "FieldConfig": [
                            {
                                "FieldKey": "table_1.column_1",
                                "FieldDataType": "int",
                                "FieldValue": "id"
                            }
                        ]
                    }
                ],
                "WhereConfig": [
                    {
                        "FieldKey": "param_1",
                        "FieldDataType": "int",
                        "FieldValue": "id"
                    }
                ]
            },
            "MultiSourceFlag": true,
            "WhereFlag": true,
            "TemplateSql": "select count(${table_1.column_1}) from ${table_1}",
            "SubQualityDim": 1,
            "TargetObjectType": 1,
            "TargetObjectDataType": 1,
            "TargetObjectDataTypeName": "name",
            "TargetObjectValue": "value"
        },
        "RequestId": "e447b6ad-c3c3-44b5-b473-dbfc39591f93"
    }
}

5. Developer Resources

SDK

TencentCloud API 3.0 integrates SDKs that support various programming languages to make it easier for you to call APIs.

Command Line Interface

6. Error Code

The following only lists the error codes related to the API business logic. For other error codes, see Common Error Codes.

Error Code Description
FailedOperation Operation Failure.
InvalidParameter.DuplicateName Duplicate Name.
InvalidParameter.ServiceIsBusy Service Busy, please try again later.