批量创建元数据实体,同一批次需要为同一种类型,当前仅支持纯自定义类型和扩展表类型(对应Database/Table)。
接口说明
需要购买 DataWorks 专业版及以上版本才能使用。
调试
您可以在OpenAPI Explorer中直接运行该接口,免去您计算签名的困扰。运行成功后,OpenAPI Explorer可以自动生成SDK代码示例。
调试
授权信息
请求语法
POST HTTP/1.1
请求参数
|
名称 |
类型 |
必填 |
描述 |
示例值 |
| Entities |
array<object> |
是 |
实体列表,最多 5 个;同一批次必须为同一种 entityType |
[] |
|
array<object> |
否 |
实体对象 |
||
| EntityType |
string |
是 |
实体类型, 统一批次须一致,支持
|
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 | 是否必填 | 类型/写法 | 说明 |
parentMetaEntityId | 是 | String | 父实例 ID,必须是 instance 层,不能包含 catalog/database/schema/table/column |
technicalMetadata.location | 否 | String | Database 存储位置 |
扩展 Table
EntityType 使用 custom_xxx-table。Table 的字段也需要在这里通过 Attributes.columns 一起注册。
Attributes
| Attributes key | 是否必填 | 类型/写法 | 说明 |
parentMetaEntityId | 是 | String | 父 Database ID,必须是 database 层 |
tableType | 否 | String | 表类型;不传默认 TABLE |
partitionKeys | 否 | JSON Array 字符串 | 分区键,例如 ["dt"] |
technicalMetadata.location | 否 | String | 存储位置 |
technicalMetadata.compressed | 否 | Boolean 字符串或 JSON boolean | 是否压缩 |
technicalMetadata.inputFormat | 否 | String | InputFormat |
technicalMetadata.outputFormat | 否 | String | OutputFormat |
technicalMetadata.serializationLibrary | 否 | String | SerDe 类 |
technicalMetadata.parameters | 否 | JSON Object 字符串 | 参数信息,例如 {"retention":"30"} |
columns | 否 | JSON Array 字符串 | 内嵌字段列表;用于随 Table 一起注册扩展 Column |
Attributes.columns
columns 是 Attributes 里的一个 JSON Array 字符串。数组内每个对象支持以下字段:
| columns item key | 是否必填 | 类型/写法 | 说明 |
name | 是 | String | 字段名;为空会跳过该字段 |
type | 是 | String | 字段类型;缺失会报 attributes.columns[i].type |
comment | 否 | String | 字段注释 |
position | 否 | Integer | 字段位置;不传默认按数组顺序 i + 1 |
partitionKey | 否 | Boolean | 是否分区键 |
primaryKey | 否 | Boolean | 是否主键 |
customAttributes | 否 | Object | 字段自定义属性值 |
示例
创建扩展 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严格拦截未知Attributeskey;未知 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."
}
]
}
错误码
访问错误中心查看更多错误码。
变更历史
更多信息,参考变更详情。