BatchCreateMetaEntities - 大量建立中繼資料實體

更新時間:
Copy as MD

大量建立中繼資料實體,同一批次需要為同一種類型,當前僅支援純自訂類型和擴充表類型(對應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."
    }
  ]
}

錯誤碼

訪問錯誤中心查看更多錯誤碼。

變更歷史

更多資訊,參考變更詳情