BatchCreateMetaEntities
Creates metadata entities in batches. All entities in a batch must be of the same type. Currently, only pure custom types and extended table types (corresponding to databases and tables) are supported.
Operation description
DataWorks Professional Edition or higher is required to use this feature.
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. You can specify up to 5 entities. All entities in the same batch must have the same entityType. |
[{"EntityType":"custom_entity-customer_api","Name":"api_001"}] |
|
array<object> |
No |
The entity object. |
||
| EntityType |
string |
Yes |
The entity type. All entities in the same batch must have the same entity type. Valid values:
|
custom_entity-customer_api |
| Name |
string |
Yes |
The name of the entity. The name can contain letters, digits, and underscores (_), and must start with a letter. The name can be up to 64 characters in length. |
api_001 |
| Comment |
string |
No |
The comment. |
this is a comment |
| Attributes |
object |
No |
The attributes of the entity. Complex values must be serialized into 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 create a custom attribute with the ID custom-attribute:owner_name by calling the operation, you can configure {'owner_name': ['Bob']} here to set the custom attribute. |
|
|
array |
No |
The list of custom attribute values. |
||
|
string |
No |
The custom attribute value. |
value1 |
Extended database
Set EntityType to custom_xxx-database. The xxx part is derived from the created custom_xxx-table extended EntityDef.
Attributes
| Attributes key | Required | Type/format | Description |
parentMetaEntityId | Yes | String | The ID of the parent instance. It must be at the instance level and cannot contain catalog, database, schema, table, or column. |
technicalMetadata.location | No | String | The storage location of the database. |
Extended table
Set EntityType to custom_xxx-table. The columns of the table must also be registered here by using Attributes.columns.
Attributes
| Attributes key | Required | Type/format | Description |
parentMetaEntityId | Yes | String | The ID of the parent database. It must be at the database level. |
tableType | No | String | The table type. Default value: TABLE. |
partitionKeys | No | JSON array string | The partition keys. Example: ["dt"]. |
technicalMetadata.location | No | String | The storage location. |
technicalMetadata.compressed | No | Boolean string or JSON boolean | Specifies whether the table 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. Example: {"retention":"30"}. |
columns | No | JSON array string | The embedded column list. Used to register extended columns along with the table. |
Attributes.columns
columns is a JSON array string in Attributes. Each object in the array supports the following fields:
| columns item key | Required | Type/format | Description |
name | Yes | String | The column name. If this field is empty, the column is skipped. |
type | Yes | String | The column type. If this field is missing, an attributes.columns[i].type error is reported. |
comment | No | String | The column comment. |
position | No | Integer | The column position. If this field is not specified, the default value is i + 1, based on the order in the array. |
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 extended 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 extended 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 extended database must be at the instance level, such ascustom_demo:demo_source.The
parentMetaEntityIdof an extended table must be at the database level, such ascustom_demo-database:demo_source::ods.The parent and child entities must belong to the same extended family. For example, the parent of
custom_demo-tablemust becustom_demo-database.The
columnsparameter can only be provided when a table is created. You cannot createcustom_xxx-columnseparately by callingBatchCreateMetaEntities.The write path for extended entities does not strictly reject unknown
Attributeskeys based onMetaEntityDef.AttributeDefs. Unknown keys are usually ignored.
Response elements
|
Element |
Type |
Description |
Example |
|
object |
The response schema. |
||
| RequestId |
string |
The request ID. |
9E0C8E7A-C6BE-5A73-9562-2A030A80E8C6 |
| Success |
boolean |
Indicates whether the request is successful. If some entities fail to be created, the value is still true. For the result of each entity, see Results[].Success and Results[].ErrorMessage. |
true |
| Results |
array |
The list of entity write results. The result of each entity indicates whether the creation is successful and the cause of failure. |
|
| 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.