BatchCreateMetaEntities

Updated at:

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

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. 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 types, such as custom_entity-biz_api.

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

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

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

  • columns can only be provided when creating a table. You cannot use BatchCreateMetaEntities to independently create custom_xxx-column.

  • The extension entity write path does not strictly block unknown Attributes keys based on MetaEntityDef.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.