All Products
Search
Document Center

Object Storage Service:OSS tables

Last Updated:Jul 09, 2026

OSS Tables is a structured data lake storage service from Alibaba Cloud OSS. Built on the Apache Iceberg open table format, it offers cost-effective, high-performance storage for AI training data and OLAP analytics. Its built-in automated maintenance features, including compaction, snapshot management, and dangling file cleanup, provide a zero-maintenance, serverless data lake experience.

Request access

OSS Tables is in a free, invitation-only preview in the China (Hangzhou), China (Shanghai), China (Ulanqab), China (Beijing), China (Shenzhen), Singapore, and Germany (Frankfurt) regions. This preview is available only to customers who have completed enterprise real-name registration. To request access, sign in to your Alibaba Cloud account and navigate to the Table Bucket List page. Monitor your billing notifications during the preview to avoid unexpected charges.

How it works

OSS Tables organizes data using a three-tier structure (Table Bucket - Namespace - Table), providing hierarchical management capabilities, from resource isolation to table management.

  • Table Bucket: A top-level resource container and a cloud resource unit that is used to manage and isolate table resources. Its type is customer, and it is used to host user-created structured data tables. A Table Bucket has its own ARN (Alibaba Cloud Resource Name) in the format acs:osstables:{region}:{uid}:bucket/{bucket-name}.

  • Namespace: A logical isolation layer, similar to a schema in a relational database. It groups tables from different business domains and isolates permissions within a single Table Bucket.

  • Table: The actual data table, stored in the Apache Iceberg format. Each table has a unique ARN in the format acs:osstables:{region}:{uid}:bucket/{bucket-name}/table/{table-id} and supports fine-grained permission control. You must specify a schema when you create a table. Supported field types include long, string, timestamptz, boolean, int, float, double, decimal(P,S), date, time, timestamp, uuid, binary, and fixed[L].

Table bucket

A Table Bucket is the top-level resource container in OSS Tables. It stores and manages tables in the Apache Iceberg format.

Create table bucket

You can create a maximum of 10 Table Buckets per Alibaba Cloud account in a single region. Table Bucket names must be unique within the same region.

Console

  1. Log on to the OSS console. In the left-side navigation pane, select Table Bucket List.

  2. Click Create Table Bucket.

  3. In the Create Table Bucket dialog box, configure the following parameters:

    • Name: Enter a name for the Table Bucket. The name must be 3 to 32 characters long, contain only lowercase letters, digits, and hyphens (-), and cannot start or end with a hyphen. It also cannot start with the prefix oss, acs, aliyun, alibaba, or aws.

    • Region: Select a region, for example, China (Beijing).

    • Data Directory Format: The default value is iceberg.

    • Endpoint: Automatically generated based on the selected region.

    • Redundancy Type: The current value is local redundancy.

    • Server-Side Encryption: Select None or AES256.

  4. Click OK.

ossutil

The following ossutil command creates a Table Bucket:

ossutil tables-api create-table-bucket --name mytablebucket

SDK

Python

The following Python SDK code creates a Table Bucket:

import argparse
import alibabacloud_oss_v2 as oss
import alibabacloud_oss_v2.tables as oss_tables

parser = argparse.ArgumentParser(description="create table bucket sample")
parser.add_argument('--region', help='The region in which the table bucket is located.', required=True)
parser.add_argument('--endpoint', help='The domain names that other services can use to access OSS Tables.')
parser.add_argument('--name', help='The name of the table bucket.', required=True)
parser.add_argument('--sse-algorithm', help='The server-side encryption algorithm.')
parser.add_argument('--kms-key-arn', help='The KMS key ARN for encryption.')

def main():
    args = parser.parse_args()

    credentials_provider = oss.credentials.EnvironmentVariableCredentialsProvider()

    cfg = oss.config.load_default()
    cfg.credentials_provider = credentials_provider
    cfg.region = args.region
    if args.endpoint is not None:
        cfg.endpoint = args.endpoint

    client = oss_tables.Client(cfg)

    encryption_configuration = None
    if args.sse_algorithm is not None or args.kms_key_arn is not None:
        encryption_configuration = oss_tables.models.EncryptionConfiguration(
            sse_algorithm=args.sse_algorithm,
            kms_key_arn=args.kms_key_arn,
        )

    result = client.create_table_bucket(oss_tables.models.CreateTableBucketRequest(
        name=args.name,
        encryption_configuration=encryption_configuration,
    ))

    print(f'status code: {result.status_code},'
          f' request id: {result.request_id},'
          f' arn: {result.arn}')


if __name__ == "__main__":
    main()

Go

The following Go SDK code creates a Table Bucket:

package main

import (
	"context"
	"flag"
	"log"

	"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss"
	"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss/credentials"
	"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss/tables"
)

var (
	region string
	name   string
)

func init() {
	flag.StringVar(&region, "region", "", "The region in which the bucket is located.")
	flag.StringVar(&name, "name", "", "The name of the bucket.")
}

func main() {
	flag.Parse()
	if len(name) == 0 {
		flag.PrintDefaults()
		log.Fatalf("invalid parameters, bucket name required")
	}

	if len(region) == 0 {
		flag.PrintDefaults()
		log.Fatalf("invalid parameters, region required")
	}

	cfg := oss.LoadDefaultConfig().
		WithCredentialsProvider(credentials.NewEnvironmentVariableCredentialsProvider()).
		WithRegion(region)

	client := tables.NewTablesClient(cfg)

	result, err := client.CreateTableBucket(context.TODO(), &tables.CreateTableBucketRequest{
		Name: oss.Ptr(name),
	})

	if err != nil {
		log.Fatalf("failed to create table bucket %v", err)
	}

	log.Printf("create table bucket result:%#v\n", result)
}

Java

The following Java SDK code creates a Table Bucket:

import com.aliyun.sdk.service.oss2.credentials.EnvironmentVariableCredentialsProvider;
import com.aliyun.sdk.service.oss2.tables.OSSTablesClient;
import com.aliyun.sdk.service.oss2.tables.models.*;

public class CreateTableBucketSample {

    public static void main(String[] args) throws Exception {
        String region = "cn-hangzhou";
        String name = "mytablebucket";
        String sseAlgorithm = "AES256";

        try (OSSTablesClient client = OSSTablesClient.newBuilder()
                .credentialsProvider(new EnvironmentVariableCredentialsProvider())
                .region(region)
                .build()) {
            CreateTableBucketRequest.Builder requestBuilder = CreateTableBucketRequest.newBuilder()
                    .name(name);

            EncryptionConfiguration encryptionConfig = EncryptionConfiguration.newBuilder()
                    .sseAlgorithm(sseAlgorithm)
                    .build();
            requestBuilder.encryptionConfiguration(encryptionConfig);

            CreateTableBucketResult result = client.createTableBucket(requestBuilder.build());

            System.out.printf("Status code:%d, request id:%s%n",
                    result.statusCode(), result.requestId());
            System.out.printf("Created table bucket with ARN: %s%n", result.arn());
        } catch (Exception e) {
            System.out.println("Error: " + e.getMessage());
        }
    }
}

API

Call the CreateTableBucket operation to create a Table Bucket.

After a Table Bucket is created, the automatic data maintenance configuration (icebergUnreferencedFileRemoval) is enabled by default to automatically remove unreferenced files in Iceberg tables. The default parameters are unreferencedDays=3 (removes files unreferenced for more than 3 days) and nonCurrentDays=10 (retains non-current file versions for 10 days).

Query table bucket

Console

  1. Log on to the OSS console. In the left-side navigation pane, select Table Bucket List.

  2. Click the name of the Table Bucket to view its details.

  3. On the details page, view the following basic information:

    • Bucket Owner Account ID: The ID of the Alibaba Cloud account that owns the Table Bucket.

    • Resource Identifier (ARN): The globally unique ARN of the Table Bucket.

    • Bucket Type: Displays Customer, which indicates that the Table Bucket was created by a user.

    • Creation Time: The time when the Table Bucket was created.

    • Storage Class: Displays Standard - local redundancy.

    • Server-Side Encryption: Displays the current encryption configuration.

ossutil

The following ossutil command queries a Table Bucket:

ossutil tables-api get-table-bucket --table-bucket-arn acs:osstables:cn-hangzhou:1234567890:bucket/mytablebucket

SDK

Python

The following Python SDK code queries a Table Bucket:

import argparse
import alibabacloud_oss_v2 as oss
import alibabacloud_oss_v2.tables as oss_tables

parser = argparse.ArgumentParser(description="get table bucket sample")
parser.add_argument('--region', help='The region in which the table bucket is located.', required=True)
parser.add_argument('--endpoint', help='The domain names that other services can use to access OSS Tables.')
parser.add_argument('--table-bucket-arn', help='The ARN of the table bucket.', required=True)

def main():
    args = parser.parse_args()

    credentials_provider = oss.credentials.EnvironmentVariableCredentialsProvider()

    cfg = oss.config.load_default()
    cfg.credentials_provider = credentials_provider
    cfg.region = args.region
    if args.endpoint is not None:
        cfg.endpoint = args.endpoint

    client = oss_tables.Client(cfg)

    result = client.get_table_bucket(oss_tables.models.GetTableBucketRequest(
        table_bucket_arn=args.table_bucket_arn,
    ))

    print(f'status code: {result.status_code},'
          f' request id: {result.request_id},'
          f' arn: {result.arn},'
          f' name: {result.name},'
          f' owner account id: {result.owner_account_id},'
          f' created at: {result.created_at},'
          f' table bucket id: {result.table_bucket_id},'
          f' type: {result.type}')


if __name__ == "__main__":
    main()

Go

The following Go SDK code queries a Table Bucket:

package main

import (
	"context"
	"flag"
	"log"

	"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss"
	"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss/credentials"
	"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss/tables"
)

var (
	region         string
	tableBucketArn string
)

func init() {
	flag.StringVar(&region, "region", "", "The region in which the bucket is located.")
	flag.StringVar(&tableBucketArn, "table-bucket-arn", "", "The arn of the table bucket.")
}

func main() {
	flag.Parse()
	if len(tableBucketArn) == 0 {
		flag.PrintDefaults()
		log.Fatalf("invalid parameters, table bucket arn required")
	}

	if len(region) == 0 {
		flag.PrintDefaults()
		log.Fatalf("invalid parameters, region required")
	}

	cfg := oss.LoadDefaultConfig().
		WithCredentialsProvider(credentials.NewEnvironmentVariableCredentialsProvider()).
		WithRegion(region)

	client := tables.NewTablesClient(cfg)

	result, err := client.GetTableBucket(context.TODO(), &tables.GetTableBucketRequest{
		TableBucketARN: oss.Ptr(tableBucketArn),
	})

	if err != nil {
		log.Fatalf("failed to get table bucket %v", err)
	}

	log.Printf("get table bucket result:%#v\n", result)
}

Java

The following Java SDK code queries a Table Bucket:

import com.aliyun.sdk.service.oss2.credentials.EnvironmentVariableCredentialsProvider;
import com.aliyun.sdk.service.oss2.tables.OSSTablesClient;
import com.aliyun.sdk.service.oss2.tables.models.*;

public class GetTableBucketSample {

    public static void main(String[] args) throws Exception {
        String region = "cn-hangzhou";
        String tableBucketARN = "acs:osstables:cn-hangzhou:1234567890:bucket/mytablebucket";

        try (OSSTablesClient client = OSSTablesClient.newBuilder()
                .credentialsProvider(new EnvironmentVariableCredentialsProvider())
                .region(region)
                .build()) {
            GetTableBucketResult result = client.getTableBucket(GetTableBucketRequest.newBuilder()
                    .tableBucketARN(tableBucketARN)
                    .build());

            System.out.printf("Status code:%d, request id:%s%n",
                    result.statusCode(), result.requestId());
            System.out.printf("Table bucket ARN: %s%n", result.arn());
            System.out.printf("Table bucket name: %s%n", result.name());
            System.out.printf("Table bucket type: %s%n", result.type());
            System.out.printf("Owner account ID: %s%n", result.ownerAccountId());
            System.out.printf("Table bucket ID: %s%n", result.tableBucketId());
            System.out.printf("Created at: %s%n", result.createdAt());
        } catch (Exception e) {
            System.out.println("Error: " + e.getMessage());
        }
    }
}

API

Call the GetTableBucket operation to query a Table Bucket.

List table buckets

Console

  1. Log on to the OSS console. In the left-side navigation pane, select Table Bucket List.

  2. On the list page, view information such as the names, regions, and creation times for all Table Buckets in your account.

ossutil

The following ossutil command lists Table Buckets:

ossutil tables-api list-table-buckets

SDK

Python

The following Python SDK code lists Table Buckets:

import argparse
import alibabacloud_oss_v2 as oss
import alibabacloud_oss_v2.tables as oss_tables

parser = argparse.ArgumentParser(description="list table buckets sample")
parser.add_argument('--region', help='The region in which the table buckets are located.', required=True)
parser.add_argument('--endpoint', help='The domain names that other services can use to access OSS Tables.')
parser.add_argument('--prefix', help='The prefix used to filter the table buckets.')
parser.add_argument('--max-buckets', help='The maximum number of buckets to return.', type=int)

def main():
    args = parser.parse_args()

    credentials_provider = oss.credentials.EnvironmentVariableCredentialsProvider()

    cfg = oss.config.load_default()
    cfg.credentials_provider = credentials_provider
    cfg.region = args.region
    if args.endpoint is not None:
        cfg.endpoint = args.endpoint

    client = oss_tables.Client(cfg)

    result = client.list_table_buckets(oss_tables.models.ListTableBucketsRequest(
        prefix=args.prefix,
        max_buckets=args.max_buckets,
    ))

    print(f'status code: {result.status_code},'
          f' request id: {result.request_id},'
          f' continuation token: {result.continuation_token}')

    if result.table_buckets:
        for i, bucket in enumerate(result.table_buckets):
            print(f'bucket {i + 1}:'
                  f' arn: {bucket.arn},'
                  f' name: {bucket.name},'
                  f' id: {bucket.table_bucket_id},'
                  f' owner account id: {bucket.owner_account_id},'
                  f' created at: {bucket.created_at}')


if __name__ == "__main__":
    main()

Go

The following Go SDK code lists Table Buckets:

package main

import (
	"context"
	"flag"
	"log"

	"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss"
	"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss/credentials"
	"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss/tables"
)

var (
	region string
)

func init() {
	flag.StringVar(&region, "region", "", "The region in which the bucket is located.")
}

func main() {
	flag.Parse()

	if len(region) == 0 {
		flag.PrintDefaults()
		log.Fatalf("invalid parameters, region required")
	}

	cfg := oss.LoadDefaultConfig().
		WithCredentialsProvider(credentials.NewEnvironmentVariableCredentialsProvider()).
		WithRegion(region)

	client := tables.NewTablesClient(cfg)

	p := client.NewListTableBucketsPaginator(&tables.ListTableBucketsRequest{})

	var i int
	log.Println("Table Buckets:")
	for p.HasNext() {
		i++

		page, err := p.NextPage(context.TODO())
		if err != nil {
			log.Fatalf("failed to get page %v, %v", i, err)
		}

		// Log the objects found
		for _, b := range page.TableBuckets {
			log.Printf("Table Bucket %v,%v,%v,%v,%v,%v\n", oss.ToString(b.Name), oss.ToString(b.Arn), oss.ToString(b.OwnerAccountId), oss.ToString(b.TableBucketId), oss.ToString(b.CreatedAt), oss.ToString(b.Type))
		}
	}
}

Java

The following Java SDK code lists Table Buckets:

import com.aliyun.sdk.service.oss2.credentials.EnvironmentVariableCredentialsProvider;
import com.aliyun.sdk.service.oss2.tables.OSSTablesClient;
import com.aliyun.sdk.service.oss2.tables.models.*;

public class ListTableBucketsSample {

    public static void main(String[] args) throws Exception {
        String region = "cn-hangzhou";
        int maxBuckets = 10;

        try (OSSTablesClient client = OSSTablesClient.newBuilder()
                .credentialsProvider(new EnvironmentVariableCredentialsProvider())
                .region(region)
                .build()) {
            ListTableBucketsRequest request = ListTableBucketsRequest.newBuilder()
                    .maxBuckets(maxBuckets)
                    .build();

            ListTableBucketsResult result = client.listTableBuckets(request);

            System.out.printf("Status code:%d, request id:%s%n",
                    result.statusCode(), result.requestId());
            System.out.printf("Continuation token: %s%n", result.continuationToken());
            System.out.printf("Number of buckets: %d%n", result.tableBuckets().size());

            for (int i = 0; i < result.tableBuckets().size(); i++) {
                TableBucketSummary bucket = result.tableBuckets().get(i);
                System.out.printf("Bucket %d:%n", i + 1);
                System.out.printf("  ARN: %s%n", bucket.arn());
                System.out.printf("  Name: %s%n", bucket.name());
                System.out.printf("  ID: %s%n", bucket.tableBucketId());
                System.out.printf("  Owner Account ID: %s%n", bucket.ownerAccountId());
                System.out.printf("  Created At: %s%n", bucket.createdAt());
            }
        } catch (Exception e) {
            System.out.println("Error: " + e.getMessage());
        }
    }
}

API

Call the ListTableBuckets operation to list Table Buckets.

Delete table bucket

To delete a Table Bucket, you must first delete all tables and namespaces within it. You cannot delete a non-empty Table Bucket. This operation is irreversible. Proceed with caution.

Console

  1. Log on to the OSS console. In the left-side navigation pane, select Table Bucket List.

  2. In the Actions column for the Table Bucket, click Delete.

  3. In the confirmation dialog box, click OK.

ossutil

The following ossutil command deletes a Table Bucket:

ossutil tables-api delete-table-bucket --table-bucket-arn acs:osstables:cn-hangzhou:1234567890:bucket/mytablebucket

SDK

Python

The following Python SDK code deletes a Table Bucket:

import argparse
import alibabacloud_oss_v2 as oss
import alibabacloud_oss_v2.tables as oss_tables

parser = argparse.ArgumentParser(description="delete table bucket sample")
parser.add_argument('--region', help='The region in which the table bucket is located.', required=True)
parser.add_argument('--endpoint', help='The domain names that other services can use to access OSS Tables.')
parser.add_argument('--table-bucket-arn', help='The ARN of the table bucket.', required=True)

def main():
    args = parser.parse_args()

    credentials_provider = oss.credentials.EnvironmentVariableCredentialsProvider()

    cfg = oss.config.load_default()
    cfg.credentials_provider = credentials_provider
    cfg.region = args.region
    if args.endpoint is not None:
        cfg.endpoint = args.endpoint

    client = oss_tables.Client(cfg)

    result = client.delete_table_bucket(oss_tables.models.DeleteTableBucketRequest(
        table_bucket_arn=args.table_bucket_arn,
    ))

    print(f'status code: {result.status_code},'
          f' request id: {result.request_id}')


if __name__ == "__main__":
    main()

Go

The following Go SDK code deletes a Table Bucket:

package main

import (
	"context"
	"flag"
	"log"

	"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss"
	"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss/credentials"
	"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss/tables"
)

var (
	region         string
	tableBucketArn string
)

func init() {
	flag.StringVar(&region, "region", "", "The region in which the bucket is located.")
	flag.StringVar(&tableBucketArn, "table-bucket-arn", "", "The arn of the table bucket.")
}

func main() {
	flag.Parse()
	if len(tableBucketArn) == 0 {
		flag.PrintDefaults()
		log.Fatalf("invalid parameters, table bucket arn required")
	}

	if len(region) == 0 {
		flag.PrintDefaults()
		log.Fatalf("invalid parameters, region required")
	}

	cfg := oss.LoadDefaultConfig().
		WithCredentialsProvider(credentials.NewEnvironmentVariableCredentialsProvider()).
		WithRegion(region)

	client := tables.NewTablesClient(cfg)

	result, err := client.DeleteTableBucket(context.TODO(), &tables.DeleteTableBucketRequest{
		TableBucketARN: oss.Ptr(tableBucketArn),
	})

	if err != nil {
		log.Fatalf("failed to delete table bucket %v", err)
	}

	log.Printf("delete table bucket result:%#v\n", result)
}

Java

The following Java SDK code deletes a Table Bucket:

import com.aliyun.sdk.service.oss2.credentials.EnvironmentVariableCredentialsProvider;
import com.aliyun.sdk.service.oss2.tables.OSSTablesClient;
import com.aliyun.sdk.service.oss2.tables.models.*;

public class DeleteTableBucketSample {

    public static void main(String[] args) throws Exception {
        String region = "cn-hangzhou";
        String tableBucketARN = "acs:osstables:cn-hangzhou:1234567890:bucket/mytablebucket";

        try (OSSTablesClient client = OSSTablesClient.newBuilder()
                .credentialsProvider(new EnvironmentVariableCredentialsProvider())
                .region(region)
                .build()) {
            DeleteTableBucketRequest request = DeleteTableBucketRequest.newBuilder()
                    .tableBucketARN(tableBucketARN)
                    .build();

            DeleteTableBucketResult result = client.deleteTableBucket(request);

            System.out.printf("Status code:%d, request id:%s%n",
                    result.statusCode(), result.requestId());
            System.out.println("Successfully deleted table bucket.");
        } catch (Exception e) {
            System.out.println("Error: " + e.getMessage());
        }
    }
}

API

Call the DeleteTableBucket operation to delete a Table Bucket.

Namespace

A namespace logically groups and isolates tables within a table bucket, similar to a schema in a relational database. You can create up to 10,000 namespaces per table bucket.

In the OSS console, you manage namespaces as part of the table creation workflow. To create a table, you can either select an existing namespace from the Namespace drop-down menu or create a new one by clicking Create Namespace and entering a name. You can also manage namespaces independently with ossutil, the SDK, or the API.

Namespace naming rules:

  • Must be 1 to 255 characters in length.

  • Can contain only lowercase letters, digits, and underscores (_).

  • Cannot start or end with an underscore.

  • Must be unique within a table bucket.

Create namespace

ossutil

ossutil tables-api create-namespace \
  --table-bucket-arn acs:osstables:cn-hangzhou:1234567890:bucket/mytablebucket \
  --namespace mynamespace

SDK

Python

import argparse
import alibabacloud_oss_v2 as oss
import alibabacloud_oss_v2.tables as oss_tables

parser = argparse.ArgumentParser(description="create namespace sample")
parser.add_argument('--region', help='The region where the table bucket is located.', required=True)
parser.add_argument('--endpoint', help='The endpoint for accessing OSS Tables.')
parser.add_argument('--table-bucket-arn', help='The ARN of the table bucket.', required=True)
parser.add_argument('--namespace', help='The namespace to create, comma separated if multiple.', required=True)

def main():
    args = parser.parse_args()

    credentials_provider = oss.credentials.EnvironmentVariableCredentialsProvider()

    cfg = oss.config.load_default()
    cfg.credentials_provider = credentials_provider
    cfg.region = args.region
    if args.endpoint is not None:
        cfg.endpoint = args.endpoint

    client = oss_tables.Client(cfg)

    namespaces = args.namespace.split(",")

    result = client.create_namespace(oss_tables.models.CreateNamespaceRequest(
        table_bucket_arn=args.table_bucket_arn,
        namespace=namespaces,
    ))

    print(f'status code: {result.status_code},'
          f' request id: {result.request_id}')
    print(f'successfully created namespace(s) in table bucket: {args.table_bucket_arn}')


if __name__ == "__main__":
    main()

Go

package main

import (
	"context"
	"flag"
	"log"

	"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss"
	"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss/credentials"
	"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss/tables"
)

var (
	region         string
	tableBucketArn string
)

func init() {
	flag.StringVar(&region, "region", "", "The region where the bucket is located.")
	flag.StringVar(&tableBucketArn, "table-bucket-arn", "", "The ARN of the table bucket.")
}

func main() {
	flag.Parse()
	if len(tableBucketArn) == 0 {
		flag.PrintDefaults()
		log.Fatalf("invalid parameters, table bucket arn required")
	}

	if len(region) == 0 {
		flag.PrintDefaults()
		log.Fatalf("invalid parameters, region required")
	}

	cfg := oss.LoadDefaultConfig().
		WithCredentialsProvider(credentials.NewEnvironmentVariableCredentialsProvider()).
		WithRegion(region)

	client := tables.NewTablesClient(cfg)

	result, err := client.CreateNamespace(context.TODO(), &tables.CreateNamespaceRequest{
		TableBucketARN: oss.Ptr(tableBucketArn),
		Namespace:      []string{"my_space"},
	})

	if err != nil {
		log.Fatalf("failed to create namespace %v", err)
	}

	log.Printf("create namespace result:%#v\n", result)
}

Java

import com.aliyun.sdk.service.oss2.credentials.EnvironmentVariableCredentialsProvider;
import com.aliyun.sdk.service.oss2.tables.OSSTablesClient;
import com.aliyun.sdk.service.oss2.tables.models.*;

import java.util.Arrays;
import java.util.List;

public class CreateNamespaceSample {

    public static void main(String[] args) throws Exception {
        String region = "cn-hangzhou";
        String tableBucketARN = "acs:osstables:cn-hangzhou:1234567890:bucket/mytablebucket";
        String namespace = "mynamespace";

        try (OSSTablesClient client = OSSTablesClient.newBuilder()
                .credentialsProvider(new EnvironmentVariableCredentialsProvider())
                .region(region)
                .build()) {
            List<String> namespaces = Arrays.asList("mynamespace");

            CreateNamespaceRequest request = CreateNamespaceRequest.newBuilder()
                    .tableBucketARN(tableBucketARN)
                    .namespace(namespaces)
                    .build();

            CreateNamespaceResult result = client.createNamespace(request);

            System.out.printf("Status code:%d, request id:%s%n",
                    result.statusCode(), result.requestId());
            System.out.printf("Successfully created namespace(s) in table bucket: %s%n", tableBucketARN);
        } catch (Exception e) {
            System.out.println("Error: " + e.getMessage());
        }
    }
}

API

Use the CreateNamespace API operation to create a namespace.

Get namespace

ossutil

ossutil tables-api get-namespace \
  --table-bucket-arn acs:osstables:cn-hangzhou:1234567890:bucket/mytablebucket \
  --namespace mynamespace

SDK

Python

import argparse
import alibabacloud_oss_v2 as oss
import alibabacloud_oss_v2.tables as oss_tables

parser = argparse.ArgumentParser(description="get namespace sample")
parser.add_argument('--region', help='The region where the table bucket is located.', required=True)
parser.add_argument('--endpoint', help='The endpoint for accessing OSS Tables.')
parser.add_argument('--table-bucket-arn', help='The ARN of the table bucket.', required=True)
parser.add_argument('--namespace', help='The namespace to get.', required=True)

def main():
    args = parser.parse_args()

    credentials_provider = oss.credentials.EnvironmentVariableCredentialsProvider()

    cfg = oss.config.load_default()
    cfg.credentials_provider = credentials_provider
    cfg.region = args.region
    if args.endpoint is not None:
        cfg.endpoint = args.endpoint

    client = oss_tables.Client(cfg)

    result = client.get_namespace(oss_tables.models.GetNamespaceRequest(
        table_bucket_arn=args.table_bucket_arn,
        namespace=args.namespace,
    ))

    print(f'status code: {result.status_code},'
          f' request id: {result.request_id},'
          f' namespace: {result.namespace},'
          f' namespace id: {result.namespace_id},'
          f' table bucket id: {result.table_bucket_id},'
          f' owner account id: {result.owner_account_id},'
          f' created at: {result.created_at},'
          f' created by: {result.created_by}')


if __name__ == "__main__":
    main()

Go

package main

import (
	"context"
	"flag"
	"log"

	"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss"
	"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss/credentials"
	"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss/tables"
)

var (
	region         string
	tableBucketArn string
)

func init() {
	flag.StringVar(&region, "region", "", "The region where the bucket is located.")
	flag.StringVar(&tableBucketArn, "table-bucket-arn", "", "The ARN of the table bucket.")
}

func main() {
	flag.Parse()
	if len(tableBucketArn) == 0 {
		flag.PrintDefaults()
		log.Fatalf("invalid parameters, table bucket arn required")
	}

	if len(region) == 0 {
		flag.PrintDefaults()
		log.Fatalf("invalid parameters, region required")
	}

	cfg := oss.LoadDefaultConfig().
		WithCredentialsProvider(credentials.NewEnvironmentVariableCredentialsProvider()).
		WithRegion(region)

	client := tables.NewTablesClient(cfg)

	result, err := client.GetNamespace(context.TODO(), &tables.GetNamespaceRequest{
		TableBucketARN: oss.Ptr(tableBucketArn),
		Namespace:      oss.Ptr("my_space"),
	})

	if err != nil {
		log.Fatalf("failed to get namespace %v", err)
	}

	log.Printf("get namespace result:%#v\n", result)
}

Java

import com.aliyun.sdk.service.oss2.credentials.EnvironmentVariableCredentialsProvider;
import com.aliyun.sdk.service.oss2.tables.OSSTablesClient;
import com.aliyun.sdk.service.oss2.tables.models.*;

public class GetNamespaceSample {

    public static void main(String[] args) throws Exception {
        String region = "cn-hangzhou";
        String tableBucketARN = "acs:osstables:cn-hangzhou:1234567890:bucket/mytablebucket";
        String namespace = "mynamespace";

        try (OSSTablesClient client = OSSTablesClient.newBuilder()
                .credentialsProvider(new EnvironmentVariableCredentialsProvider())
                .region(region)
                .build()) {
            GetNamespaceRequest request = GetNamespaceRequest.newBuilder()
                    .tableBucketARN(tableBucketARN)
                    .namespace(namespace)
                    .build();

            GetNamespaceResult result = client.getNamespace(request);

            System.out.printf("Status code:%d, request id:%s%n",
                    result.statusCode(), result.requestId());
            System.out.printf("Successfully retrieved namespace: %s from table bucket: %s%n", result.namespaceId(), tableBucketARN);
        } catch (Exception e) {
            System.out.println("Error: " + e.getMessage());
        }
    }
}

API

Use the GetNamespace API operation to get the details of a namespace.

List namespaces

ossutil

ossutil tables-api list-namespaces \
  --table-bucket-arn acs:osstables:cn-hangzhou:1234567890:bucket/mytablebucket

SDK

Python

import argparse
import alibabacloud_oss_v2 as oss
import alibabacloud_oss_v2.tables as oss_tables

parser = argparse.ArgumentParser(description="list namespaces sample")
parser.add_argument('--region', help='The region where the table bucket is located.', required=True)
parser.add_argument('--endpoint', help='The endpoint for accessing OSS Tables.')
parser.add_argument('--table-bucket-arn', help='The ARN of the table bucket.', required=True)
parser.add_argument('--prefix', help='The prefix to filter namespaces.')
parser.add_argument('--max-namespaces', type=int, help='The maximum number of namespaces to return.')

def main():
    args = parser.parse_args()

    credentials_provider = oss.credentials.EnvironmentVariableCredentialsProvider()

    cfg = oss.config.load_default()
    cfg.credentials_provider = credentials_provider
    cfg.region = args.region
    if args.endpoint is not None:
        cfg.endpoint = args.endpoint

    client = oss_tables.Client(cfg)

    result = client.list_namespaces(oss_tables.models.ListNamespacesRequest(
        table_bucket_arn=args.table_bucket_arn,
        prefix=args.prefix,
        max_namespaces=args.max_namespaces,
    ))

    print(f'status code: {result.status_code},'
          f' request id: {result.request_id},'
          f' continuation token: {result.continuation_token}')

    if result.namespaces:
        for i, ns in enumerate(result.namespaces):
            print(f'namespace {i + 1}:'
                  f' namespace: {ns.namespace},'
                  f' namespace id: {ns.namespace_id},'
                  f' owner account id: {ns.owner_account_id},'
                  f' created at: {ns.created_at},'
                  f' created by: {ns.created_by}')


if __name__ == "__main__":
    main()

Go

package main

import (
	"context"
	"flag"
	"log"

	"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss"
	"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss/credentials"
	"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss/tables"
)

var (
	region         string
	tableBucketArn string
)

func init() {
	flag.StringVar(&region, "region", "", "The region where the bucket is located.")
	flag.StringVar(&tableBucketArn, "table-bucket-arn", "", "The ARN of the table bucket.")
}

func main() {
	flag.Parse()
	if len(tableBucketArn) == 0 {
		flag.PrintDefaults()
		log.Fatalf("invalid parameters, table bucket arn required")
	}

	if len(region) == 0 {
		flag.PrintDefaults()
		log.Fatalf("invalid parameters, region required")
	}

	cfg := oss.LoadDefaultConfig().
		WithCredentialsProvider(credentials.NewEnvironmentVariableCredentialsProvider()).
		WithRegion(region)

	client := tables.NewTablesClient(cfg)

	p := client.NewListNameSpacesPaginator(&tables.ListNamespacesRequest{
		TableBucketARN: oss.Ptr(tableBucketArn),
	})

	var i int
	log.Println("Namespaces:")
	for p.HasNext() {
		i++

		page, err := p.NextPage(context.TODO())
		if err != nil {
			log.Fatalf("failed to get page %v, %v", i, err)
		}

		for _, b := range page.Namespaces {
			log.Printf("Namespace %v,%v,%v,%v,%v,%v\n", oss.ToString(b.CreatedAt), oss.ToString(b.CreatedBy), oss.ToString(b.OwnerAccountId), oss.ToString(b.TableBucketId), oss.ToString(b.NamespaceId), b.Namespace)
		}
	}
}

Java

import com.aliyun.sdk.service.oss2.credentials.EnvironmentVariableCredentialsProvider;
import com.aliyun.sdk.service.oss2.tables.OSSTablesClient;
import com.aliyun.sdk.service.oss2.tables.models.*;

public class ListNamespacesSample {

    public static void main(String[] args) throws Exception {
        String region = "cn-hangzhou";
        String tableBucketARN = "acs:osstables:cn-hangzhou:1234567890:bucket/mytablebucket";
        int maxNamespaces = 10;

        try (OSSTablesClient client = OSSTablesClient.newBuilder()
                .credentialsProvider(new EnvironmentVariableCredentialsProvider())
                .region(region)
                .build()) {
            ListNamespacesRequest request = ListNamespacesRequest.newBuilder()
                    .tableBucketARN(tableBucketARN)
                    .maxNamespaces(maxNamespaces)
                    .build();

            ListNamespacesResult result = client.listNamespaces(request);

            System.out.printf("Status code:%d, request id:%s%n",
                    result.statusCode(), result.requestId());
            System.out.printf("Successfully listed namespaces for table bucket: %s%n", tableBucketARN);
            System.out.printf("Continuation token: %s%n", result.continuationToken());

            for (int i = 0; i < result.namespaces().size(); i++) {
                NamespaceSummary ns = result.namespaces().get(i);
                if (ns.namespace() != null && !ns.namespace().isEmpty()) {
                    System.out.printf("Namespace %%d: %%s (ID: %%s)%%n", i+1, ns.namespace().get(0), ns.namespaceId());
                } else {
                    System.out.printf("Namespace %%d: (no namespace name) (ID: %%s)%%n", i+1, ns.namespaceId());
                }
            }
        } catch (Exception e) {
            System.out.println("Error: " + e.getMessage());
        }
    }
}

API

Use the ListNamespaces API operation to list namespaces.

Delete namespace

You must delete all tables in a namespace before you can delete the namespace.

ossutil

ossutil tables-api delete-namespace \
  --table-bucket-arn acs:osstables:cn-hangzhou:1234567890:bucket/mytablebucket \
  --namespace mynamespace

SDK

Python

import argparse
import alibabacloud_oss_v2 as oss
import alibabacloud_oss_v2.tables as oss_tables

parser = argparse.ArgumentParser(description="delete namespace sample")
parser.add_argument('--region', help='The region where the table bucket is located.', required=True)
parser.add_argument('--endpoint', help='The endpoint for accessing OSS Tables.')
parser.add_argument('--table-bucket-arn', help='The ARN of the table bucket.', required=True)
parser.add_argument('--namespace', help='The namespace to delete.', required=True)

def main():
    args = parser.parse_args()

    credentials_provider = oss.credentials.EnvironmentVariableCredentialsProvider()

    cfg = oss.config.load_default()
    cfg.credentials_provider = credentials_provider
    cfg.region = args.region
    if args.endpoint is not None:
        cfg.endpoint = args.endpoint

    client = oss_tables.Client(cfg)

    result = client.delete_namespace(oss_tables.models.DeleteNamespaceRequest(
        table_bucket_arn=args.table_bucket_arn,
        namespace=args.namespace,
    ))

    print(f'status code: {result.status_code},'
          f' request id: {result.request_id}')
    print(f'successfully deleted namespace: {args.namespace}')


if __name__ == "__main__":
    main()

Go

package main

import (
	"context"
	"flag"
	"log"

	"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss"
	"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss/credentials"
	"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss/tables"
)

var (
	region         string
	tableBucketArn string
)

func init() {
	flag.StringVar(&region, "region", "", "The region where the bucket is located.")
	flag.StringVar(&tableBucketArn, "table-bucket-arn", "", "The ARN of the table bucket.")
}

func main() {
	flag.Parse()
	if len(tableBucketArn) == 0 {
		flag.PrintDefaults()
		log.Fatalf("invalid parameters, table bucket arn required")
	}

	if len(region) == 0 {
		flag.PrintDefaults()
		log.Fatalf("invalid parameters, region required")
	}

	cfg := oss.LoadDefaultConfig().
		WithCredentialsProvider(credentials.NewEnvironmentVariableCredentialsProvider()).
		WithRegion(region)

	client := tables.NewTablesClient(cfg)

	result, err := client.DeleteNamespace(context.TODO(), &tables.DeleteNamespaceRequest{
		TableBucketARN: oss.Ptr(tableBucketArn),
		Namespace:      oss.Ptr("my_space"),
	})

	if err != nil {
		log.Fatalf("failed to delete namespace %v", err)
	}

	log.Printf("delete namespace result:%#v\n", result)
}

Java

import com.aliyun.sdk.service.oss2.credentials.EnvironmentVariableCredentialsProvider;
import com.aliyun.sdk.service.oss2.tables.OSSTablesClient;
import com.aliyun.sdk.service.oss2.tables.models.*;

public class DeleteNamespaceSample {

    public static void main(String[] args) throws Exception {
        String region = "cn-hangzhou";
        String tableBucketARN = "acs:osstables:cn-hangzhou:1234567890:bucket/mytablebucket";
        String namespace = "mynamespace";

        try (OSSTablesClient client = OSSTablesClient.newBuilder()
                .credentialsProvider(new EnvironmentVariableCredentialsProvider())
                .region(region)
                .build()) {
            DeleteNamespaceRequest request = DeleteNamespaceRequest.newBuilder()
                    .tableBucketARN(tableBucketARN)
                    .namespace(namespace)
                    .build();

            DeleteNamespaceResult result = client.deleteNamespace(request);

            System.out.printf("Status code:%d, request id:%s%n",
                    result.statusCode(), result.requestId());
            System.out.printf("Successfully deleted namespace: %s from table bucket: %s%n", namespace, tableBucketARN);
        } catch (Exception e) {
            System.out.println("Error: " + e.getMessage());
        }
    }
}

API

Use the DeleteNamespace API operation to delete a namespace.

Table

A table is a dataset stored in the Apache Iceberg format.

Create a table

If the target namespace does not exist, create it first. Each Table Bucket can contain up to 10,000 namespaces and 10,000 tables.

Schema

Note

Currently, the console does not support Iceberg nested types, such as struct, list, and map. You must use the API to manage tables that contain nested types.

When you create a table, you define its field structure using a schema. Each field has attributes such as name, type, and whether it is required.

The following table describes the supported field types.

Type

Description

boolean

A true or false value.

int

A 32-bit signed integer.

long

A 64-bit signed integer.

float

A 32-bit IEEE 754 floating-point number.

double

A 64-bit IEEE 754 floating-point number.

decimal(P,S)

A fixed-precision decimal, where P is the precision and S is the scale.

date

A date without time or time zone.

timestamp

A timestamp with microsecond precision, without time zone information.

timestamptz

A timestamp with microsecond precision, with time zone information.

string

A UTF-8 encoded string.

binary

A variable-length byte array.

uuid

A Universally Unique Identifier (UUID).

The following is an example of a schema definition:

{
  "schema": {
    "fields": [
      {"name": "id", "type": "long", "required": true},
      {"name": "name", "type": "string", "required": true},
      {"name": "created_at", "type": "timestamptz", "required": false}
    ]
  }
}

Partition spec

A partition specification (Partition Spec) defines how the data in a table is partitioned. A well-designed partition specification can significantly improve query performance by reducing the amount of data scanned.

The following partition transform types are supported:

Transform type

Description

Applicable types

identity

Partitions by the column's raw value without a transform.

All types.

year

Partitions by the year extracted from a date or timestamp.

date, timestamp, timestamptz.

month

Partitions by the month extracted from a date or timestamp.

date, timestamp, timestamptz.

day

Partitions by the day extracted from a date or timestamp.

date, timestamp, timestamptz.

hour

Partitions by the hour extracted from a timestamp.

timestamp, timestamptz.

bucket[N]

Partitions by hashing the column value into N buckets. This is suitable for evenly distributing high-cardinality fields.

int, long, string, decimal, date, timestamp, timestamptz, uuid.

truncate[N]

Partitions by truncating int/long values to width N and string values to length N.

int, long, string, decimal.

Console

To create a table in the OSS console, follow these steps:

  1. Log on to the OSS console. In the navigation pane on the left, choose Table Bucket List.

  2. Click the name of the target Table Bucket to open its details page.

  3. On the Table List tab, click Create Table.

  4. In the Create Table dialog box, configure the following parameters:

    • Namespace: Select an existing namespace from the drop-down menu, or enter a new name to create one. The name must be 1 to 255 characters long and unique within the Table Bucket. It can only contain lowercase letters, digits, and underscores (_), and cannot start or end with an underscore.

    • Table Format: Select Iceberg.

    • Table Name: Enter a name for the table. The name must be 1 to 255 characters long and unique within the namespace. It can only contain lowercase letters, digits, and underscores (_), and cannot start or end with an underscore.

    • Server-side Encryption Method: Select None or AES256.

    • Table Format Version: Select an Iceberg table format version, such as 2.

    • Field Information: Add fields. For each field, configure its ID, Column Name, Required status, and Data Type.

    • Partition Information: Add partitions. For each partition, configure the sourceId, Partition Field Name, and transform.

    • Sort Information: Add sort orders. For each sort order, configure the sourceId, transform, direction, and nullOrder.

  5. Click OK.

ossutil

Before you use ossutil to create a table, you must first create a namespace if the target namespace does not exist. The following is an example of the command to create a table. In this command, the properties parameter contains format-version, which specifies the Iceberg table format version and can be set to 2 or 3. Use the --encryption-configuration parameter to configure server-side encryption.

# Step 2: Create a table, specifying the table format version and server-side encryption method
ossutil tables-api create-table \
  --region cn-hangzhou \
  --endpoint https://cn-hangzhou.oss-tables.aliyuncs.com \
  --table-bucket-arn acs:osstables:cn-hangzhou:1234567890:bucket/mytablebucket \
  --namespace mynamespace \
  --name mytable \
  --format ICEBERG \
  --metadata '{"iceberg":{"schema":{"fields":[{"name":"id","type":"long","required":true},{"name":"data","type":"string"}]},"properties":{"format-version":"2"}}}' \
  --encryption-configuration '{"sseAlgorithm":"AES256"}'

SDK

Python

The following code shows how to create a table using the Python SDK. If the target namespace does not exist, you must create it first.

import argparse
import alibabacloud_oss_v2 as oss
import alibabacloud_oss_v2.tables as oss_tables

parser = argparse.ArgumentParser(description="create table sample")
parser.add_argument('--region', help='The region in which the table bucket is located.', required=True)
parser.add_argument('--endpoint', help='The domain names that other services can use to access OSS Tables.')
parser.add_argument('--table-bucket-arn', help='The ARN of the table bucket.', required=True)
parser.add_argument('--namespace', help='The namespace of the table.', required=True)
parser.add_argument('--name', help='The name of the table.', required=True)
parser.add_argument('--format', help='The format of the table.', required=True)

def main():
    args = parser.parse_args()

    credentials_provider = oss.credentials.EnvironmentVariableCredentialsProvider()

    cfg = oss.config.load_default()
    cfg.credentials_provider = credentials_provider
    cfg.region = args.region
    if args.endpoint is not None:
        cfg.endpoint = args.endpoint

    client = oss_tables.Client(cfg)

    # Create schema fields
    schema = oss_tables.models.IcebergSchema(fields=[
        oss_tables.models.SchemaField(name="id", type="long", required=True),
        oss_tables.models.SchemaField(name="name", type="string", required=False),
        oss_tables.models.SchemaField(name="ts", type="timestamptz", required=False),
    ])

    # Create partition spec
    partition_spec = oss_tables.models.IcebergPartitionSpec(
        spec_id=0,
        fields=[
            oss_tables.models.IcebergPartitionField(
                source_id=2,
                field_id=1001,
                name="region",
                transform="identity",
            ),
        ],
    )

    # Create Iceberg metadata. Use 'properties' to specify 'format-version', which supports "2" and "3".
    iceberg_metadata = oss_tables.models.IcebergMetadata(
        schema=schema,
        partition_spec=partition_spec,
        properties={"format-version": "2"},
    )

    # Set metadata
    metadata = oss_tables.models.TableMetadata(iceberg=iceberg_metadata)

    # Add encryption configuration. 'sse_algorithm' supports "AES256" and "KMS". If using "KMS", 'kms_key_arn' must also be specified.
    encryption_configuration = oss_tables.models.EncryptionConfiguration(
        sse_algorithm="AES256",
    )

    result = client.create_table(oss_tables.models.CreateTableRequest(
        table_bucket_arn=args.table_bucket_arn,
        namespace=args.namespace,
        name=args.name,
        format=args.format,
        metadata=metadata,
        encryption_configuration=encryption_configuration,
    ))

    print(f'status code: {result.status_code},'
          f' request id: {result.request_id},'
          f' table arn: {result.table_arn},'
          f' version token: {result.version_token}')


if __name__ == "__main__":
    main()

Go

The following code shows how to create a table using the Go SDK. If the target namespace does not exist, you must create it first.

package main

import (
	"context"
	"flag"
	"log"

	"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss"
	"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss/credentials"
	"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss/tables"
)

var (
	region         string
	tableBucketArn string
	namespace      string
	name           string
)

func init() {
	flag.StringVar(&region, "region", "", "The region in which the bucket is located.")
	flag.StringVar(&tableBucketArn, "table-bucket-arn", "", "The arn of the table bucket.")
	flag.StringVar(&namespace, "namespace", "", "The name of the namespace.")
	flag.StringVar(&name, "name", "", "The name of the table.")
}

func main() {
	flag.Parse()
	if len(tableBucketArn) == 0 {
		flag.PrintDefaults()
		log.Fatalf("invalid parameters, table bucket arn required")
	}

	if len(namespace) == 0 {
		flag.PrintDefaults()
		log.Fatalf("invalid parameters, namespace name required")
	}

	if len(name) == 0 {
		flag.PrintDefaults()
		log.Fatalf("invalid parameters, table name required")
	}

	if len(region) == 0 {
		flag.PrintDefaults()
		log.Fatalf("invalid parameters, region required")
	}

	cfg := oss.LoadDefaultConfig().
		WithCredentialsProvider(credentials.NewEnvironmentVariableCredentialsProvider()).
		WithRegion(region)

	client := tables.NewTablesClient(cfg)

	// Build the complete Iceberg metadata using a map. 'format-version' in properties specifies the table format version ("2" or "3").
	icebergMap := map[string]any{
		"schema": map[string]any{
			"fields": []map[string]any{
				{"name": "id", "type": "long", "required": true},
				{"name": "data", "type": "string"},
			},
		},
		"properties": map[string]any{
			"format-version": "2",
		},
	}

	result, err := client.CreateTable(context.TODO(), &tables.CreateTableRequest{
		TableBucketARN: oss.Ptr(tableBucketArn),
		Namespace:      oss.Ptr(namespace),
		Name:           oss.Ptr(name),
		Format:         oss.Ptr("ICEBERG"),
		Metadata: &tables.TableMetadata{
			Iceberg: &tables.IcebergMetadata{Schema: icebergMap},
		},
		// Server-side encryption: SseAlgorithm
		EncryptionConfiguration: &tables.EncryptionConfiguration{
			SseAlgorithm: oss.Ptr("AES256"),
		},
	})

	if err != nil {
		log.Fatalf("failed to create table %v", err)
	}

	log.Printf("create table result:%#v\n", result)
}

Java

The following code shows how to create a table using the Java SDK. If the target namespace does not exist, you must create it first.

import com.aliyun.sdk.service.oss2.credentials.EnvironmentVariableCredentialsProvider;
import com.aliyun.sdk.service.oss2.tables.OSSTablesClient;
import com.aliyun.sdk.service.oss2.tables.models.*;

import java.util.ArrayList;
import java.util.List;

public class CreateTableSample {

    public static void main(String[] args) throws Exception {
        String region = "cn-hangzhou";
        String tableBucketARN = "acs:osstables:cn-hangzhou:1234567890:bucket/mytablebucket";
        String namespace = "mynamespace";
        String name = "mytable";
        String format = "iceberg";

        try (OSSTablesClient client = OSSTablesClient.newBuilder()
                .credentialsProvider(new EnvironmentVariableCredentialsProvider())
                .region(region)
                .build()) {
            // Create schema fields
            List<SchemaField> fields = new ArrayList<>();
            fields.add(SchemaField.newBuilder()
                .name("id")
                .type("long")
                .required(true)
                .build());
            fields.add(SchemaField.newBuilder()
                .name("name")
                .type("string")
                .required(false)
                .build());
            fields.add(SchemaField.newBuilder()
                .name("ts")
                .type("timestamptz")
                .required(false)
                .build());

            // Create schema
            IcebergSchema icebergSchema = IcebergSchema.newBuilder()
                .fields(fields)
                .build();

            // Create partition spec
            IcebergPartitionField partitionField = IcebergPartitionField.newBuilder()
                .sourceId(2)
                .transform("identity")
                .name("region")
                .fieldId(1001)
                .build();
            List<IcebergPartitionField> partitionFields = new ArrayList<>();
            partitionFields.add(partitionField);
            IcebergPartitionSpec partitionSpec = IcebergPartitionSpec.newBuilder()
                .specId(0)
                .fields(partitionFields)
                .build();

            // Create iceberg metadata
            IcebergMetadata icebergMetadata = IcebergMetadata.newBuilder()
                .schema(icebergSchema)
                .partitionSpec(partitionSpec)
                .build();

            // Set metadata
            TableMetadata metadata = TableMetadata.newBuilder()
                .iceberg(icebergMetadata)
                .build();

            // Add encryption configuration
            EncryptionConfiguration encryptionConfig = EncryptionConfiguration.newBuilder()
                .sseAlgorithm("AES256")
                .build();

            CreateTableRequest request = CreateTableRequest.newBuilder()
                    .tableBucketARN(tableBucketARN)
                    .namespace(namespace)
                    .name(name)
                    .format(format)
                    .metadata(metadata)
                    .encryptionConfiguration(encryptionConfig)
                    .build();

            CreateTableResult result = client.createTable(request);

            System.out.printf("Status code:%d, request id:%s%n",
                    result.statusCode(), result.requestId());
            System.out.printf("Created table with ARN: %s%n", result.tableARN());
            System.out.printf("Version token: %s%n", result.versionToken());
        } catch (Exception e) {
            System.out.println("Error: " + e.getMessage());
        }
    }
}

API

Use the CreateTable API operation to create a table.

Get a Table

Retrieves detailed information for a Table, including its name, namespace, Table ARN, format, versionToken, metadataLocation, and warehouseLocation.

Console

Follow these steps to view the details of a Table in the OSS console:

  1. Log on to the OSS console. In the left navigation pane, choose Table Bucket list.

  2. Click the name of the target Table Bucket to view its details.

  3. On the Table list tab, click the name of the target Table to view its details.

ossutil

The following example shows how to use the ossutil command to retrieve information for a Table:

ossutil tables-api get-table \
  --table-bucket-arn acs:osstables:cn-hangzhou:1234567890:bucket/mytablebucket \
  --namespace mynamespace \
  --name mytable

SDK

Python

The following code provides an example of how to use the Python SDK to retrieve information for a Table:

import argparse
import alibabacloud_oss_v2 as oss
import alibabacloud_oss_v2.tables as oss_tables

parser = argparse.ArgumentParser(description="get table sample")
parser.add_argument('--region', help='The region where the Table Bucket is located.', required=True)
parser.add_argument('--endpoint', help='The endpoint to access OSS Tables.')
parser.add_argument('--table-bucket-arn', help='The ARN of the Table Bucket.')
parser.add_argument('--namespace', help='The namespace of the Table.')
parser.add_argument('--name', help='The name of the Table.')
parser.add_argument('--table-arn', help='The ARN of the Table.')

def main():
    args = parser.parse_args()

    credentials_provider = oss.credentials.EnvironmentVariableCredentialsProvider()

    cfg = oss.config.load_default()
    cfg.credentials_provider = credentials_provider
    cfg.region = args.region
    if args.endpoint is not None:
        cfg.endpoint = args.endpoint

    client = oss_tables.Client(cfg)

    result = client.get_table(oss_tables.models.GetTableRequest(
        table_bucket_arn=args.table_bucket_arn,
        namespace=args.namespace,
        name=args.name,
        table_arn=args.table_arn,
    ))

    print(f'status code: {result.status_code},'
          f' request id: {result.request_id},'
          f' name: {result.name},'
          f' table arn: {result.table_arn},'
          f' format: {result.format},'
          f' created by: {result.created_by},'
          f' created at: {result.created_at}')


if __name__ == "__main__":
    main()

Go

The following code provides an example of how to use the Go SDK to retrieve information for a Table:

package main

import (
	"context"
	"flag"
	"log"

	"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss"
	"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss/credentials"
	"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss/tables"
)

var (
	region         string
	tableBucketArn string
	namespace      string
	name           string
	tableArn       string
)

func init() {
	flag.StringVar(&region, "region", "", "The region where the Table Bucket is located.")
	flag.StringVar(&tableBucketArn, "table-bucket-arn", "", "The ARN of the Table Bucket.")
	flag.StringVar(&namespace, "namespace", "", "The namespace of the Table.")
	flag.StringVar(&name, "name", "", "The name of the Table.")
	flag.StringVar(&tableArn, "table-arn", "", "The ARN of the Table.")
}

func main() {
	flag.Parse()

	if len(region) == 0 {
		flag.PrintDefaults()
		log.Fatalf("invalid parameters, region required")
	}

	cfg := oss.LoadDefaultConfig().
		WithCredentialsProvider(credentials.NewEnvironmentVariableCredentialsProvider()).
		WithRegion(region)

	client := tables.NewTablesClient(cfg)

	// Method 1: Query by using the Table Bucket ARN, namespace, and name.
	result, err := client.GetTable(context.TODO(), &tables.GetTableRequest{
		TableBucketARN: oss.Ptr(tableBucketArn),
		Namespace:      oss.Ptr(namespace),
		Name:           oss.Ptr(name),
	})

	// Method 2: Query by using the Table ARN.
	//result, err := client.GetTable(context.TODO(), &tables.GetTableRequest{
	//	TableARN: oss.Ptr(tableArn),
	//})

	if err != nil {
		log.Fatalf("failed to get table %v", err)
	}

	log.Printf("get table result:%#v\n", result)
}

Java

The following code provides an example of how to use the Java SDK to retrieve information for a Table:

import com.aliyun.sdk.service.oss2.credentials.EnvironmentVariableCredentialsProvider;
import com.aliyun.sdk.service.oss2.tables.OSSTablesClient;
import com.aliyun.sdk.service.oss2.tables.models.*;

public class GetTableSample {

    public static void main(String[] args) throws Exception {
        String region = "cn-hangzhou";
        String tableBucketARN = "acs:osstables:cn-hangzhou:1234567890:bucket/mytablebucket";
        String namespace = "mynamespace";
        String tableName = "mytable";

        try (OSSTablesClient client = OSSTablesClient.newBuilder()
                .credentialsProvider(new EnvironmentVariableCredentialsProvider())
                .region(region)
                .build()) {
            // Method 1: Query by using the Table Bucket ARN, namespace, and name.
            GetTableRequest request = GetTableRequest.newBuilder()
                    .tableBucketARN(tableBucketARN)
                    .namespace(namespace)
                    .name(tableName)
                    .build();

            // Method 2: Query by using the Table ARN.
            // GetTableRequest request = GetTableRequest.newBuilder()
            //         .tableARN("acs:osstables:cn-hangzhou:1234567890:bucket/mytablebucket/table/table-id")
            //         .build();

            GetTableResult result = client.getTable(request);

            System.out.printf("Status code:%d, request id:%s%n",
                    result.statusCode(), result.requestId());
            System.out.printf("Table name: %s%n", result.name());
            System.out.printf("Table ARN: %s%n", result.tableARN());
            System.out.printf("Format: %s%n", result.format());
            System.out.printf("Created by: %s%n", result.createdBy());
            System.out.printf("Created at: %s%n", result.createdAt());
        } catch (Exception e) {
            System.out.println("Error: " + e.getMessage());
        }
    }
}

API

Use the GetTable API operation to retrieve detailed information for a Table.

List tables

This operation lists all tables in a specified namespace and supports pagination.

Console

Follow these steps to list tables in the OSS console:

  1. Sign in to the OSS console. In the navigation pane on the left, choose Table bucket list.

  2. Click the name of the target table bucket to view its details page.

  3. On the Table list tab, view all tables across all namespaces in the current table bucket.

Ossutil

The following example shows how to list tables by using ossutil:

ossutil tables-api list-tables \
  --table-bucket-arn acs:osstables:cn-hangzhou:1234567890:bucket/mytablebucket \
  --namespace mynamespace

SDK

Python

The following example shows how to list tables by using the Python SDK:

import argparse
import alibabacloud_oss_v2 as oss
import alibabacloud_oss_v2.tables as oss_tables

parser = argparse.ArgumentParser(description="list tables sample")
parser.add_argument('--region', help='The region of the table bucket.', required=True)
parser.add_argument('--endpoint', help='The domain names that other services can use to access OSS Tables.')
parser.add_argument('--table-bucket-arn', help='The ARN of the table bucket.', required=True)
parser.add_argument('--namespace', help='The namespace of the tables.', required=True)
parser.add_argument('--prefix', help='The prefix to filter tables.')
parser.add_argument('--max-tables', type=int, help='The maximum number of tables to return.')

def main():
    args = parser.parse_args()

    credentials_provider = oss.credentials.EnvironmentVariableCredentialsProvider()

    cfg = oss.config.load_default()
    cfg.credentials_provider = credentials_provider
    cfg.region = args.region
    if args.endpoint is not None:
        cfg.endpoint = args.endpoint

    client = oss_tables.Client(cfg)

    result = client.list_tables(oss_tables.models.ListTablesRequest(
        table_bucket_arn=args.table_bucket_arn,
        namespace=args.namespace,
        prefix=args.prefix,
        max_tables=args.max_tables,
    ))

    print(f'status code: {result.status_code},'
          f' request id: {result.request_id},'
          f' continuation token: {result.continuation_token}')

    if result.table_summaries:
        for i, table in enumerate(result.table_summaries):
            print(f'table {i + 1}:'
                  f' name: {table.name},'
                  f' namespace: {table.namespace},'
                  f' type: {table.type},'
                  f' table arn: {table.table_arn},'
                  f' created at: {table.created_at},'
                  f' modified at: {table.modified_at}')


if __name__ == "__main__":
    main()

Go

The following example shows how to list tables by using the Go SDK:

package main

import (
	"context"
	"flag"
	"log"

	"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss"
	"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss/credentials"
	"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss/tables"
)

var (
	region         string
	tableBucketArn string
	namespace      string
)

func init() {
	flag.StringVar(&region, "region", "", "The region of the table bucket.")
	flag.StringVar(&tableBucketArn, "table-bucket-arn", "", "The ARN of the table bucket.")
	flag.StringVar(&namespace, "namespace", "", "The namespace of the tables.")
}

func main() {
	flag.Parse()
	if len(tableBucketArn) == 0 {
		flag.PrintDefaults()
		log.Fatalf("invalid parameters, table bucket arn required")
	}

	if len(namespace) == 0 {
		flag.PrintDefaults()
		log.Fatalf("invalid parameters, namespace name required")
	}

	if len(region) == 0 {
		flag.PrintDefaults()
		log.Fatalf("invalid parameters, region required")
	}

	cfg := oss.LoadDefaultConfig().
		WithCredentialsProvider(credentials.NewEnvironmentVariableCredentialsProvider()).
		WithRegion(region)

	client := tables.NewTablesClient(cfg)

	p := client.NewListTablesPaginator(&tables.ListTablesRequest{
		TableBucketARN: oss.Ptr(tableBucketArn),
		Namespace:      oss.Ptr(namespace),
	})

	var i int
	log.Println("Tables:")
	for p.HasNext() {
		i++

		page, err := p.NextPage(context.TODO())
		if err != nil {
			log.Fatalf("failed to get page %v, %v", i, err)
		}

		for _, b := range page.Tables {
			log.Printf("Table %v,%v,%v,%v,%v,%v\n", oss.ToString(b.CreatedAt), oss.ToString(b.TableARN), oss.ToString(b.ModifiedAt), oss.ToString(b.Type), oss.ToString(b.Name), b.Namespace)
		}
	}
}

Java

The following example shows how to list tables by using the Java SDK:

import com.aliyun.sdk.service.oss2.credentials.EnvironmentVariableCredentialsProvider;
import com.aliyun.sdk.service.oss2.tables.OSSTablesClient;
import com.aliyun.sdk.service.oss2.tables.models.*;

public class ListTablesSample {

    public static void main(String[] args) throws Exception {
        String region = "cn-hangzhou";
        String tableBucketARN = "acs:osstables:cn-hangzhou:1234567890:bucket/mytablebucket";
        String namespace = "mynamespace";
        int maxTables = 10;

        try (OSSTablesClient client = OSSTablesClient.newBuilder()
                .credentialsProvider(new EnvironmentVariableCredentialsProvider())
                .region(region)
                .build()) {
            ListTablesRequest request = ListTablesRequest.newBuilder()
                    .tableBucketARN(tableBucketARN)
                    .namespace(namespace)
                    .maxTables(maxTables)
                    .build();

            ListTablesResult result = client.listTables(request);

            System.out.printf("Status code:%d, request id:%s%n",
                    result.statusCode(), result.requestId());
            System.out.printf("Continuation token: %s%n", result.continuationToken());

            if (result.tables() != null) {
                System.out.printf("Number of tables: %d%n", result.tables().size());
                for (int i = 0; i < result.tables().size(); i++) {
                    TableSummary table = result.tables().get(i);
                    System.out.printf("Table %d:%n", i + 1);
                    System.out.printf("  Name: %s%n", table.name());
                    System.out.printf("  Namespace: %s%n", table.namespace());
                    System.out.printf("  ARN: %s%n", table.tableARN());
                    System.out.printf("  Type: %s%n", table.type());
                    System.out.printf("  Created at: %s%n", table.createdAt());
                    System.out.printf("  Modified at: %s%n", table.modifiedAt());
                }
            } else {
                System.out.println("No tables found.");
            }
        } catch (Exception e) {
            System.out.println("Error: " + e.getMessage());
        }
    }
}

API

List tables by calling the ListTables operation.

Rename and move a table

Use the RenameTable API operation to perform the following actions:

  • Rename a table: Change the name of a table while keeping it in the same namespace.

  • Move a table: Move a table to a different namespace within the same table bucket.

This operation supports versionToken for optimistic locking to prevent data conflicts from concurrent operations.

ossutil

The following command shows how to rename a table with ossutil:

ossutil tables-api rename-table \
  --table-bucket-arn acs:osstables:cn-hangzhou:1234567890:bucket/mytablebucket \
  --namespace mynamespace \
  --name mytable \
  --new-namespace mynamespace \
  --new-name mytable_renamed

SDK

Python

The following code shows how to rename a table with the Python SDK:

import argparse
import alibabacloud_oss_v2 as oss
import alibabacloud_oss_v2.tables as oss_tables

parser = argparse.ArgumentParser(description="rename table sample")
parser.add_argument('--region', help='The region where the table bucket is located.', required=True)
parser.add_argument('--endpoint', help='The endpoint for accessing OSSTables.')
parser.add_argument('--table-bucket-arn', help='The ARN of the table bucket.', required=True)
parser.add_argument('--namespace', help='The namespace of the table.', required=True)
parser.add_argument('--name', help='The current name of the table.', required=True)
parser.add_argument('--new-namespace-name', help='The new namespace name for the table.')
parser.add_argument('--new-name', help='The new name for the table.')
parser.add_argument('--version-token', help='The version token for the table.')

def main():
    args = parser.parse_args()

    credentials_provider = oss.credentials.EnvironmentVariableCredentialsProvider()

    cfg = oss.config.load_default()
    cfg.credentials_provider = credentials_provider
    cfg.region = args.region
    if args.endpoint is not None:
        cfg.endpoint = args.endpoint

    client = oss_tables.Client(cfg)

    result = client.rename_table(oss_tables.models.RenameTableRequest(
        table_bucket_arn=args.table_bucket_arn,
        namespace=args.namespace,
        name=args.name,
        new_namespace_name=args.new_namespace_name,
        new_name=args.new_name,
        version_token=args.version_token,
    ))

    print(f'status code: {result.status_code},'
          f' request id: {result.request_id}')
    print(f'successfully renamed table: {args.namespace}/{args.name}')


if __name__ == "__main__":
    main()

Go

The following code shows how to rename a table with the Go SDK:

package main

import (
	"context"
	"flag"
	"log"

	"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss"
	"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss/credentials"
	"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss/tables"
)

var (
	region         string
	tableBucketArn string
	namespace      string
	name           string
	newName        string
)

func init() {
	flag.StringVar(&region, "region", "", "The region where the table bucket is located.")
	flag.StringVar(&tableBucketArn, "table-bucket-arn", "", "The ARN of the table bucket.")
	flag.StringVar(&namespace, "namespace", "", "The name of the namespace.")
	flag.StringVar(&name, "name", "", "The name of the table.")
	flag.StringVar(&newName, "new-name", "", "The new name of the table.")
}

func main() {
	flag.Parse()

	if len(tableBucketArn) == 0 {
		flag.PrintDefaults()
		log.Fatalf("invalid parameters, table bucket arn required")
	}

	if len(namespace) == 0 {
		flag.PrintDefaults()
		log.Fatalf("invalid parameters, namespace name required")
	}

	if len(name) == 0 {
		flag.PrintDefaults()
		log.Fatalf("invalid parameters, table name required")
	}

	if len(newName) == 0 {
		flag.PrintDefaults()
		log.Fatalf("invalid parameters, table new name required")
	}

	if len(region) == 0 {
		flag.PrintDefaults()
		log.Fatalf("invalid parameters, region required")
	}

	cfg := oss.LoadDefaultConfig().
		WithCredentialsProvider(credentials.NewEnvironmentVariableCredentialsProvider()).
		WithRegion(region)

	client := tables.NewTablesClient(cfg)

	result, err := client.RenameTable(context.TODO(), &tables.RenameTableRequest{
		TableBucketARN: oss.Ptr(tableBucketArn),
		Namespace:      oss.Ptr(namespace),
		Name:           oss.Ptr(name),
		NewName:        oss.Ptr(newName),
	})

	if err != nil {
		log.Fatalf("failed to rename table %v", err)
	}

	log.Printf("rename table result:%#v\n", result)
}

Java

The following code shows how to rename a table with the Java SDK:

import com.aliyun.sdk.service.oss2.credentials.EnvironmentVariableCredentialsProvider;
import com.aliyun.sdk.service.oss2.tables.OSSTablesClient;
import com.aliyun.sdk.service.oss2.tables.models.*;

public class RenameTableSample {

    public static void main(String[] args) throws Exception {
        String region = "cn-hangzhou";
        String tableBucketARN = "acs:osstables:cn-hangzhou:1234567890:bucket/mytablebucket";
        String namespace = "mynamespace";
        String name = "mytable";
        String newName = "mytable-renamed";

        try (OSSTablesClient client = OSSTablesClient.newBuilder()
                .credentialsProvider(new EnvironmentVariableCredentialsProvider())
                .region(region)
                .build()) {
            RenameTableRequest request = RenameTableRequest.newBuilder()
                    .tableBucketARN(tableBucketARN)
                    .namespace(namespace)
                    .name(name)
                    .newName(newName)
                    .build();

            RenameTableResult result = client.renameTable(request);

            System.out.printf("Status code:%d, request id:%s%n",
                    result.statusCode(), result.requestId());
            System.out.printf("Successfully renamed table from %s/%s to %s/%s%n",
                    namespace, name, namespace, newName);
        } catch (Exception e) {
            System.out.println("Error: " + e.getMessage());
        }
    }
}

API

Use the RenameTable API operation to rename or move a table.

Delete a table

This operation deletes the specified table and permanently removes all data within it. This action is irreversible. Before deleting the table, ensure you have a data backup.

Console

To delete a table in the OSS console, follow these steps:

  1. Sign in to the OSS console. In the navigation pane on the left, choose Table Bucket List.

  2. Click the name of the target Table Bucket to open its details page.

  3. On the Table List tab, find the target table and click Delete in the Actions column.

  4. In the confirmation dialog box, click OK.

Ossutil

Use the following command to delete a table with ossutil:

ossutil tables-api delete-table \
  --table-bucket-arn acs:osstables:cn-hangzhou:1234567890:bucket/mytablebucket \
  --namespace mynamespace \
  --name mytable

SDK

Python

The following code shows how to delete a table with the Python SDK:

# Step 1: Delete a table
# Full sample: delete_table.py
import argparse
import alibabacloud_oss_v2 as oss
import alibabacloud_oss_v2.tables as oss_tables

parser = argparse.ArgumentParser(description="delete table sample")
parser.add_argument('--region', help='The region in which the table bucket is located.', required=True)
parser.add_argument('--endpoint', help='The domain names that other services can use to access OSS Tables.')
parser.add_argument('--table-bucket-arn', help='The ARN of the table bucket.', required=True)
parser.add_argument('--namespace', help='The namespace of the table.', required=True)
parser.add_argument('--name', help='The name of the table.', required=True)
parser.add_argument('--version-token', help='The version token for optimistic locking.')

def main():
    args = parser.parse_args()

    credentials_provider = oss.credentials.EnvironmentVariableCredentialsProvider()

    cfg = oss.config.load_default()
    cfg.credentials_provider = credentials_provider
    cfg.region = args.region
    if args.endpoint is not None:
        cfg.endpoint = args.endpoint

    client = oss_tables.Client(cfg)

    result = client.delete_table(oss_tables.models.DeleteTableRequest(
        table_bucket_arn=args.table_bucket_arn,
        namespace=args.namespace,
        name=args.name,
        version_token=args.version_token,
    ))

    print(f'status code: {result.status_code},'
          f' request id: {result.request_id}')
    print(f'successfully deleted table: {args.namespace}/{args.name}')


if __name__ == "__main__":
    main()

# ----------------------------------------------------------------
# Step 2: Delete a namespace (To delete a namespace, you must first delete all tables within it.)
# Full sample: delete_namespace.py
import argparse
import alibabacloud_oss_v2 as oss
import alibabacloud_oss_v2.tables as oss_tables

parser = argparse.ArgumentParser(description="delete namespace sample")
parser.add_argument('--region', help='The region in which the table bucket is located.', required=True)
parser.add_argument('--endpoint', help='The domain names that other services can use to access OSS Tables.')
parser.add_argument('--table-bucket-arn', help='The ARN of the table bucket.', required=True)
parser.add_argument('--namespace', help='The namespace to delete.', required=True)

def main():
    args = parser.parse_args()

    credentials_provider = oss.credentials.EnvironmentVariableCredentialsProvider()

    cfg = oss.config.load_default()
    cfg.credentials_provider = credentials_provider
    cfg.region = args.region
    if args.endpoint is not None:
        cfg.endpoint = args.endpoint

    client = oss_tables.Client(cfg)

    result = client.delete_namespace(oss_tables.models.DeleteNamespaceRequest(
        table_bucket_arn=args.table_bucket_arn,
        namespace=args.namespace,
    ))

    print(f'status code: {result.status_code},'
          f' request id: {result.request_id}')
    print(f'successfully deleted namespace: {args.namespace}')


if __name__ == "__main__":
    main()

Go

The following code shows how to delete a table with the Go SDK:

// Step 1: Delete a table
// Full sample: delete_table.go
package main

import (
	"context"
	"flag"
	"log"

	"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss"
	"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss/credentials"
	"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss/tables"
)

var (
	region         string
	tableBucketArn string
	namespace      string
	name           string
)

func init() {
	flag.StringVar(&region, "region", "", "The region in which the bucket is located.")
	flag.StringVar(&tableBucketArn, "table-bucket-arn", "", "The ARN of the table bucket.")
	flag.StringVar(&namespace, "namespace", "", "The name of the namespace.")
	flag.StringVar(&name, "name", "", "The name of the table.")
}

func main() {
	flag.Parse()

	if len(tableBucketArn) == 0 {
		flag.PrintDefaults()
		log.Fatalf("invalid parameters, table bucket arn required")
	}

	if len(namespace) == 0 {
		flag.PrintDefaults()
		log.Fatalf("invalid parameters, namespace name required")
	}

	if len(name) == 0 {
		flag.PrintDefaults()
		log.Fatalf("invalid parameters, table name required")
	}

	if len(region) == 0 {
		flag.PrintDefaults()
		log.Fatalf("invalid parameters, region required")
	}

	cfg := oss.LoadDefaultConfig().
		WithCredentialsProvider(credentials.NewEnvironmentVariableCredentialsProvider()).
		WithRegion(region)

	client := tables.NewTablesClient(cfg)

	result, err := client.DeleteTable(context.TODO(), &tables.DeleteTableRequest{
		TableBucketARN: oss.Ptr(tableBucketArn),
		Namespace:      oss.Ptr(namespace),
		Name:           oss.Ptr(name),
	})

	if err != nil {
		log.Fatalf("failed to delete table %v", err)
	}

	log.Printf("delete table result:%#v\n", result)
}

// ----------------------------------------------------------------
// Step 2: Delete a namespace (To delete a namespace, you must first delete all tables within it.)
// Full sample: delete_namespace.go
package main

import (
	"context"
	"flag"
	"log"

	"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss"
	"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss/credentials"
	"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss/tables"
)

var (
	region         string
	tableBucketArn string
)

func init() {
	flag.StringVar(&region, "region", "", "The region in which the bucket is located.")
	flag.StringVar(&tableBucketArn, "table-bucket-arn", "", "The ARN of the table bucket.")
}

func main() {
	flag.Parse()
	if len(tableBucketArn) == 0 {
		flag.PrintDefaults()
		log.Fatalf("invalid parameters, table bucket arn required")
	}

	if len(region) == 0 {
		flag.PrintDefaults()
		log.Fatalf("invalid parameters, region required")
	}

	cfg := oss.LoadDefaultConfig().
		WithCredentialsProvider(credentials.NewEnvironmentVariableCredentialsProvider()).
		WithRegion(region)

	client := tables.NewTablesClient(cfg)

	result, err := client.DeleteNamespace(context.TODO(), &tables.DeleteNamespaceRequest{
		TableBucketARN: oss.Ptr(tableBucketArn),
		Namespace:      oss.Ptr("my_space"),
	})

	if err != nil {
		log.Fatalf("failed to delete namespace %v", err)
	}

	log.Printf("delete namespace result:%#v\n", result)
}

Java

The following code shows how to delete a table with the Java SDK:

import com.aliyun.sdk.service.oss2.credentials.EnvironmentVariableCredentialsProvider;
import com.aliyun.sdk.service.oss2.tables.OSSTablesClient;
import com.aliyun.sdk.service.oss2.tables.models.*;

public class DeleteTableSample {

    public static void main(String[] args) throws Exception {
        String region = "cn-hangzhou";
        String tableBucketARN = "acs:osstables:cn-hangzhou:1234567890:bucket/mytablebucket";
        String namespace = "mynamespace";
        String tableName = "mytable";

        try (OSSTablesClient client = OSSTablesClient.newBuilder()
                .credentialsProvider(new EnvironmentVariableCredentialsProvider())
                .region(region)
                .build()) {
            DeleteTableRequest request = DeleteTableRequest.newBuilder()
                    .tableBucketARN(tableBucketARN)
                    .namespace(namespace)
                    .name(tableName)
                    .build();

            DeleteTableResult result = client.deleteTable(request);

            System.out.printf("Status code: %d, request id: %s%n",
                    result.statusCode(), result.requestId());
            System.out.printf("Successfully deleted table: %s/%s from bucket: %s%n",
                    namespace, tableName, tableBucketARN);
        } catch (Exception e) {
            System.out.println("Error: " + e.getMessage());
        }
    }
}

API

Use the DeleteTable API to delete a table.

Metadata management

The Iceberg metadata file for a table contains essential information, such as the table's schema, snapshot history, and partition spec. Metadata management involves the following two key properties:

  • metadataLocation: The storage path for the metadata file. After each Iceberg commit, the system generates a new metadata file. The path is in the format oss://{tableId}--table-oss/metadata/00000-{uuid}.metadata.json.

  • versionToken: Identifies the metadata version. This token changes after each metadata update. When performing UpdateTableMetadataLocation or RenameTable operations, you must include the current version token to implement an optimistic lock.

ossutil

Retrieve the metadata location:

ossutil tables-api get-table-metadata-location --table-bucket-arn {ARN} --namespace {ns} --name {table}

Update the metadata location:

ossutil tables-api update-table-metadata-location --table-bucket-arn {ARN} --namespace {ns} --name {table} --metadata-location {location} --version-token {token}

SDK

Python

Retrieve the metadata location:

import argparse
import alibabacloud_oss_v2 as oss
import alibabacloud_oss_v2.tables as oss_tables

parser = argparse.ArgumentParser(description="get table metadata location sample")
parser.add_argument('--region', help='The region where the table bucket is located.', required=True)
parser.add_argument('--endpoint', help='The endpoint for accessing OSS Tables.')
parser.add_argument('--table-bucket-arn', help='The ARN of the table bucket.', required=True)
parser.add_argument('--namespace', help='The table namespace.', required=True)
parser.add_argument('--name', help='The table name.', required=True)

def main():
    args = parser.parse_args()

    credentials_provider = oss.credentials.EnvironmentVariableCredentialsProvider()

    cfg = oss.config.load_default()
    cfg.credentials_provider = credentials_provider
    cfg.region = args.region
    if args.endpoint is not None:
        cfg.endpoint = args.endpoint

    client = oss_tables.Client(cfg)

    result = client.get_table_metadata_location(
        oss_tables.models.GetTableMetadataLocationRequest(
            table_bucket_arn=args.table_bucket_arn,
            namespace=args.namespace,
            name=args.name,
        )
    )

    print(f'status code: {result.status_code},'
          f' request id: {result.request_id},'
          f' version token: {result.version_token},'
          f' metadata location: {result.metadata_location},'
          f' warehouse location: {result.warehouse_location}')


if __name__ == "__main__":
    main()

Update the metadata location:

import argparse
import alibabacloud_oss_v2 as oss
import alibabacloud_oss_v2.tables as oss_tables

parser = argparse.ArgumentParser(description="update table metadata location sample")
parser.add_argument('--region', help='The region where the table bucket is located.', required=True)
parser.add_argument('--endpoint', help='The endpoint for accessing OSS Tables.')
parser.add_argument('--table-bucket-arn', help='The ARN of the table bucket.', required=True)
parser.add_argument('--namespace', help='The table namespace.', required=True)
parser.add_argument('--name', help='The table name.', required=True)
parser.add_argument('--version-token', help='The version token.', required=True)
parser.add_argument('--metadata-location', help='The new metadata location.', required=True)

def main():
    args = parser.parse_args()

    credentials_provider = oss.credentials.EnvironmentVariableCredentialsProvider()

    cfg = oss.config.load_default()
    cfg.credentials_provider = credentials_provider
    cfg.region = args.region
    if args.endpoint is not None:
        cfg.endpoint = args.endpoint

    client = oss_tables.Client(cfg)

    result = client.update_table_metadata_location(
        oss_tables.models.UpdateTableMetadataLocationRequest(
            table_bucket_arn=args.table_bucket_arn,
            namespace=args.namespace,
            name=args.name,
            version_token=args.version_token,
            metadata_location=args.metadata_location,
        )
    )

    print(f'status code: {result.status_code},'
          f' request id: {result.request_id},'
          f' name: {result.name},'
          f' version token: {result.version_token},'
          f' metadata location: {result.metadata_location},'
          f' table arn: {result.table_arn}')


if __name__ == "__main__":
    main()

Go

Retrieve the metadata location:

package main

import (
	"context"
	"flag"
	"log"

	"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss"
	"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss/credentials"
	"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss/tables"
)

var (
	region         string
	tableBucketArn string
	namespace      string
	name           string
)

func init() {
	flag.StringVar(&region, "region", "", "The region where the bucket is located.")
	flag.StringVar(&tableBucketArn, "table-bucket-arn", "", "The ARN of the table bucket.")
	flag.StringVar(&namespace, "namespace", "", "The table namespace.")
	flag.StringVar(&name, "name", "", "The table name.")
}

func main() {
	flag.Parse()

	if len(region) == 0 {
		flag.PrintDefaults()
		log.Fatalf("invalid parameters, region required")
	}

	if len(tableBucketArn) == 0 {
		flag.PrintDefaults()
		log.Fatalf("invalid parameters, table bucket arn required")
	}

	if len(namespace) == 0 {
		flag.PrintDefaults()
		log.Fatalf("invalid parameters, namespace name required")
	}

	if len(name) == 0 {
		flag.PrintDefaults()
		log.Fatalf("invalid parameters, table name required")
	}

	cfg := oss.LoadDefaultConfig().
		WithCredentialsProvider(credentials.NewEnvironmentVariableCredentialsProvider()).
		WithRegion(region)

	client := tables.NewTablesClient(cfg)

	result, err := client.GetTableMetadataLocation(context.TODO(), &tables.GetTableMetadataLocationRequest{
		TableBucketARN: oss.Ptr(tableBucketArn),
		Namespace:      oss.Ptr(namespace),
		Name:           oss.Ptr(name),
	})

	if err != nil {
		log.Fatalf("failed to get table metadata location %v", err)
	}

	log.Printf("get table metadata location result:%#v\n", result)
}

Update the metadata location:

package main

import (
	"context"
	"flag"
	"log"

	"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss"
	"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss/credentials"
	"github.com/aliyun/alibabacloud-oss-go-sdk-v2/oss/tables"
)

var (
	region           string
	tableBucketArn   string
	namespace        string
	name             string
	metadataLocation string
	versionToken     string
)

func init() {
	flag.StringVar(&region, "region", "", "The region where the bucket is located.")
	flag.StringVar(&tableBucketArn, "table-bucket-arn", "", "The ARN of the table bucket.")
	flag.StringVar(&namespace, "namespace", "", "The table namespace.")
	flag.StringVar(&name, "name", "", "The table name.")
	flag.StringVar(&metadataLocation, "metadata-location", "", "The table's metadata location.")
	flag.StringVar(&versionToken, "version-token", "", "The table's version token.")
}

func main() {
	flag.Parse()

	if len(region) == 0 {
		flag.PrintDefaults()
		log.Fatalf("invalid parameters, region required")
	}

	if len(tableBucketArn) == 0 {
		flag.PrintDefaults()
		log.Fatalf("invalid parameters, table bucket arn required")
	}

	if len(namespace) == 0 {
		flag.PrintDefaults()
		log.Fatalf("invalid parameters, namespace name required")
	}

	if len(name) == 0 {
		flag.PrintDefaults()
		log.Fatalf("invalid parameters, table name required")
	}

	if len(metadataLocation) == 0 {
		flag.PrintDefaults()
		log.Fatalf("invalid parameters, table metadata location required")
	}

	if len(versionToken) == 0 {
		flag.PrintDefaults()
		log.Fatalf("invalid parameters, table version token required")
	}

	cfg := oss.LoadDefaultConfig().
		WithCredentialsProvider(credentials.NewEnvironmentVariableCredentialsProvider()).
		WithRegion(region)

	client := tables.NewTablesClient(cfg)

	result, err := client.UpdateTableMetadataLocation(context.TODO(), &tables.UpdateTableMetadataLocationRequest{
		TableBucketARN:   oss.Ptr(tableBucketArn),
		Namespace:        oss.Ptr(namespace),
		Name:             oss.Ptr(name),
		MetadataLocation: oss.Ptr(metadataLocation),
		VersionToken:     oss.Ptr(versionToken),
	})

	if err != nil {
		log.Fatalf("failed to update table metadata location %v", err)
	}

	log.Printf("update table metadata location result:%#v\n", result)
}

Java

Retrieve the metadata location:

import com.aliyun.sdk.service.oss2.credentials.EnvironmentVariableCredentialsProvider;
import com.aliyun.sdk.service.oss2.tables.OSSTablesClient;
import com.aliyun.sdk.service.oss2.tables.models.*;

public class GetTableMetadataLocationSample {

    public static void main(String[] args) throws Exception {
        String region = "cn-hangzhou";
        String tableBucketARN = "acs:osstables:cn-hangzhou:1234567890:bucket/mytablebucket";
        String namespace = "mynamespace";
        String name = "mytable";

        try (OSSTablesClient client = OSSTablesClient.newBuilder()
                .credentialsProvider(new EnvironmentVariableCredentialsProvider())
                .region(region)
                .build()) {
            GetTableMetadataLocationRequest request = GetTableMetadataLocationRequest.newBuilder()
                    .tableBucketARN(tableBucketARN)
                    .namespace(namespace)
                    .name(name)
                    .build();

            GetTableMetadataLocationResult result = client.getTableMetadataLocation(request);

            System.out.printf("Status code:%d, request id:%s%n",
                    result.statusCode(), result.requestId());
            System.out.printf("Metadata location: %s%n", result.metadataLocation());
            System.out.printf("Version token: %s%n", result.versionToken());
            System.out.printf("Warehouse location: %s%n", result.warehouseLocation());
        } catch (Exception e) {
            System.out.println("Error: " + e.getMessage());
        }
    }
}

Update the metadata location:

import com.aliyun.sdk.service.oss2.credentials.EnvironmentVariableCredentialsProvider;
import com.aliyun.sdk.service.oss2.tables.OSSTablesClient;
import com.aliyun.sdk.service.oss2.tables.models.*;

public class UpdateTableMetadataLocationSample {

    public static void main(String[] args) throws Exception {
        String region = "cn-hangzhou";
        String tableBucketARN = "acs:osstables:cn-hangzhou:1234567890:bucket/mytablebucket";
        String namespace = "mynamespace";
        String name = "mytable";
        String versionToken = "your-version-token";
        String metadataLocation = "oss://warehouse/metadata/v1.metadata.json";

        try (OSSTablesClient client = OSSTablesClient.newBuilder()
                .credentialsProvider(new EnvironmentVariableCredentialsProvider())
                .region(region)
                .build()) {
            UpdateTableMetadataLocationRequest request = UpdateTableMetadataLocationRequest.newBuilder()
                    .tableBucketARN(tableBucketARN)
                    .namespace(namespace)
                    .name(name)
                    .versionToken(versionToken)
                    .metadataLocation(metadataLocation)
                    .build();

            UpdateTableMetadataLocationResult result = client.updateTableMetadataLocation(request);

            System.out.printf("Status code:%d, request id:%s%n",
                    result.statusCode(), result.requestId());
            System.out.printf("Successfully updated table metadata location for table: %s%n", name);
            System.out.printf("New metadata location: %s%n", result.metadataLocation());
            System.out.printf("New version token: %s%n", result.versionToken());
        } catch (Exception e) {
            System.out.println("Error: " + e.getMessage());
        }
    }
}

API

Quotas and limits

Item

Description

Number of tables per table bucket

Up to 10,000. If you need a higher quota, contact Technical Support.

Number of namespaces per table bucket

Up to 10,000.

Number of table buckets

Each account can create up to 10 table buckets in each region.

Table bucket name length

3 to 32 characters.

Table name length

1 to 255 characters.

Valid characters for table bucket names

Must contain only lowercase letters, digits, and hyphens (-), and must not start or end with a hyphen.

Disallowed prefixes for table bucket names

Must not start with oss, acs, aliyun, alibaba, or aws.

Valid characters for table names

Must contain only lowercase letters, digits, and underscores (_), and must not start or end with an underscore.

Namespace name length

1 to 255 characters.

Valid characters for namespace names

Must contain only lowercase letters, digits, and underscores (_), and must not start or end with an underscore.

Encryption algorithm

Only AES256 is supported.

Table format

Only Iceberg is supported.

Billing

OSS Tables is available at no charge during its invitation-only test. Please check the official website for announcements about the commercial launch.