{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/yunqi/json-schema/yunqi-dqc-rule-request-schema.json",
  "title": "DqcRuleRequest",
  "description": "Add Rule Request",
  "x-generated": "2026-11-06",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/yunqi-dqc-api-openapi.yml#/components/schemas/DqcRuleRequest",
  "type": "object",
  "properties": {
    "name": {
      "type": "string",
      "description": "Rule name"
    },
    "owner": {
      "type": "integer",
      "format": "int64",
      "description": "Owner user ID"
    },
    "datasourceType": {
      "type": "string",
      "title": "DatasourceEnum",
      "description": "数据源类型\n\n枚举说明：\n- `LakeHouse`: Clickzetta Lakehouse\n- `Databricks`: Databricks",
      "enum": [
        "LakeHouse",
        "Databricks"
      ]
    },
    "instanceName": {
      "type": "string"
    },
    "workspaceName": {
      "type": "string",
      "description": "Workspace name"
    },
    "objectName": {
      "type": "string",
      "description": "Object name"
    },
    "objectType": {
      "type": "string",
      "title": "ObjectTypeEnum",
      "description": "DQC 规则作用的对象类型\n\n枚举说明：\n- `TABLE`: 表\n- `PIPE`: pipe\n- `VIEW`: view\n- `VOLUME`: Volume\n- `DYNAMIC_TABLE`: Dynamic Table\n- `TABLE_STREAM`: Table Stream\n- `MATERIALIZED_VIEW`: materialized View",
      "enum": [
        "TABLE",
        "PIPE",
        "VIEW",
        "VOLUME",
        "DYNAMIC_TABLE",
        "TABLE_STREAM",
        "MATERIALIZED_VIEW"
      ]
    },
    "properties": {
      "type": "string",
      "description": "Check properties, comma-separated"
    },
    "checkerInfo": {
      "$ref": "#/$defs/CheckerInfo"
    },
    "tagType": {
      "type": "integer",
      "format": "int32",
      "description": "Tag type: 1=built-in, 2=custom SQL"
    },
    "tagCode": {
      "type": "string",
      "title": "TagEnum",
      "description": "DQC 规则标签类型（type=0 表级，type=1 字段级）\n\n枚举说明：\n- `defined_sql`: 表级 (type=0)\n- `table_count`: 表级 (type=0)\n- `avg`: 字段级 (type=1)\n- `count`: 字段级 (type=1)\n- `null_count`: 字段级 (type=1)\n- `max`: 字段级 (type=1)\n- `min`: 字段级 (type=1)\n- `sum`: 字段级 (type=1)\n- `count_distinct`: 字段级 (type=1)\n- `count_repetition`: 字段级 (type=1)\n- `pipe_kafka_latency`: 表级 (type=0)\n- `table_stream_kafka_latency`: 表级 (type=0)\n- `volume_file_count`: 表级 (type=0)",
      "enum": [
        "defined_sql",
        "table_count",
        "avg",
        "count",
        "null_count",
        "max",
        "min",
        "sum",
        "count_distinct",
        "count_repetition",
        "pipe_kafka_latency",
        "table_stream_kafka_latency",
        "volume_file_count"
      ]
    },
    "paramValues": {
      "type": "string",
      "description": "Parameter config"
    },
    "definedSql": {
      "type": "string",
      "description": "Custom SQL"
    },
    "condition": {
      "type": "string",
      "description": "Check condition"
    },
    "triggerType": {
      "type": [
        "string",
        "null"
      ],
      "title": "TriggerEnum",
      "description": "规则触发方式\n\n枚举说明：\n- `TEST`: 手动触发，仅测试，不发送告警\n- `TEST_ALERT`: 手动触发，测试并发送告警\n- `REST`: 通过 REST 接口手动触发\n- `SCHEDULE_TASK`: 由调度器定时触发\n- `PLAN`: 由执行计划触发",
      "enum": [
        "TEST",
        "TEST_ALERT",
        "REST",
        "SCHEDULE_TASK",
        "PLAN",
        null
      ]
    },
    "triggerCron": {
      "type": "string",
      "description": "Cron expression for scheduled trigger"
    },
    "mainSchedulerTaskId": {
      "type": [
        "integer",
        "null"
      ],
      "description": "调度任务触发：组合节点或者独立节点任务",
      "format": "int64"
    },
    "subSchedulerTaskId": {
      "type": [
        "integer",
        "null"
      ],
      "description": "调度任务触发：组合节点的子任务",
      "format": "int64"
    },
    "vcluster": {
      "type": "string",
      "description": "Execution cluster"
    },
    "timeout": {
      "type": "integer",
      "format": "int32",
      "description": "Timeout (hours)"
    },
    "desc": {
      "type": "string",
      "description": "Description"
    }
  },
  "required": [
    "instanceName",
    "workspaceName",
    "objectName",
    "name",
    "vcluster",
    "timeout",
    "checkerInfo"
  ],
  "$defs": {
    "CheckerInfo": {
      "type": "object",
      "title": "CheckerInfo",
      "description": "规则检查条件配置",
      "properties": {
        "checker": {
          "title": "CheckerEnum",
          "description": "检查类型：固定值或波动值\n\n枚举说明：\n- `FIXED`: 与固定阈值比较\n- `FLUX`: 与历史基准值的波动比较",
          "type": "string",
          "enum": [
            "FIXED",
            "FLUX"
          ]
        },
        "operator": {
          "title": "OperatorEnum",
          "description": "比较运算符\n\n枚举说明：\n- `EQUAL`: ==\n- `NOT_EQUAL`: !=\n- `LESS_THAN`: <\n- `LESS_EQUAL`: <=\n- `GREATER_THAN`: >\n- `GREATER_EQUAL`: >=",
          "type": "string",
          "enum": [
            "EQUAL",
            "NOT_EQUAL",
            "LESS_THAN",
            "LESS_EQUAL",
            "GREATER_THAN",
            "GREATER_EQUAL"
          ]
        },
        "value": {
          "description": "阈值（固定值模式下为具体数值，波动值模式下为波动比例或绝对量）"
        },
        "baseInfo": {
          "type": "string",
          "description": "基准信息（波动值模式下的基准描述）"
        },
        "fluxType": {
          "title": "FluxTypeEnum",
          "description": "波动类型，checker=FLUX 时有效\n\n枚举说明：\n- `ABS`: 与基准的绝对差值\n- `UP`: 仅检测上涨方向的波动\n- `DOWN`: 仅检测下跌方向的波动",
          "type": "string",
          "enum": [
            "ABS",
            "UP",
            "DOWN"
          ]
        }
      }
    }
  }
}