All Products
Search
Document Center

Object Storage Service:Data maintenance

Last Updated:Jun 02, 2026

OSS Tables automatically runs compaction, snapshot management, and unreferenced file cleanup to optimize query performance and reduce storage costs. No external compute resources are required.

Automatic maintenance runs three tasks at different resource levels:

  • Unreferenced file cleanup: Configured at the bucket level. Automatically identifies and deletes objects that are no longer referenced by any table snapshot.

  • Compaction: Configured at the table level. Merges small files into larger files to improve query performance.

  • Snapshot management: Configured at the table level. Automatically cleans up expired snapshots to reduce metadata files and storage overhead.

The following defaults apply when you create a bucket or table.

Maintenance feature

Configuration level

Parameter

Default

Unreferenced file cleanup

bucket level

status

enabled

unreferencedDays

3

nonCurrentDays

10

Compaction

table level

status

enabled

targetFileSizeMB

512

strategy

auto

Snapshot management

table level

status

enabled

maxSnapshotAgeHours

120

minSnapshotsToKeep

1

Service-linked role

A background service runs automatic maintenance (compaction, unreferenced file cleanup, and snapshot management) for OSS Tables. It uses the service-linked role AliyunServiceRoleForOssTableMaintenance to access Table Buckets.

Authorization

When you first open the Table Buckets page in the OSS console, a notification appears if the service-linked role has not been created: Missing permissions: AliyunServiceRoleForOssTableMaintenance. Click Create Now to create the role. The background maintenance service starts automatically after the role is created.

Note

If you are a RAM user, ensure you have the permission to create service-linked roles. Attach the following policy to the RAM user:

{
  "Version": "1",
  "Statement": [
    {
      "Action": "ram:CreateServiceLinkedRole",
      "Resource": "*",
      "Effect": "Allow",
      "Condition": {
        "StringEquals": {
          "ram:ServiceName": "tablemaintenance.oss.aliyuncs.com"
        }
      }
    }
  ]
}

Permissions

The permission policy (AliyunServiceRolePolicyForOssTableMaintenance) grants the following permissions:

Action

Description

oss:GetTableBucketMaintenanceConfiguration

Read bucket-level maintenance configurations

oss:GetTableMaintenanceConfiguration

Read table-level maintenance configurations

oss:ListTableBuckets

List Table Buckets

oss:GetTableBucket

Get Table Bucket information

oss:ListTables

List tables

oss:GetTable

Get table information

oss:GetTableData

Read table data files (to perform compaction and cleanup)

oss:PutTableData

Write table data files (to generate new files after compaction)

oss:GetTableMetadataLocation

Get the location of the metadata file

oss:UpdateTableMetadataLocation

Update metadata file location (to commit changes after maintenance)

Unreferenced file cleanup

Unreferenced file cleanup is a bucket-level optimization that applies to all tables in a Table Bucket. It deletes data files (Parquet, Avro, or ORC) no longer referenced by any table snapshot. Such orphaned files can accumulate from failed write jobs or expired snapshots and consume unnecessary storage.

Important

When enabled, unreferenced file cleanup also deletes Parquet, Avro, or ORC files in the Table Bucket that are not part of any table.

Cleanup uses a two-stage process: files are first marked as non-current (controlled by unreferencedDays), then deleted after remaining non-current for the specified period (controlled by nonCurrentDays).

Configuration parameters:

Parameter

Description

Value

Default

status

Enable or disable unreferenced file cleanup.

enabled or disabled.

enabled

unreferencedDays

Days before marking an unreferenced file as non-current.

1 to 2147483647.

3

nonCurrentDays

Days before deleting a non-current file.

1 to 2147483647.

10

Console

View and modify the maintenance configuration for a Table Bucket in the OSS console.

Follow these steps:

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

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

  3. Choose the Data Maintenance tab.

  4. In the Unreferenced File Cleanup section, view the current configuration:

    • Status: Whether the feature is enabled.

    • Unreferenced Days: Days before marking an unreferenced file as non-current. Default: 3.

    • Non-current Days: Days before deleting a non-current file. Default: 10.

  5. Click Edit, modify the parameters for unreferenced file cleanup, and then click Save.

ossutil

Use ossutil to modify the unreferenced file cleanup configuration:

ossutil tables-api put-table-bucket-maintenance-configuration \
  --table-bucket-arn {ARN} \
  --type icebergUnreferencedFileRemoval \
  --value '{"status":"enabled","settings":{"icebergUnreferencedFileRemoval":{"unreferencedDays":5,"nonCurrentDays":15}}}'

SDK

Query and modify the unreferenced file cleanup configuration using an SDK.

Python

Query the unreferenced file cleanup configuration:

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

parser = argparse.ArgumentParser(description="get table bucket maintenance configuration 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_maintenance_configuration(
        oss_tables.models.GetTableBucketMaintenanceConfigurationRequest(
            table_bucket_arn=args.table_bucket_arn,
        )
    )

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


if __name__ == "__main__":
    main()

Modify the unreferenced file cleanup configuration:

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

parser = argparse.ArgumentParser(description="put table bucket maintenance configuration 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('--type', help='The maintenance type, e.g., icebergUnreferencedFileRemoval.', 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)

    value = {
        'status': 'enabled',
        'settings': {
            'icebergUnreferencedFileRemoval': {
                'unreferencedDays': 7,
                'nonCurrentDays': 30
            }
        }
    }

    result = client.put_table_bucket_maintenance_configuration(
        oss_tables.models.PutTableBucketMaintenanceConfigurationRequest(
            table_bucket_arn=args.table_bucket_arn,
            type=args.type,
            value=value,
        )
    )

    print(f'status code: {result.status_code},'
          f' request id: {result.request_id}')
    print(f'successfully updated maintenance configuration for: {args.table_bucket_arn}')


if __name__ == "__main__":
    main()

Go

Query the unreferenced file cleanup configuration:

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.GetTableBucketMaintenanceConfiguration(context.TODO(), &tables.GetTableBucketMaintenanceConfigurationRequest{
		TableBucketARN: oss.Ptr(tableBucketArn),
	})

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

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

Modify the unreferenced file cleanup configuration:

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.PutTableBucketMaintenanceConfiguration(context.TODO(), &tables.PutTableBucketMaintenanceConfigurationRequest{
		TableBucketARN: oss.Ptr(tableBucketArn),
		Type:           oss.Ptr("icebergUnreferencedFileRemoval"),
		Value: &tables.MaintenanceValue{
			Settings: &tables.MaintenanceSettings{
				IcebergUnreferencedFileRemoval: &tables.SettingsDetail{
					UnreferencedDays: oss.Ptr(4),
					NonCurrentDays:   oss.Ptr(10),
				},
			},
			Status: oss.Ptr("enabled"),
		},
	})

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

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

Java

Query the unreferenced file cleanup configuration:

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 GetTableBucketMaintenanceConfigurationSample {

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

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

            GetTableBucketMaintenanceConfigurationResult result = client.getTableBucketMaintenanceConfiguration(request);

            System.out.printf("Status code:%d, request id:%s%n",
                    result.statusCode(), result.requestId());
            System.out.printf("Successfully got maintenance configuration for table bucket: %s%n", tableBucketARN);
            System.out.printf("Table Bucket ARN: %s%n", result.tableBucketARN());

            result.configuration().forEach((key, value) -> {
                System.out.printf("Configuration Type: %s, Status: %s%n", key, value.status());
            });
        } catch (Exception e) {
            System.out.println("Error: " + e.getMessage());
        }
    }
}

Modify the unreferenced file cleanup configuration:

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 PutTableBucketMaintenanceConfigurationSample {

    public static void main(String[] args) throws Exception {
        String region = "cn-hangzhou";
        String tableBucketARN = "acs:osstables:cn-hangzhou:1234567890:bucket/mytable-bucket";
        String type = "icebergUnreferencedFileRemoval";
        String status = "enabled";
        int unreferencedDays = 3;
        int nonCurrentDays = 3;

        IcebergUnreferencedFileRemovalSettings removalSettings = IcebergUnreferencedFileRemovalSettings.newBuilder()
                .unreferencedDays(unreferencedDays)
                .nonCurrentDays(nonCurrentDays)
                .build();

        TableBucketMaintenanceSettings settings = TableBucketMaintenanceSettings.newBuilder()
                .icebergUnreferencedFileRemoval(removalSettings)
                .build();

        TableBucketMaintenanceConfigurationValue value = TableBucketMaintenanceConfigurationValue.newBuilder()
                .status(status)
                .settings(settings)
                .build();

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

            PutTableBucketMaintenanceConfigurationResult result = client.putTableBucketMaintenanceConfiguration(request);

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

API

Use the following API operations:

Compaction

Compaction is a table-level optimization. Frequent streaming or small-batch writes to Apache Iceberg tables can produce many small files, which degrades query performance. Compaction merges small files into larger files that approach a target size, reducing file count and metadata overhead.

Configuration parameters:

Parameter

Description

Value

Default

status

Enable or disable automatic compaction.

enabled or disabled

enabled

targetFileSizeMB

Target file size (MB) after compaction. Files smaller than this value are merged.

1 to 2147483647.

512

strategy

Compaction strategy that determines how files are merged and sorted.

auto, binpack, sort, or z-order. If you set this parameter to sort or z-order, a sort order must be defined in the table's metadata.

auto

Available strategies:

  • auto: The system automatically selects the optimal compaction strategy. It applies the sort strategy to tables with a defined sort order and the binpack strategy to tables without one.

  • binpack: Merges files based only on file size without changing the data order. This is the fastest strategy and is suitable when data sorting is not required.

  • sort: Sorts and merges data based on the sort order defined in the table. This strategy is suitable for range query scenarios. A sort order must be defined in the table's metadata.

  • z-order: Uses a Z-Order curve to sort and merge data across multiple columns simultaneously. This strategy is suitable for multi-dimensional query scenarios. A sort order must be defined in the table's metadata.

View and configure compaction:

Console

View and modify compaction settings on the Data Maintenance tab.

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

  2. Click the name of the target Table Bucket. In the Table list, click the name of the target table to open the Table details page.

  3. Select the Data Maintenance tab.

  4. In the Compaction section, view the current configuration:

    • Status: Whether automatic compaction is enabled.

    • Target file size: Target size for each file after compaction. Default: 512 MB.

    • Compaction strategy: Active compaction strategy. Default: auto.

    • Job status: Status and timestamp of the last compaction job.

  5. Click Edit, modify the compaction parameters, and then click Save.

ossutil

Use ossutil to modify the compaction configuration:

ossutil tables-api put-table-maintenance-configuration \
  --table-bucket-arn {ARN} \
  --namespace mynamespace \
  --name mytable \
  --type icebergCompaction \
  --value '{"status":"enabled","settings":{"icebergCompaction":{"targetFileSizeMB":256,"strategy":"binpack"}}}'

SDK

Query and modify compaction configuration using an SDK.

Python

Query the compaction configuration:

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

parser = argparse.ArgumentParser(description="get table maintenance configuration 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)

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_maintenance_configuration(
        oss_tables.models.GetTableMaintenanceConfigurationRequest(
            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' table arn: {result.table_arn},'
          f' configuration: {result.configuration}')


if __name__ == "__main__":
    main()

Modify the compaction configuration:

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

parser = argparse.ArgumentParser(description="put table maintenance configuration 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('--type', help='The maintenance type, e.g., icebergCompaction.', 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)

    value = {
        'status': 'enabled',
        'settings': {
            'icebergCompaction': {
                'targetFileSizeMB': 512,
                'strategy': 'auto'
            }
        }
    }

    result = client.put_table_maintenance_configuration(
        oss_tables.models.PutTableMaintenanceConfigurationRequest(
            table_bucket_arn=args.table_bucket_arn,
            namespace=args.namespace,
            name=args.name,
            type=args.type,
            value=value,
        )
    )

    print(f'status code: {result.status_code},'
          f' request id: {result.request_id}')
    print(f'successfully updated maintenance configuration for: {args.namespace}/{args.name}')


if __name__ == "__main__":
    main()

Go

Query the compaction configuration:

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(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.GetTableMaintenanceConfiguration(context.TODO(), &tables.GetTableMaintenanceConfigurationRequest{
		TableBucketARN: oss.Ptr(tableBucketArn),
		Namespace:      oss.Ptr(namespace),
		Name:           oss.Ptr(name),
	})

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

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

Modify the compaction configuration:

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(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)

	// icebergCompaction type
	result, err := client.PutTableMaintenanceConfiguration(context.TODO(), &tables.PutTableMaintenanceConfigurationRequest{
		TableBucketARN: oss.Ptr(tableBucketArn),
		Namespace:      oss.Ptr(namespace),
		Name:           oss.Ptr(name),
		Type:           oss.Ptr("icebergCompaction"),
		Value: &tables.TableMaintenanceValue{
			Status: oss.Ptr("enabled"),
			Settings: &tables.TableMaintenanceSettings{
				IcebergCompaction: &tables.IcebergCompactionSettingsDetail{
					TargetFileSizeMB: oss.Ptr(400),
					Strategy:         oss.Ptr("auto"),
				},
			},
		},
	})

	// icebergSnapshotManagement type
	//result, err := client.PutTableMaintenanceConfiguration(context.TODO(), &tables.PutTableMaintenanceConfigurationRequest{
	//	TableBucketARN: oss.Ptr(tableBucketArn),
	//	Namespace:      oss.Ptr(namespace),
	//	Name:           oss.Ptr(name),
	//	Type:           oss.Ptr("icebergSnapshotManagement"),
	//	Value: &tables.TableMaintenanceValue{
	//		Status: oss.Ptr("enabled"),
	//		Settings: &tables.TableMaintenanceSettings{
	//			IcebergSnapshotManagement: &tables.IcebergSnapshotManagementSettingsDetail{
	//				MaxSnapshotAgeHours: oss.Ptr(350),
	//				MinSnapshotsToKeep:  oss.Ptr(1),
	//			},
	//		},
	//	},
	//})

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

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

Java

Query the compaction configuration:

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 GetTableMaintenanceConfigurationSample {

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

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

            GetTableMaintenanceConfigurationResult result = client.getTableMaintenanceConfiguration(request);

            System.out.printf("Status code:%d, request id:%s%n",
                    result.statusCode(), result.requestId());
            System.out.printf("Table ARN: %s%n", result.tableARN());

            if (result.configuration() != null && !result.configuration().isEmpty()) {
                System.out.println("Maintenance configurations:");
                result.configuration().forEach((type, config) -> {
                    System.out.printf("  Type: %s, Status: %s%n", type, config.status());
                    if (config.settings() != null) {
                        if (config.settings().icebergCompaction() != null) {
                            System.out.printf("    Compaction - TargetFileSizeMB: %d, Strategy: %s%n",
                                    config.settings().icebergCompaction().targetFileSizeMB(),
                                    config.settings().icebergCompaction().strategy());
                        }
                        if (config.settings().icebergSnapshotManagement() != null) {
                            System.out.printf("    SnapshotManagement - MinSnapshotsToKeep: %d, MaxSnapshotAgeHours: %d%n",
                                    config.settings().icebergSnapshotManagement().minSnapshotsToKeep(),
                                    config.settings().icebergSnapshotManagement().maxSnapshotAgeHours());
                        }
                    }
                });
            } else {
                System.out.println("No maintenance configuration found.");
            }
        } catch (Exception e) {
            System.out.println("Error: " + e.getMessage());
        }
    }
}

Modify the compaction configuration:

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 PutTableMaintenanceConfigurationSample {

    public static void main(String[] args) throws Exception {
        String region = "cn-hangzhou";
        String tableBucketARN = "acs:osstables:cn-hangzhou:1234567890:bucket/mytable-bucket";
        String namespace = "mynamespace";
        String name = "mytable";
        String type = "icebergCompaction";
        String status = "enabled";
        int targetFileSizeMB = 256;
        String strategy = "auto";

        try (OSSTablesClient client = OSSTablesClient.newBuilder()
                .credentialsProvider(new EnvironmentVariableCredentialsProvider())
                .region(region)
                .build()) {
            IcebergCompactionSettings compactionSettings = IcebergCompactionSettings.newBuilder()
                    .targetFileSizeMB(targetFileSizeMB)
                    .strategy(strategy)
                    .build();
            TableMaintenanceSettings settings = TableMaintenanceSettings.newBuilder()
                    .icebergCompaction(compactionSettings)
                    .build();

            TableMaintenanceConfigurationValue value = TableMaintenanceConfigurationValue.newBuilder()
                    .status(status)
                    .settings(settings)
                    .build();

            PutTableMaintenanceConfigurationRequest request = PutTableMaintenanceConfigurationRequest.newBuilder()
                    .tableBucketARN(tableBucketARN)
                    .namespace(namespace)
                    .name(name)
                    .type(type)
                    .value(value)
                    .build();

            PutTableMaintenanceConfigurationResult result = client.putTableMaintenanceConfiguration(request);

            System.out.printf("Status code:%d, request id:%s%n",
                    result.statusCode(), result.requestId());
            System.out.printf("Successfully put table maintenance configuration for table: %s/%s, type: %s%n", namespace, name, type);
        } catch (Exception e) {
            System.out.println("Error: " + e.getMessage());
        }
    }
}

API

API operations:

Snapshot management

Snapshot management is a table-level optimization. Each write to an Apache Iceberg table creates a snapshot. Over time, accumulated snapshots consume storage and increase metadata overhead. Snapshot management automatically cleans up expired snapshots to reduce costs while preserving data safety.

When minSnapshotsToKeep and maxSnapshotAgeHours conflict, the system prioritizes retaining the minimum number of snapshots to preserve data recovery capabilities.

Configuration parameters:

Parameter

Description

Value

Default

status

Enable or disable snapshot management.

enabled or disabled.

enabled

maxSnapshotAgeHours

Maximum snapshot retention period (hours). Older snapshots are deleted.

1~2147483647.

120

minSnapshotsToKeep

Minimum snapshots to retain, even if they exceed the maximum age.

1~2147483647.

1

View and configure snapshot management:

Console

View and modify snapshot management settings on the Data Maintenance tab.

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

  2. Click the name of the target Table Bucket. In the Table List, click the name of the target table.

  3. Select the Data Maintenance tab.

  4. In the Snapshot Management section, view the current configuration:

    • Status: Whether snapshot management is enabled.

    • Maximum Snapshot Retention Time: Maximum retention period for snapshots. Default: 120 hours.

    • Minimum Number of Snapshots to Keep: Minimum snapshots to retain. Default: 1.

    • Job Status: Status and timestamp of the most recent snapshot cleanup job.

  5. Click Edit to modify the snapshot management parameters, and then click Save.

ossutil

Use ossutil to modify the snapshot management configuration:

ossutil tables-api put-table-maintenance-configuration \
  --table-bucket-arn {ARN} \
  --namespace mynamespace \
  --name mytable \
  --type icebergSnapshotManagement \
  --value '{"status":"enabled","settings":{"icebergSnapshotManagement":{"maxSnapshotAgeHours":72,"minSnapshotsToKeep":3}}}'

SDK

Query and modify snapshot management configuration using an SDK. Snapshot management and compaction share the same API operations: GetTableMaintenanceConfiguration and PutTableMaintenanceConfiguration.

Python

Query the snapshot management configuration:

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

parser = argparse.ArgumentParser(description="get table maintenance configuration 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)

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_maintenance_configuration(
        oss_tables.models.GetTableMaintenanceConfigurationRequest(
            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' table arn: {result.table_arn},'
          f' configuration: {result.configuration}')


if __name__ == "__main__":
    main()

Modify the snapshot management configuration:

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

parser = argparse.ArgumentParser(description="put table maintenance configuration 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('--type', help='The maintenance type, e.g., icebergSnapshotManagement.', 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)

    value = {
        'status': 'enabled',
        'settings': {
            'icebergSnapshotManagement': {
                'maxSnapshotAgeHours': 72,
                'minSnapshotsToKeep': 3
            }
        }
    }

    result = client.put_table_maintenance_configuration(
        oss_tables.models.PutTableMaintenanceConfigurationRequest(
            table_bucket_arn=args.table_bucket_arn,
            namespace=args.namespace,
            name=args.name,
            type=args.type,
            value=value,
        )
    )

    print(f'status code: {result.status_code},'
          f' request id: {result.request_id}')
    print(f'successfully updated maintenance configuration for: {args.namespace}/{args.name}')


if __name__ == "__main__":
    main()

Go

Query the snapshot management configuration:

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(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.GetTableMaintenanceConfiguration(context.TODO(), &tables.GetTableMaintenanceConfigurationRequest{
		TableBucketARN: oss.Ptr(tableBucketArn),
		Namespace:      oss.Ptr(namespace),
		Name:           oss.Ptr(name),
	})

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

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

Modify the snapshot management configuration:

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(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)



	// icebergSnapshotManagement type
	result, err := client.PutTableMaintenanceConfiguration(context.TODO(), &tables.PutTableMaintenanceConfigurationRequest{
		TableBucketARN: oss.Ptr(tableBucketArn),
		Namespace:      oss.Ptr(namespace),
		Name:           oss.Ptr(name),
		Type:           oss.Ptr("icebergSnapshotManagement"),
		Value: &tables.TableMaintenanceValue{
			Status: oss.Ptr("enabled"),
			Settings: &tables.TableMaintenanceSettings{
				IcebergSnapshotManagement: &tables.IcebergSnapshotManagementSettingsDetail{
					MaxSnapshotAgeHours: oss.Ptr(350),
					MinSnapshotsToKeep:  oss.Ptr(1),
				},
			},
		},
	})

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

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

Java

Query the snapshot management configuration:

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 GetTableMaintenanceConfigurationSample {

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

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

            GetTableMaintenanceConfigurationResult result = client.getTableMaintenanceConfiguration(request);

            System.out.printf("Status code:%d, request id:%s%n",
                    result.statusCode(), result.requestId());
            System.out.printf("Table ARN: %s%n", result.tableARN());

            if (result.configuration() != null && !result.configuration().isEmpty()) {
                System.out.println("Maintenance configurations:");
                result.configuration().forEach((type, config) -> {
                    System.out.printf("  Type: %s, Status: %s%n", type, config.status());
                    if (config.settings() != null) {
                        if (config.settings().icebergCompaction() != null) {
                            System.out.printf("    Compaction - TargetFileSizeMB: %d, Strategy: %s%n",
                                    config.settings().icebergCompaction().targetFileSizeMB(),
                                    config.settings().icebergCompaction().strategy());
                        }
                        if (config.settings().icebergSnapshotManagement() != null) {
                            System.out.printf("    SnapshotManagement - MinSnapshotsToKeep: %d, MaxSnapshotAgeHours: %d%n",
                                    config.settings().icebergSnapshotManagement().minSnapshotsToKeep(),
                                    config.settings().icebergSnapshotManagement().maxSnapshotAgeHours());
                        }
                    }
                });
            } else {
                System.out.println("No maintenance configuration found.");
            }
        } catch (Exception e) {
            System.out.println("Error: " + e.getMessage());
        }
    }
}

Modify the snapshot management configuration:

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 PutTableMaintenanceConfigurationSample {

    public static void main(String[] args) throws Exception {
        String region = "cn-hangzhou";
        String tableBucketARN = "acs:osstables:cn-hangzhou:1234567890:bucket/mytable-bucket";
        String namespace = "mynamespace";
        String name = "mytable";
        String type = "icebergSnapshotManagement";
        String status = "enabled";
        int maxSnapshotAgeHours = 72;
        int minSnapshotsToKeep = 3;

        try (OSSTablesClient client = OSSTablesClient.newBuilder()
                .credentialsProvider(new EnvironmentVariableCredentialsProvider())
                .region(region)
                .build()) {
            IcebergSnapshotManagementSettings snapshotManagementSettings = IcebergSnapshotManagementSettings.newBuilder()
                    .maxSnapshotAgeHours(maxSnapshotAgeHours)
                    .minSnapshotsToKeep(minSnapshotsToKeep)
                    .build();
            TableMaintenanceSettings settings = TableMaintenanceSettings.newBuilder()
                    .icebergSnapshotManagement(snapshotManagementSettings)
                    .build();

            TableMaintenanceConfigurationValue value = TableMaintenanceConfigurationValue.newBuilder()
                    .status(status)
                    .settings(settings)
                    .build();

            PutTableMaintenanceConfigurationRequest request = PutTableMaintenanceConfigurationRequest.newBuilder()
                    .tableBucketARN(tableBucketARN)
                    .namespace(namespace)
                    .name(name)
                    .type(type)
                    .value(value)
                    .build();

            PutTableMaintenanceConfigurationResult result = client.putTableMaintenanceConfiguration(request);

            System.out.printf("Status code:%d, request id:%s%n",
                    result.statusCode(), result.requestId());
            System.out.printf("Successfully put table maintenance configuration for table: %s/%s, type: %s%n", namespace, name, type);
        } catch (Exception e) {
            System.out.println("Error: " + e.getMessage());
        }
    }
}

API

API operations:

Runtime mechanism

  • Scheduling: The backend automatically schedules maintenance tasks. Tasks typically run once every 24 hours per table but do not follow a fixed schedule. High system load may cause delays.

  • Resource usage: Maintenance tasks do not consume your throughput or QPS quotas and do not affect production workloads.

  • Transaction isolation: Maintenance tasks use Iceberg snapshot isolation. Concurrent reads and writes continue unaffected — the query engine automatically selects the latest valid snapshot.

Query maintenance job status

Check the status of compaction, snapshot management, and unreferenced file cleanup jobs. Each job type reports status independently.

Console

View Job status for each maintenance type on the Data Maintenance tab.

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

  2. Click the name of the target Table Bucket. In the Table List, click the table name to open its details page.

  3. Click the Data Maintenance tab.

  4. In each maintenance section, view the Job status:

    • Compaction: Execution status (Failed or Succeeded) and last run timestamp.

    • Snapshot management: Execution status and last run timestamp of the snapshot cleanup job.

    • Unreferenced file cleanup: Configured at the Table Bucket level. Click Edit Configuration in Table Bucket to view status on the Table Bucket's Data Maintenance page.

Ossutil

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

SDK

Python

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

parser = argparse.ArgumentParser(description="get table maintenance job status sample")
parser.add_argument('--region', help='The region where 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)

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_maintenance_job_status(
        oss_tables.models.GetTableMaintenanceJobStatusRequest(
            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' table arn: {result.table_arn},'
          f' status: {result.status}')


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
	namespace      string
	name           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.")
}

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.GetTableMaintenanceJobStatus(context.TODO(), &tables.GetTableMaintenanceJobStatusRequest{
		TableBucketARN: oss.Ptr(tableBucketArn),
		Namespace:      oss.Ptr(namespace),
		Name:           oss.Ptr(name),
	})

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

	log.Printf("get table maintenance job status 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 GetTableMaintenanceJobStatusSample {

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

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

            GetTableMaintenanceJobStatusResult result = client.getTableMaintenanceJobStatus(request);

            System.out.printf("Status code:%d, request id:%s%n",
                    result.statusCode(), result.requestId());
            System.out.printf("Table ARN: %s%n", result.tableARN());

            if (result.jobStatus() != null && !result.jobStatus().isEmpty()) {
                System.out.println("Maintenance job status:");
                result.jobStatus().forEach((type, status) -> {
                    System.out.printf("  Type: %s, Status: %s%n", type, status.status());
                    if (status.lastRunTimestamp() != null) {
                        System.out.printf("    LastRunTimestamp: %s%n", status.lastRunTimestamp());
                    }
                    if (status.failureMessage() != null && !status.failureMessage().isEmpty()) {
                        System.out.printf("    FailureMessage: %s%n", status.failureMessage());
                    }
                });
            } else {
                System.out.println("No maintenance job status found.");
            }
        } catch (Exception e) {
            System.out.println("Error: " + e.getMessage());
        }
    }
}

API

Call GetTableMaintenanceJobStatus to query maintenance job status.