Membuat entitas metadata secara batch. Semua entitas dalam satu batch harus memiliki tipe entitas yang sama. Operasi ini saat ini hanya mendukung tipe kustom dan tipe tabel yang diperluas, yang merepresentasikan database dan tabel.
Deskripsi operasi
You must purchase DataWorks Professional Edition or a higher edition to use this operation.
Coba sekarang
Test
RAM authorization
Sintaks permintaan
POST HTTP/1.1
Parameter permintaan
|
Parameter |
Type |
Required |
Description |
Example |
| Entities |
array<object> |
Yes |
Daftar entitas. Anda dapat membuat hingga lima entitas dalam satu batch. Semua entitas dalam batch harus memiliki |
[] |
|
array<object> |
No |
An object that represents a metadata entity. |
||
| EntityType |
string |
Yes |
The entity type. All entities in a 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 not exceed 64 characters. |
api_001 |
| Comment |
string |
No |
The comment for the entity. |
this is a comment |
| Attributes |
object |
No |
The entity attributes. Complex values must be serialized into a JSON string. |
|
|
string |
No |
An entity attribute. |
key1 |
|
| CustomAttributes |
object |
No |
The custom attribute values. The key is the identifier of the custom attribute, and the value is a single-element list. Penting The custom attributes used here must be created in advance by using the CreateCustomAttribute API. For example, after you create a custom attribute with the ID custom-attribute:owner_name, you can configure the custom attribute by setting this parameter to {'owner_name': ['Bob']}. |
|
|
array |
No |
A list of custom attribute values. |
||
|
string |
No |
A custom attribute value. |
value1 |
Database yang diperluas
Atur EntityType menjadi custom_xxx-database. Placeholder xxx diturunkan dari definisi entitas yang diperluas (EntityDef) yang sudah ada untuk tabel, seperti custom_xxx-table.
Atribut
| Kunci atribut | Wajib | Tipe | Deskripsi |
parentMetaEntityId | Ya | String | ID instans induk. Harus berada di tingkat instans dan tidak boleh mengandung pengenal katalog, database, skema, tabel, atau kolom. |
technicalMetadata.location | Tidak | String | Lokasi penyimpanan database. |
Tabel yang diperluas
Atur EntityType menjadi custom_xxx-table. Anda juga harus mendaftarkan kolom tabel menggunakan parameter Attributes.columns.
Atribut
| Kunci atribut | Wajib | Tipe | Deskripsi |
parentMetaEntityId | Ya | String | ID database induk. Harus berada di tingkat database. |
tableType | Tidak | String | Tipe tabel. Jika parameter ini tidak diatur, nilai default TABLE akan digunakan. |
partitionKeys | Tidak | String array JSON | Kunci partisi. Contoh: ["dt"]. |
technicalMetadata.location | Tidak | String | Lokasi penyimpanan. |
technicalMetadata.compressed | Tidak | String boolean atau boolean JSON | Apakah data dikompresi. |
technicalMetadata.inputFormat | Tidak | String | Format input. |
technicalMetadata.outputFormat | Tidak | String | Format output. |
technicalMetadata.serializationLibrary | Tidak | String | Library serialisasi/deserialisasi (SerDe). |
technicalMetadata.parameters | Tidak | String objek JSON | Informasi parameter. Contoh: {"retention":"30"}. |
columns | Tidak | String array JSON | Daftar kolom tertanam. Gunakan parameter ini untuk mendaftarkan kolom yang diperluas saat tabel dibuat. |
Attributes.columns
Parameter columns adalah string array JSON di dalam Attributes. Setiap objek dalam array mendukung bidang berikut:
| Parameter | Wajib | Tipe | Deskripsi |
name | Ya | String | Nama kolom. Jika properti ini kosong, kolom akan dilewati. |
type | Ya | String | Tipe kolom. Jika properti ini tidak ada, sistem akan melaporkan error untuk attributes.columns[i].type. |
comment | Tidak | String | Komentar kolom. |
position | Tidak | Integer | Posisi kolom. Jika tidak ditentukan, defaultnya adalah indeks array i + 1. |
partitionKey | Tidak | Boolean | Apakah kolom merupakan kunci partisi. |
primaryKey | Tidak | Boolean | Apakah kolom merupakan kunci primer. |
customAttributes | Tidak | Object | Nilai atribut kustom untuk kolom. |
Contoh.
Membuat database yang diperluas
{
"Entities": [
{
"EntityType": "custom_demo-database",
"Name": "ods",
"Comment": "ODS database",
"Attributes": {
"parentMetaEntityId": "custom_demo:demo_source",
"technicalMetadata.location": "oss://bucket/ods"
},
"CustomAttributes": {
"biz_Pemilik": ["data_team"]
}
}
]
}
```.
### Membuat tabel yang diperluas dan kolom
```json
{
"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\":\"Kunci primer\",\"position\":1,\"primaryKey\":true,\"customAttributes\":{\"security_level\":[\"P1\"]}},{\"name\":\"dt\",\"type\":\"STRING\",\"comment\":\"Partition date\",\"position\":2,\"partitionKey\":true}]"
},
"CustomAttributes": {
"biz_Pemilik": ["data_team"]
}
}
]
}
```.
## Catatan penggunaan
- `parentMetaEntityId` untuk database yang diperluas harus berada di tingkat instans, seperti `custom_demo:demo_source`.
- `parentMetaEntityId` untuk tabel yang diperluas harus berada di tingkat database, seperti `custom_demo-database:demo_source::ods`.
- Entitas induk dan anak harus berada dalam keluarga ekstensi yang sama. Misalnya, induk dari entitas `custom_demo-table` harus berupa entitas `custom_demo-database`.
- Parameter `columns` hanya dapat diberikan saat Anda membuat tabel. Anda tidak dapat menggunakan operasi `BatchCreateMetaEntities` untuk membuat entitas `custom_xxx-column` secara terpisah.
- Untuk entitas yang diperluas, jalur penulisan tidak secara ketat memblokir kunci yang tidak diketahui dalam parameter `Attributes` berdasarkan `MetaEntityDef.AttributeDefs`. Kunci yang tidak diketahui biasanya akan diabaikan.
Elemen respons
|
Element |
Type |
Description |
Example |
|
object |
The response body. |
||
| RequestId |
string |
The request ID. |
9E0C8E7A-C6BE-5A73-9562-2A030A80E8C6 |
| Success |
boolean |
Indicates whether the request was successful. This parameter returns |
true |
| Results |
array |
A list of results for the batch creation operation. This list provides the success status and any error messages for each individual entity in the request. |
|
| MetaEntityWriteResult |
The result of a single entity creation within the batch. |
Contoh
Respons sukses
JSONformat
{
"RequestId": "9E0C8E7A-C6BE-5A73-9562-2A030A80E8C6",
"Success": true,
"Results": [
{
"Name": "",
"EntityType": "",
"Id": "",
"Success": false,
"ErrorMessage": ""
}
]
}
Kode kesalahan
Lihat Error Codes untuk daftar lengkap.
Catatan rilis
Lihat Release Notes untuk daftar lengkap.