World's most powerful open data catalog for building a high-performance, geo-distributed and federated metadata lake.
title: "Iceberg Orphan File Removal Policy" slug: "/iceberg-orphan-file-removal-policy" keyword: "iceberg, orphan, cleanup, 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_orphan_file_removal is a built-in policy type used by the optimizer and the
Table Maintenance Service to remove unreferenced Iceberg files through
builtin-iceberg-remove-orphan-files.
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. It accepts time
triggers only; commitTrigger=true is rejected.
Policy Content
The typed content for system_iceberg_orphan_file_removal supports the following fields:
| Field | Required | Default | Description |
|---|---|---|---|
olderThanDays |
No | 3 |
Minimum age of orphan files eligible for removal, in days. Must be between 1 and 36500. |
location |
No | Table location | Optional absolute scan path within the table. Must be a valid absolute URI path without query, fragment, .., \, or percent-encoding. |
dryRun |
No | false |
When true, list candidates without deleting. 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-orphan-file-removaljob.template-name=builtin-iceberg-remove-orphan-files
Derived rules:
trigger-expr=truescore-expr=1job.options.olderThanDays=<olderThanDays>job.options.dryRun=<dryRun>job.options.location=<location>whenlocationis set
The optimizer or TMS schedule decides when to submit the job. Once the Spark job starts, it
always runs the orphan-cleanup 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_orphan_cleanup_default",
"comment": "Built-in iceberg orphan file removal policy",
"policyType": "system_iceberg_orphan_file_removal",
"enabled": true,
"content": {}
}' \
http://localhost:8090/api/metalakes/test/policies
GravitinoClient client = ...;
PolicyContent content = PolicyContents.icebergOrphanFileRemoval();
Policy policy =
client.createPolicy(
"iceberg_orphan_cleanup_default",
"system_iceberg_orphan_file_removal",
"Built-in iceberg orphan file removal 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
Remove Orphan Files.