BatchCreateMetaEntities

Updated at:

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

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

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:

  • Pure custom types, such as custom_entity-biz_api.

  • Extended table types. If the metadata entity type custom_dw-table is registered, you can create objects of the corresponding database type custom_dw-database and table type custom_dw-table.

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 keyRequiredType/formatDescription
parentMetaEntityIdYesStringThe ID of the parent instance. It must be at the instance level and cannot contain catalog, database, schema, table, or column.
technicalMetadata.locationNoStringThe 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 keyRequiredType/formatDescription
parentMetaEntityIdYesStringThe ID of the parent database. It must be at the database level.
tableTypeNoStringThe table type. Default value: TABLE.
partitionKeysNoJSON array stringThe partition keys. Example: ["dt"].
technicalMetadata.locationNoStringThe storage location.
technicalMetadata.compressedNoBoolean string or JSON booleanSpecifies whether the table is compressed.
technicalMetadata.inputFormatNoStringThe InputFormat.
technicalMetadata.outputFormatNoStringThe OutputFormat.
technicalMetadata.serializationLibraryNoStringThe SerDe class.
technicalMetadata.parametersNoJSON object stringThe parameter information. Example: {"retention":"30"}.
columnsNoJSON array stringThe 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 keyRequiredType/formatDescription
nameYesStringThe column name. If this field is empty, the column is skipped.
typeYesStringThe column type. If this field is missing, an attributes.columns[i].type error is reported.
commentNoStringThe column comment.
positionNoIntegerThe column position. If this field is not specified, the default value is i + 1, based on the order in the array.
partitionKeyNoBooleanSpecifies whether the column is a partition key.
primaryKeyNoBooleanSpecifies whether the column is a primary key.
customAttributesNoObjectThe 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 parentMetaEntityId of an extended database must be at the instance level, such as custom_demo:demo_source.

  • The parentMetaEntityId of an extended table must be at the database level, such as custom_demo-database:demo_source::ods.

  • The parent and child entities must belong to the same extended family. For example, the parent of custom_demo-table must be custom_demo-database.

  • The columns parameter can only be provided when a table is created. You cannot create custom_xxx-column separately by calling BatchCreateMetaEntities.

  • The write path for extended entities does not strictly reject unknown Attributes keys based on MetaEntityDef.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.