全部产品
Search
文档中心

大数据开发治理平台 DataWorks:BatchCreateMetaEntities - 批量创建元数据实体

更新时间:Jun 05, 2026

批量创建元数据实体,同一批次需要为同一种类型,当前仅支持纯自定义类型和扩展表类型(对应Database/Table)。

接口说明

需要购买 DataWorks 专业版及以上版本才能使用。

调试

您可以在OpenAPI Explorer中直接运行该接口,免去您计算签名的困扰。运行成功后,OpenAPI Explorer可以自动生成SDK代码示例。

调试

授权信息

当前API暂无授权信息透出。

请求语法

POST  HTTP/1.1

请求参数

名称

类型

必填

描述

示例值

Entities

array<object>

实体列表,最多 5 个;同一批次必须为同一种 entityType

[]

array<object>

实体对象

EntityType

string

实体类型, 统一批次须一致,支持

  • 纯自定义类型,如 custom_entity-biz_api

  • 扩展表类型,如果注册了元数据实体类型 custom_dw-table,支持创建对应的数据库类型 custom_dw-database 和 数据表 类型 custom_dw-table 的对象

custom_entity-customer_api

Name

string

实体名称,由大小写字母、数字、下划线组成,必须以字母开头,最长 64 字符

api_001

Comment

string

注释

this is a comment

Attributes

object

实体属性,复杂值需要序列化为 JSON 字符串

string

实体属性

key1

CustomAttributes

object

自定义属性值,key 为自定义属性标识,value 当前仅支持单值。

重要 这里用到的自定义属性,需要通过 CreateCustomAttribute API 预先创建,比如通过 API 创建 ID 为 custom-attribute:owner_name的自定义属性后,这里可以配置 {'owner_name': ['Bob']}完成自定义属性配置

array

自定义属性值列表

string

自定义属性值

value1

扩展 Database

EntityType 使用 custom_xxx-database。其中 xxx 来自已创建的 custom_xxx-table 扩展 EntityDef。

Attributes

Attributes key是否必填类型/写法说明
parentMetaEntityIdString父实例 ID,必须是 instance 层,不能包含 catalog/database/schema/table/column
technicalMetadata.locationStringDatabase 存储位置

扩展 Table

EntityType 使用 custom_xxx-table。Table 的字段也需要在这里通过 Attributes.columns 一起注册。

Attributes

Attributes key是否必填类型/写法说明
parentMetaEntityIdString父 Database ID,必须是 database 层
tableTypeString表类型;不传默认 TABLE
partitionKeysJSON Array 字符串分区键,例如 ["dt"]
technicalMetadata.locationString存储位置
technicalMetadata.compressedBoolean 字符串或 JSON boolean是否压缩
technicalMetadata.inputFormatStringInputFormat
technicalMetadata.outputFormatStringOutputFormat
technicalMetadata.serializationLibraryStringSerDe 类
technicalMetadata.parametersJSON Object 字符串参数信息,例如 {"retention":"30"}
columnsJSON Array 字符串内嵌字段列表;用于随 Table 一起注册扩展 Column

Attributes.columns

columnsAttributes 里的一个 JSON Array 字符串。数组内每个对象支持以下字段:

columns item key是否必填类型/写法说明
nameString字段名;为空会跳过该字段
typeString字段类型;缺失会报 attributes.columns[i].type
commentString字段注释
positionInteger字段位置;不传默认按数组顺序 i + 1
partitionKeyBoolean是否分区键
primaryKeyBoolean是否主键
customAttributesObject字段自定义属性值

示例

创建扩展 Database

{
  "Entities": [
    {
      "EntityType": "custom_demo-database",
      "Name": "ods",
      "Comment": "ODS database",
      "Attributes": {
        "parentMetaEntityId": "custom_demo:demo_source",
        "technicalMetadata.location": "oss://bucket/ods"
      },
      "CustomAttributes": {
        "biz_owner": ["data_team"]
      }
    }
  ]
}

创建扩展 Table,同时注册字段

{
  "Entities": [
    {
      "EntityType": "custom_demo-table",
      "Name": "order_fact",
      "Comment": "订单事实表",
      "Attributes": {
        "parentMetaEntityId": "custom_demo-database:demo_source::ods",
        "tableType": "TABLE",
        "partitionKeys": "[\"dt\"]",
        "technicalMetadata.location": "oss://bucket/ods/order_fact",
        "technicalMetadata.compressed": "true",
        "technicalMetadata.parameters": "{\"retention\":\"30\",\"bizDomain\":\"trade\"}",
        "columns": "[{\"name\":\"id\",\"type\":\"BIGINT\",\"comment\":\"主键\",\"position\":1,\"primaryKey\":true,\"customAttributes\":{\"security_level\":[\"P1\"]}},{\"name\":\"dt\",\"type\":\"STRING\",\"comment\":\"分区日期\",\"position\":2,\"partitionKey\":true}]"
      },
      "CustomAttributes": {
        "biz_owner": ["data_team"]
      }
    }
  ]
}

注意事项

  • 扩展 Database 的 parentMetaEntityId 必须是实例层,例如 custom_demo:demo_source

  • 扩展 Table 的 parentMetaEntityId 必须是 Database 层,例如 custom_demo-database:demo_source::ods

  • 父子实体必须属于同一个扩展族,例如 custom_demo-table 的父级必须是 custom_demo-database

  • columns 只能随 Table 创建提供,不能通过 BatchCreateMetaEntities 单独创建 custom_xxx-column

  • 扩展实体写入路径不会按 MetaEntityDef.AttributeDefs 严格拦截未知 Attributes key;未知 key 通常会被忽略。

返回参数

名称

类型

描述

示例值

object

Schema of Response

RequestId

string

Id of the request

9E0C8E7A-C6BE-5A73-9562-2A030A80E8C6

Success

boolean

请求是否成功;部分实体失败时仍返回 true,逐条结果见 Results[].Success 和 Results[].ErrorMessage

true

Results

array

实体写入结果列表;逐条返回创建是否成功及失败原因

MetaEntityWriteResult

批量创建结果。

示例

正常返回示例

JSON格式

{
  "RequestId": "9E0C8E7A-C6BE-5A73-9562-2A030A80E8C6",
  "Success": true,
  "Results": [
    {
      "Name": "entity_01",
      "EntityType": "custom_entity-demo",
      "Id": "custom_entity-demo:entity_01",
      "Success": true,
      "ErrorMessage": "The specified parameters are invalid."
    }
  ]
}

错误码

访问错误中心查看更多错误码。

变更历史

更多信息,参考变更详情