World's most powerful open data catalog for building a high-performance, geo-distributed and federated metadata lake.
title: "Iceberg Snapshot Expiration Policy" slug: "/iceberg-snapshot-expiration-policy" keyword: "iceberg, snapshot, expiration, policy, optimizer, Gravitino" license: "This software is licensed under the Apache License version 2."
import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem';
Overview
system_iceberg_snapshot_expiration is a built-in policy type used by the optimizer and the
Table Maintenance Service to expire old Iceberg snapshots through
builtin-iceberg-expire-snapshots.
The optimizer treats CATALOG, SCHEMA, and TABLE as the applicable object types for this
policy. That list is not an association reject list: associating a policy does not check
supportedObjectTypes, and object policy lookup does not filter by it. Consumers decide whether
the policy type applies to the object they are processing. See
Policies and the OpenAPI description of supportedObjectTypes.
Policy Content
The typed content for system_iceberg_snapshot_expiration supports the following fields:
| Field | Required | Default | Description |
|---|---|---|---|
olderThanDays |
No | 5 |
Minimum age of snapshots eligible for expiration, in days. Must be between 1 and 36500. |
retainLast |
No | 1 |
Minimum number of recent snapshots to keep regardless of age. Must be >= 1. |
streamResults |
No | false |
Whether the expire job should stream intermediate delete results. JSON boolean only. |
Generated Rules and Properties
Typed content fields on CREATE/GET are the REST payload. The optimizer (and other consumers)
derive stable properties and evaluation rules from those fields. The derived keys below are
not serialized as strategy.type, trigger-expr, or job.options.* entries on the policy
REST content object.
After a GET (or create) through the Java or Python client, inspect them with
policy.content().properties() and policy.content().rules() (for example
metalake.getPolicy(name).content().rules()).
Derived properties:
strategy.type=iceberg-snapshot-expirationjob.template-name=builtin-iceberg-expire-snapshots
Derived rules:
trigger-expr=truescore-expr=1job.options.olderThanDays=<olderThanDays>job.options.retainLast=<retainLast>job.options.streamResults=<streamResults>
The optimizer or TMS schedule decides when to submit the job. Once the Spark job starts, it
always runs the expire procedure (trigger-expr=true); there is no extra metric gate inside
Spark.
Policy Examples
curl -X POST -H "Accept: application/vnd.gravitino.v1+json" \
-H "Content-Type: application/json" \
-d '{
"name": "iceberg_snapshot_expiration_default",
"comment": "Built-in iceberg snapshot expiration policy",
"policyType": "system_iceberg_snapshot_expiration",
"enabled": true,
"content": {}
}' \
http://localhost:8090/api/metalakes/test/policies
GravitinoClient client = ...;
PolicyContent content = PolicyContents.icebergSnapshotExpiration();
Policy policy =
client.createPolicy(
"iceberg_snapshot_expiration_default",
"system_iceberg_snapshot_expiration",
"Built-in iceberg snapshot expiration policy",
true,
content);
Apply the Policy Through a Tag
After creating the policy, create or reuse a tag, associate the policy with that tag using the
ALL_VALUES selector, and assign the tag to a table or one of its ancestors. See
Manage Policies and
Snapshot expiration.