All Products
Search
Document Center

Object Storage Service:CreateTable

Last Updated:May 08, 2026

Call the CreateTable API to create an Iceberg table in the namespace of a specified Table Bucket.

Permissions

API

Action

Description

CreateTable

oss:CreateTable

The permission required to create a table.

oss:PutTableData

Required to write to a data bucket if the metadata parameter is specified.

oss:PutTableEncryption

Required when the encryptionConfiguration parameter is specified.

Request syntax

PUT /tables/{tableBucketARN}/{namespace} HTTP/1.1
Content-type: application/json
Host: cn-hangzhou.oss-tables.aliyuncs.com
Date: GMT Date
Authorization: SignatureValue

{
   "name": "string",
   "format": "string",
   "encryptionConfiguration": {
      "sseAlgorithm": "string",
      "kmsKeyArn": "string"
   },
   "metadata": {
      "iceberg": {
         "schema": {
            "fields": [
               {
                  "id": number,
                  "name": "string",
                  "type": "string",
                  "required": boolean
               }
            ]
         },
         "partitionSpec": {
            "specId": number,
            "fields": [
               {
                  "sourceId": number,
                  "transform": "string",
                  "name": "string"
               }
            ]
         },
         "writeOrder": {
            "orderId": number,
            "fields": [
               {
                  "sourceId": number,
                  "transform": "string",
                  "direction": "string",
                  "nullOrder": "string"
               }
            ]
         },
         "properties": {
            "string": "string"
         }
      }
   }
}

Parameters

Parameter

Type

Required

Example

Description

tableBucketARN

string

Yes

acs:osstables:cn-hangzhou:1234567890:bucket/my-table-bucket

The ARN of the table bucket. This parameter is located in the URI and has the format acs:osstables:{region}:{uid}:bucket/{bucketName}.

namespace

string

Yes

my_namespace

The name of the namespace that contains the table. This parameter is located in the URI.

name

string

Yes

my_table

The name of the table. It must be unique within the namespace, be 1 to 255 characters long, contain only lowercase letters, digits, and underscores (_), and not start or end with an underscore.

format

string

Yes

ICEBERG

The table format. Only ICEBERG is supported.

encryptionConfiguration

object

No

-

The server-side encryption configuration for the table. If this parameter is not specified, the table inherits the encryption configuration from the table bucket. Child nodes: sseAlgorithm, kmsKeyArn.

sseAlgorithm

string

Yes, if encryptionConfiguration is specified.

AES256

The encryption algorithm. Only AES256 is supported. Parent node: encryptionConfiguration.

kmsKeyArn

string

No

acs:kms:cn-hangzhou:1234567890:key/key-id

The ARN of the KMS key. This parameter is not supported in the current version and must be left empty. Parent node: encryptionConfiguration.

metadata

object

No

-

The metadata configuration for the table. It includes the schema, partitioning rules, write order, and properties of the Iceberg table. Child node: iceberg.

iceberg

object

Yes, if metadata is specified.

-

The metadata configuration for the Iceberg table. Parent node: metadata. Child nodes: schema, partitionSpec, writeOrder, and properties.

schema

object

No

-

The schema definition of the Iceberg table, which describes the table's columns. Parent node: iceberg. Child node: fields.

fields

array

Yes, if schema is specified.

-

An array of field definitions for the schema. Each element describes the properties of a column:

  • id: The field ID. This is an optional integer. We recommend that you explicitly specify this ID and ensure it is unique within the schema. The sourceId in partitionSpec must match this ID.

  • name: The field name. This field is required.

  • type: The data type of the field. This field is required. For a list of supported types, see the Schema Field Types section.

  • required: Specifies whether the field is required. This is an optional boolean that defaults to false. If set to true, the column does not allow NULL values.

Parent node: schema

partitionSpec

object

No

-

Defines the partitioning rule for the table. Parent node: iceberg. Contains the following child nodes:

  • specId: The partition specification ID. This is an optional integer that defaults to 0.

  • fields: An array of partition field definitions. See the next row for details.

fields

array

  • sourceId: Required. The ID of the source field from the schema. This value must match the id of a field in the schema.

  • transform: Required. The partition transformation type. Supported values are identity, void, year, month, day, hour, bucket[N], and truncate[N].

  • fieldId: Optional. The partition field ID. This is an integer.

  • name: Required. The name of the partition field.

Parent node: partitionSpec

writeOrder

object

No

-

Defines the physical sort order of data during writes. Parent node: iceberg. Contains the following child nodes:

  • orderId: The sort order ID. This is an optional integer that defaults to 1 and must be greater than or equal to 1.

  • fields: An array of sort field definitions. See the next row for details.

fields

array

  • sourceId: Required. The ID of the source field from the schema. This value must match the id of a field in the schema.

  • transform: Required. The sort transformation type. Supported values are identity, void, year, month, day, hour, bucket[N], and truncate[N].

  • direction: The sort order. The value can be asc (ascending) or desc (descending). Required.

  • nullOrder: The sort order for NULL values. The value can be nulls-first (places NULL values first) or nulls-last (places NULL values last). Required.

Parent node: writeOrder

properties

object

No

-

Configuration properties for an Iceberg table, in key-value pair format. The parent node is iceberg. Common properties include: format-version (the Iceberg format version, with a value range of 1 to 3), write.format.default (the write file format, such as parquet), and write.target-file-size-bytes (the target file size).

Response parameters

Parameter

Type

Example

Description

tableARN

string

acs:osstables:cn-hangzhou:1234567890:bucket/my-table-bucket/table/table-id

The ARN of the created table, in the format acs:osstables:{region}:{uid}:bucket/{bucketName}/table/{tableId}.

versionToken

string

abc123def456

The version token for the table, used for optimistic locking.

Examples

Example 1: Table with a schema

This example creates a basic table with a schema containing two fields: id and data.

Request example

PUT /tables/acs%3Aosstables%3Acn-hangzhou%3A1234567890%3Abucket%2Fmy-table-bucket/my_namespace HTTP/1.1
Content-type: application/json
Host: cn-hangzhou.oss-tables.aliyuncs.com
Date: Thu, 10 Apr 2025 08:00:00 GMT
Authorization: OSS4-HMAC-SHA256 Credential=LTAI********************/20250417/cn-hangzhou/osstables/aliyun_v4_request,Signature=a7c3554c729d71929e0b84489addee6b2e8d5cb48595adfc51868c299c0c****

{
   "name": "basic_table",
   "format": "ICEBERG",
   "metadata": {
      "iceberg": {
         "schema": {
            "fields": [
               {"id": 1, "name": "id", "type": "long", "required": true},
               {"id": 2, "name": "data", "type": "string"}
            ]
         }
      }
   }
}

Example 2: Table with an identity partition

This example creates a table with an identity partition on the region field.

Request example

PUT /tables/acs%3Aosstables%3Acn-hangzhou%3A1234567890%3Abucket%2Fmy-table-bucket/my_namespace HTTP/1.1
Content-type: application/json
Host: cn-hangzhou.oss-tables.aliyuncs.com
Date: Thu, 10 Apr 2025 08:00:00 GMT
Authorization: OSS4-HMAC-SHA256 Credential=LTAI********************/20250417/cn-hangzhou/osstables/aliyun_v4_request,Signature=a7c3554c729d71929e0b84489addee6b2e8d5cb48595adfc51868c299c0c****

{
   "format": "ICEBERG",
   "metadata": {
      "iceberg": {
         "schema": {
            "fields": [
               {"id": 1, "name": "id", "type": "long", "required": true},
               {"id": 2, "name": "region", "type": "string"},
               {"id": 3, "name": "ts", "type": "timestamptz"}
            ]
         },
         "partitionSpec": {
            "specId": 0,
            "fields": [
               {"sourceId": 2, "transform": "identity", "name": "region"}
            ]
         }
      }
   },
   "name": "partitioned_table"
}

Example 3: Table with time and bucket partitions

This example creates a table with both day time and bucket partitions.

Request example

PUT /tables/acs%3Aosstables%3Acn-hangzhou%3A1234567890%3Abucket%2Fmy-table-bucket/my_namespace HTTP/1.1
Content-type: application/json
Host: cn-hangzhou.oss-tables.aliyuncs.com
Date: Thu, 10 Apr 2025 08:00:00 GMT
Authorization: OSS4-HMAC-SHA256 Credential=LTAI********************/20250417/cn-hangzhou/osstables/aliyun_v4_request,Signature=a7c3554c729d71929e0b84489addee6b2e8d5cb48595adfc51868c299c0c****


{
   "format": "ICEBERG",
   "metadata": {
      "iceberg": {
         "schema": {
            "fields": [
               {"id": 1, "name": "id", "type": "long", "required": true},
               {"id": 2, "name": "data", "type": "string"},
               {"id": 3, "name": "ts", "type": "timestamptz"}
            ]
         },
         "partitionSpec": {
            "fields": [
               {"sourceId": 3, "transform": "day", "name": "ts_day"},
               {"sourceId": 1, "transform": "bucket[256]", "name": "id_bucket"}
            ]
         }
      }
   },
   "name": "multi_partition_table"
}

Example 4: Table with a write order

This example creates a table with a specified write order that sorts data by the ts field in descending order and the id field in ascending order.

Request example

PUT /tables/acs%3Aosstables%3Acn-hangzhou%3A1234567890%3Abucket%2Fmy-table-bucket/my_namespace HTTP/1.1
Content-type: application/json
Host: cn-hangzhou.oss-tables.aliyuncs.com
Date: Thu, 10 Apr 2025 08:00:00 GMT
Authorization: OSS4-HMAC-SHA256 Credential=LTAI********************/20250417/cn-hangzhou/osstables/aliyun_v4_request,Signature=a7c3554c729d71929e0b84489addee6b2e8d5cb48595adfc51868c299c0c****


{
   "format": "ICEBERG",
   "metadata": {
      "iceberg": {
         "schema": {
            "fields": [
               {"id": 1, "name": "id", "type": "long", "required": true},
               {"id": 2, "name": "ts", "type": "timestamptz"},
               {"id": 3, "name": "category", "type": "string"}
            ]
         },
         "writeOrder": {
            "orderId": 1,
            "fields": [
               {"sourceId": 2, "transform": "identity", "direction": "desc", "nullOrder": "nulls-last"},
               {"sourceId": 1, "transform": "identity", "direction": "asc", "nullOrder": "nulls-first"}
            ]
         }
      }
   },
   "name": "sorted_table"
}

Example 5: Table with specified properties

This example creates a table with specified table properties, setting the Iceberg format version to V2, the default write file format, and the target file size.

Request example

PUT /tables/acs%3Aosstables%3Acn-hangzhou%3A1234567890%3Abucket%2Fmy-table-bucket/my_namespace HTTP/1.1
Content-type: application/json
Host: cn-hangzhou.oss-tables.aliyuncs.com
Date: Thu, 10 Apr 2025 08:00:00 GMT
Authorization: OSS4-HMAC-SHA256 Credential=LTAI********************/20250417/cn-hangzhou/osstables/aliyun_v4_request,Signature=a7c3554c729d71929e0b84489addee6b2e8d5cb48595adfc51868c299c0c****

{
   "name": "v2_table",
   "format": "ICEBERG",
   "metadata": {
      "iceberg": {
         "schema": {
            "fields": [
               {"id": 1, "name": "id", "type": "long", "required": true},
               {"id": 2, "name": "name", "type": "string"}
            ]
         },
         "properties": {
            "format-version": "2",
            "write.format.default": "parquet",
            "write.target-file-size-bytes": "134217728"
         }
      }
   }
}

Example 6: Table with a full configuration

This example creates a table with a schema, partition specification, write order, table properties, and an encryption configuration.

Request example

PUT /tables/acs%3Aosstables%3Acn-hangzhou%3A1234567890%3Abucket%2Fmy-table-bucket/my_namespace HTTP/1.1
Content-type: application/json
Host: cn-hangzhou.oss-tables.aliyuncs.com
Date: Thu, 10 Apr 2025 08:00:00 GMT
Authorization: OSS4-HMAC-SHA256 Credential=LTAI********************/20250417/cn-hangzhou/osstables/aliyun_v4_request,Signature=a7c3554c729d71929e0b84489addee6b2e8d5cb48595adfc51868c299c0c****


{
   "encryptionConfiguration": {
      "sseAlgorithm": "AES256"
   },
   "format": "ICEBERG",
   "metadata": {
      "iceberg": {
         "schema": {
            "fields": [
               {"id": 1, "name": "id", "type": "long", "required": true},
               {"id": 2, "name": "ts", "type": "timestamptz", "required": true},
               {"id": 3, "name": "region", "type": "string"},
               {"id": 4, "name": "amount", "type": "double"}
            ]
         },
         "partitionSpec": {
            "specId": 0,
            "fields": [
               {"sourceId": 2, "transform": "day", "name": "ts_day"},
               {"sourceId": 3, "transform": "identity", "name": "region"}
            ]
         },
         "writeOrder": {
            "orderId": 1,
            "fields": [
               {"sourceId": 2, "transform": "identity", "direction": "desc", "nullOrder": "nulls-last"},
               {"sourceId": 1, "transform": "identity", "direction": "asc", "nullOrder": "nulls-first"}
            ]
         },
         "properties": {
            "format-version": "2",
            "write.format.default": "parquet"
         }
      }
   },
   "name": "full_featured_table"
}

Response example

HTTP/1.1 200 OK
Server: AliyunOSS
x-oss-request-id: 5C06A3B67B8B5A3DA422****
x-oss-server-time: 3
Content-Type: application/json

{
   "tableARN": "acs:osstables:cn-hangzhou:1234567890:bucket/my-table-bucket/table/table_id",
   "versionToken": "aaabbb"
}

Schema field types

Primitive types

The following table lists the primitive types supported by the Iceberg schema.

Type

Minimum version

Description

Example value

boolean

V1

A boolean value.

true

int

V1

A 32-bit signed integer.

42

long

V1

A 64-bit signed integer.

1234567890

float

V1

A 32-bit IEEE 754 floating-point number.

3.14

double

V1

A 64-bit IEEE 754 floating-point number.

3.141592653589793

decimal(P,S)

V1

A fixed-precision decimal number, where P is the precision (the total number of digits, up to 38) and S is the scale (the number of digits to the right of the decimal point).

decimal(10,2) → 12345678.90

date

V1

A calendar date without a time or time zone.

2025-04-10

time

V1

A time of day without a date or time zone, with microsecond precision.

14:30:00.000000

timestamp

V1

A timestamp without a time zone, with microsecond precision.

2025-04-10T14:30:00.000000

timestamptz

V1

A timestamp with time zone information, stored in UTC with microsecond precision.

2025-04-10T14:30:00.000000+00:00

timestamp_ns

V3

A timestamp without a time zone, with nanosecond precision.

2025-04-10T14:30:00.000000000

timestamptz_ns

V3

A timestamp with time zone information, stored in UTC with nanosecond precision.

2025-04-10T14:30:00.000000000+00:00

string

V1

A variable-length UTF-8 string.

hello world

uuid

V1

A 128-bit universally unique identifier.

550e8400-e29b-41d4-a716-446655440000

fixed[L]

V1

A fixed-length byte array, where L is the length in bytes.

fixed[16]

binary

V1

A variable-length byte array.

-

Note on version constraints: Types marked as V3, including timestamp_ns, timestamptz_ns, unknown, geometry, and geography, are supported only when the Iceberg format-version is set to 3. OSS Tables uses V2 by default. To use V3 types, you must specify "format-version": "3" in the table properties.

Compatible source types for transforms

Transform

Format

Description

Compatible source types

identity

identity

Identity partition. Partitions by the raw value of the source field.

All primitive types

year

year

Partitions by the year from a source date or timestamp.

date, timestamp, timestamptz, timestamp_ns, timestamptz_ns

month

month

Partitions by the year and month from a source date or timestamp.

date, timestamp, timestamptz, timestamp_ns, timestamptz_ns

day

day

Partitions by the year, month, and day from a source date or timestamp.

date, timestamp, timestamptz, timestamp_ns, timestamptz_ns

hour

hour

Partitions by the year, month, day, and hour from a source timestamp.

timestamp, timestamptz, timestamp_ns, timestamptz_ns

bucket[N]

bucket[N]

Hash bucketing. Partitions data into N buckets by hashing the source field value and using a modulo operation. N must be a positive integer.

int, long, decimal, date, time, timestamp, timestamptz, timestamp_ns, timestamptz_ns, string, uuid, fixed[L], binary

truncate[N]

truncate[N]

Truncate partition. Truncates integer values to a width of N or string values to a length of N characters. N must be a positive integer.

int, long, decimal, string, binary

void

void

Void partition. Maps all values to null. Typically used to remove a partition field while preserving the partition evolution history.

All types

SDK

The following SDKs support the CreateTable interface:

ossutil CLI

For the ossutil command for the CreateTable API, see create-table.

Error codes

Error code

HTTP status code

Description

BadRequestException

400

The request is invalid or malformed.

InvalidTableName

400

Invalid table name. A table name must be 1–255 characters long, contain only lowercase letters, digits, and underscores (_), and cannot start or end with an underscore.

ForbiddenException

403

The caller does not have permission to make this request.

NotFoundException

404

The requested resource does not exist.

ConflictException

409

The request conflicts with a previous write operation.