BatchCreateMetaEntities
Creates metadata entities in batches. All entities in the same batch must be of the same type. Currently, only custom entity types and extension table types (corresponding to Database/Table) are supported.
Operation description
DataWorks Professional Edition or a higher edition is required.
Try it now
Test
RAM authorization
|
Action |
Access level |
Resource type |
Condition key |
Dependent action |
|
dataworks:BatchCreateMetaEntities |
create |
*All Resource
|
None | None |
Request syntax
POST HTTP/1.1
Request parameters
|
Parameter |
Type |
Required |
Description |
Example |
| Entities |
array<object> |
Yes |
The list of entities. A maximum of five entities are supported. All entities in the same batch must have the same entityType. |
[] |
|
array<object> |
No |
The entity object. |
||
| EntityType |
string |
Yes |
The entity type. All entities in the same batch must have the same type. The following types are supported:
|
custom_entity-customer_api |
| Name |
string |
Yes |
The entity name. The name can contain uppercase letters, lowercase letters, digits, and underscores (_). It must start with a letter and can be up to 64 characters in length. |
api_001 |
| Comment |
string |
No |
The comment. |
this is a comment |
| Attributes |
object |
No |
The entity attributes. Complex values must be serialized as JSON strings. |
|
|
string |
No |
The entity attribute. |
key1 |
|
| CustomAttributes |
object |
No |
The custom attribute values. The key is the custom attribute identifier, and the value currently supports only a single value. Important The custom attributes used here must be created in advance by calling the CreateCustomAttribute operation. For example, after you call the API to create a custom attribute with the ID custom-attribute:owner_name, you can configure {'owner_name': ['Bob']} here to complete the custom attribute configuration. |
|
|
array |
No |
The list of custom attribute values. |
||
|
string |
No |
The custom attribute value. |
value1 |
Extension Database
Set EntityType to custom_xxx-database, where xxx comes from the already created custom_xxx-table extension EntityDef.
Attributes
| Attributes key | Required | Type/Format | Description |
parentMetaEntityId | Yes | String | The parent instance ID. It must be at the instance level and cannot contain catalog/database/schema/table/column. |
technicalMetadata.location | No | String | The storage location of the database. |
Extension Table
Set EntityType to custom_xxx-table. The columns of the table must also be registered here through Attributes.columns.
Attributes
| Attributes key | Required | Type/Format | Description |
parentMetaEntityId | Yes | String | The parent database ID. It must be at the database level. |
tableType | No | String | The table type. Default value: TABLE. |
partitionKeys | No | JSON Array string | The partition keys, such as ["dt"]. |
technicalMetadata.location | No | String | The storage location. |
technicalMetadata.compressed | No | Boolean string or JSON boolean | Specifies whether the data is compressed. |
technicalMetadata.inputFormat | No | String | The InputFormat. |
technicalMetadata.outputFormat | No | String | The OutputFormat. |
technicalMetadata.serializationLibrary | No | String | The SerDe class. |
technicalMetadata.parameters | No | JSON Object string | The parameter information, such as {"retention":"30"}. |
columns | No | JSON Array string | The inline column list. Used to register extension columns together with the table. |
Attributes.columns
columns is a JSON Array string within Attributes. Each object in the array supports the following fields:
| columns item key | Required | Type/Format | Description |
name | Yes | String | The column name. If empty, the column is skipped. |
type | Yes | String | The column type. If missing, an error attributes.columns[i].type is reported. |
comment | No | String | The column comment. |
position | No | Integer | The column position. If not specified, the default value is i + 1 based on the array order. |
partitionKey | No | Boolean | Specifies whether the column is a partition key. |
primaryKey | No | Boolean | Specifies whether the column is a primary key. |
customAttributes | No | Object | The custom attribute values of the column. |
Examples.
Create an extension 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"]
}
}
]
}
Create an extension table and register columns
{
"Entities": [
{
"EntityType": "custom_demo-table",
"Name": "order_fact",
"Comment": "Order fact table",
"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\":\"Primary key\",\"position\":1,\"primaryKey\":true,\"customAttributes\":{\"security_level\":[\"P1\"]}},{\"name\":\"dt\",\"type\":\"STRING\",\"comment\":\"Partition date\",\"position\":2,\"partitionKey\":true}]"
},
"CustomAttributes": {
"biz_owner": ["data_team"]
}
}
]
}
Precautions
The
parentMetaEntityIdof an extension database must be at the instance level, such ascustom_demo:demo_source.The
parentMetaEntityIdof an extension table must be at the database level, such ascustom_demo-database:demo_source::ods.Parent and child entities must belong to the same extension family. For example, the parent of
custom_demo-tablemust becustom_demo-database.columnscan only be provided when creating a table. You cannot useBatchCreateMetaEntitiesto independently createcustom_xxx-column.The extension entity write path does not strictly block unknown
Attributeskeys based onMetaEntityDef.AttributeDefs. Unknown keys are typically ignored.
Response elements
|
Element |
Type |
Description |
Example |
|
object |
Schema of Response |
||
| RequestId |
string |
Id of the request |
9E0C8E7A-C6BE-5A73-9562-2A030A80E8C6 |
| Success |
boolean |
Indicates whether the request is successful. If some entities fail, the value is still true. Check Results[].Success and Results[].ErrorMessage for individual results. |
true |
| Results |
array |
The list of entity creation results. Each entry indicates whether the creation is successful and the failure reason. |
|
| MetaEntityWriteResult |
The batch creation result. |
Examples
Success response
JSON format
{
"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."
}
]
}
Error codes
See Error Codes for a complete list.
Release notes
See Release Notes for a complete list.