BatchCreateMetaEntities - 大量建立中繼資料實體
大量建立中繼資料實體,同一批次需要為同一種類型,當前僅支援純自訂類型和擴充表類型(對應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."
}
]
}
錯誤碼
訪問錯誤中心查看更多錯誤碼。
變更歷史
更多資訊,參考變更詳情。