UpdateMetaEntity - 更新中繼資料實體

更新時間:
Copy as MD

更新中繼資料實體,支援更新建立的自訂類型對象或者擴充表對象(Database/Table/Column)

介面說明

需要購買 DataWorks 專業版及以上版本才能使用。

調試

您可以在OpenAPI Explorer中直接運行該介面,免去您計算簽名的困擾。運行成功後,OpenAPI Explorer可以自動產生SDK程式碼範例。

調試

授權資訊

當前API暫無授權資訊透出。

請求文法

POST  HTTP/1.1

請求參數

名稱

類型

必填

描述

樣本值

Id

string

待更新實體 ID;實體名稱、實體類型、父子關係由 ID 決定,不支援通過本介面修改

custom_entity-customer_api:api_001

Comment

string

注釋

this is a comment

Attributes

object

實體屬性,複雜值需要序列化為 JSON 字串

[]

string

實體屬性值

value

CustomAttributes

object

自訂屬性值,key 為自訂屬性標識,value 最多一個值;空列表表示刪除該屬性值

[]

array

自訂屬性值的數組,當前僅支援單值數組

string

自訂屬性值

張三

純自訂實體

EntityType 使用 custom_entity-<name>。可更新內容如下:

欄位支援情況說明
Comment支援更新實體注釋
Attributes支援key 必須存在於對應 MetaEntityDef.AttributeDefs;未知 key 報錯
CustomAttributes支援key 必須是適用於該實體類型的自訂屬性定義

Attributes 規則

專案說明
更新語義patch 語義;只傳入的 key 會被更新,其它已有屬性保留
刪除屬性傳入某個屬性 key 且 value 為 null 時,會從實體 attributes 中刪除該 key
必填屬性如果刪除或清空的是必填屬性,會按合并後的結果校正並報錯
ENUM 屬性value 必須在 AttributeDef.AllowedValues
DATE 屬性value 必須是毫秒時間戳記
ARRAY/JSON 屬性由於 OpenAPI 入參是字串,通常需要傳 JSON 字串

樣本:

{
  "Comment": "更新後的自訂實體",
  "Attributes": {
    "level": "L2",
    "profile": "{\"owner\":\"data_team\"}"
  },
  "CustomAttributes": {
    "biz_owner": ["data_team"]
  }
}

擴充表類型的 Database 對象

適用於 custom_<name>-database

Attributes key是否支援類型/寫法說明
technicalMetadata.locationString更新 database 的儲存位置,對應 ES 欄位 location
parentMetaEntityId-父子關係不可更新,傳入會報錯
其它 key-共用實體更新白名單外的 key 會報錯

擴充表類型 Table 對象

適用於 custom_<name>-table

Attributes key是否支援類型/寫法說明
tableTypeString更新表類型;
partitionKeysJSON Array 字串或 String傳數組時會用逗號拼接後寫入,例如 ["dt","hh"] 寫成 dt,hh
technicalMetadata.ownerString更新 owner
technicalMetadata.locationString更新儲存位置
technicalMetadata.compressedBoolean支援 truefalse
technicalMetadata.inputFormatString更新 InputFormat
technicalMetadata.outputFormatString更新 OutputFormat
technicalMetadata.serializationLibraryString更新 SerDe 類
technicalMetadata.parametersJSON Object 字串或 String傳 JSON Object 時會序列化為字串寫入 parameters
parentMetaEntityId-父 database 不可更新,傳入會報錯
columns-不能通過 UpdateMetaEntity 改欄位列表;需要更新 column 實體本身
其它 key-共用實體更新白名單外的 key 會報錯

樣本:

{
  "Comment": "更新後的表說明",
  "Attributes": {
    "tableType": "VIEW",
    "partitionKeys": "[\"dt\"]",
    "technicalMetadata.location": "oss://bucket/ods/order_fact",
    "technicalMetadata.compressed": "true",
    "technicalMetadata.parameters": "{\"retention\":\"30\"}"
  },
  "CustomAttributes": {
    "biz_owner": ["data_team"]
  }
}

擴充表類型的 Column 對象

適用於 custom_<name>-column

Attributes key是否支援類型/寫法說明
typeString更新欄位類型
positionInteger更新欄位位置
partitionKeyBoolean更新是否分區欄位,對應 ES 欄位 isPartitionKey
primaryKeyBoolean更新是否主鍵,對應 ES 欄位 isPrimaryKey
foreignKeyBoolean更新是否外鍵,對應 ES 欄位 isForeignKey
parentMetaEntityId-父 table 不可更新,傳入會報錯
其它 key-共用實體更新白名單外的 key 會報錯

如果父表不存在、父表不屬於當前租戶,或者父表沒有 inline columns,會報錯。

樣本:

{
  "Comment": "訂單 ID",
  "Attributes": {
    "type": "BIGINT",
    "position": "1",
    "primaryKey": "true"
  },
  "CustomAttributes": {
    "security_level": ["P1"]
  }
}

不支援或容易誤用的點

專案結論
修改實體名稱不支援;名稱來自 Id
修改 EntityType不支援;類型來自 Id
修改父實體不支援;attributes.parentMetaEntityId 會報錯
修改欄位列表不支援;attributes.columns 會報錯
建立新欄位不支援;擴充 table 的欄位需要在建立 table 時通過 BatchCreateMetaEntitiesAttributes.columns 提供

返回參數

名稱

類型

描述

樣本值

object

Schema of Response

RequestId

string

Id of the request

AASFDFSDFG-DFSDF-DFSDFD-SDFSDF

Success

boolean

請求是否成功

true

Result

object

更新後的實體或寫入結果

Id

string

實體 ID

custom_entity-customer_api:api_001

Success

boolean

是否成功

true

樣本

正常返回樣本

JSON格式

{
  "RequestId": "AASFDFSDFG-DFSDF-DFSDFD-SDFSDF",
  "Success": true,
  "Result": {
    "Id": "custom_entity-customer_api:api_001",
    "Success": true
  }
}

錯誤碼

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

變更歷史

更多資訊,參考變更詳情