Creates an Iceberg table in the specified table bucket and namespace.
Notes
-
Table names can contain only lowercase letters, digits, and underscores (_), and must start and end with a lowercase letter or digit.
-
Table names must be unique within a namespace.
-
The
--metadataparameter accepts JSON that defines the Iceberg table schema. Provide JSON inline or reference a local file with thefile://prefix. -
The
--formatparameter supports onlyICEBERG.
Syntax
ossutil tables-api create-table --table-bucket-arn value --namespace value --name value --format value [flags]
|
Parameter |
Type |
Description |
|
--encryption-configuration |
string |
Server-side encryption configuration for the table, in JSON format. |
|
--format |
string |
Table format. Only |
|
--metadata |
string |
Table metadata in JSON format. Defines the Iceberg table schema and field information. |
|
--name |
string |
Table name. Must contain only lowercase letters, digits, and underscores (_), and start and end with a lowercase letter or digit. |
|
--namespace |
string |
Target namespace for the table. |
|
--table-bucket-arn |
string |
Alibaba Cloud Resource Name (ARN) of the table bucket. Format: |
-
This command maps to the CreateTable API operation.
-
This command supports all Global options for ossutil.
JSON syntax for --metadata:
{
"iceberg": {
"schema": {
"fields": [
{
"id": 1,
"name": "id",
"type": "long",
"required": true
},
{
"id": 2,
"name": "name",
"type": "string",
"required": false
},
{
"id": 3,
"name": "created_at",
"type": "timestamp",
"required": false
}
]
}
}
}
Field attributes:
-
id: Unique incremental integer.
-
name: Field name.
-
type: Data type. Supported types:
long,string,int,boolean,float,double, andtimestamp. -
required: Whether the field is required. If
true, the field cannot be null.
Examples
-
Create an Iceberg table named
my_tablein themy_namespacenamespace with an inline JSON schema.ossutil tables-api create-table --table-bucket-arn acs:osstables:cn-hangzhou:1234567890:bucket/my-table-bucket --namespace my_namespace --name my_table --format ICEBERG --metadata '{"iceberg":{"schema":{"fields":[{"id":1,"name":"id","type":"long","required":true},{"id":2,"name":"data","type":"string"}]}}}' -
Create an Iceberg table from a local JSON metadata file. Save the schema to
table_metadata.json, then reference it with thefile://prefix.ossutil tables-api create-table --table-bucket-arn acs:osstables:cn-hangzhou:1234567890:bucket/my-table-bucket --namespace my_namespace --name my_table --format ICEBERG --metadata file://table_metadata.json