Creates an Iceberg table in the specified table bucket and namespace.
Notes
Table names must contain only lowercase letters, numbers, and underscores (_) and must start and end with a lowercase letter or a number.
Table names must be unique within a namespace.
The
--metadataparameter requires table metadata in JSON format to define the Iceberg table's schema. You can provide the JSON inline or from a local file by using thefile://prefix.Currently, the
--formatparameter only supportsICEBERG.
Syntax
ossutil tables-api create-table --table-bucket-arn value --namespace value --name value --format value [flags]Parameter | Type | Description |
--encryption-configuration | string | Specifies the server-side encryption method for the table. Provide the configuration in JSON format. |
--format | string | Specifies the table format. Currently, only |
--metadata | string | Specifies the table metadata in JSON format. This metadata defines the Iceberg table's schema, including field information. |
--name | string | Specifies the table name. The name can contain only lowercase letters, numbers, and underscores (_), and must start and end with a lowercase letter or a number. |
--namespace | string | The namespace in which the table is to be created. |
--table-bucket-arn | string | The Alibaba Cloud Resource Name (ARN) of the table bucket. The format is |
The create-table command maps to the CreateTable API operation. For parameter details, see CreateTable.
For supported global command-line options, see Global options for ossutil.
The JSON syntax for the --metadata parameter is as follows:
{
"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
}
]
}
}
}The attributes for each field are as follows:
id: The field ID. Must be a unique and incremental integer.
name: The name of the field.
type: The data type of the field. Supported Iceberg types include
long,string,int,boolean,float,double, andtimestamp.required: A boolean value that specifies whether the field is required. If
true, the field cannot be null.
Examples
Create an Iceberg table named
my_tablein themy_namespacenamespace and provide the table schema as inline JSON.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 file. First, save the table metadata to a file named
table_metadata.json. Then, specify the file path 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