Skip to content

API, Spark: Support cleanup level in ExpireSnapshots action and procedure - #17929

Open
xanderbailey wants to merge 2 commits into
apache:mainfrom
xanderbailey:xb/spark-expire-snapshots-cleanup-level
Open

API, Spark: Support cleanup level in ExpireSnapshots action and procedure#17929
xanderbailey wants to merge 2 commits into
apache:mainfrom
xanderbailey:xb/spark-expire-snapshots-cleanup-level

Conversation

@xanderbailey

@xanderbaileyxanderbailey commented Sep 2, 2026

Copy link
Copy Markdown

CleanupLevel was added to the expire snapshots interface in #14287 but is not reachable from any engine. Spark users cannot ask for metadata-only cleanup, and the only way to expire snapshots without deleting files is the core Java API.

Exposing it is not a pass-through. ExpireSnapshotsSparkAction already commits the core expiration with CleanupLevel.NONE and works out what to delete itself, by anti-joining the file lists before and after expiration, so forwarding the level to core would have no effect. The level is applied to that diff instead: ALL behaves as before, METADATA_ONLY deletes manifests, manifest lists and statistics files but retains content files, and NONE commits the expiration and deletes nothing. METADATA_ONLY drops contentFileDS from both sides of the anti-join rather than filtering the result, so the manifests of expired snapshots are never read.

Flink remains untouched in this PR

Exposes the CleanupLevel introduced in apache#14287 through the Spark action
and the expire_snapshots procedure.
The Spark action always commits the core expiration with CleanupLevel.NONE
and determines files to delete itself, so the level is applied to the file
diff rather than passed through:
ALL unchanged, deletes metadata and content files
METADATA_ONLY deletes manifests, manifest lists and statistics files,
and skips listing content files entirely so the manifests
of expired snapshots are never read
NONE commits the expiration and deletes nothing
Also adds CleanupLevel.fromString so the procedure can accept the level as
a string, mirroring DeleteOrphanFiles.PrefixMismatchMode.
…rocedure
Applies the same change to the remaining supported Spark versions. The
action was byte-identical across all three versions, so it is copied
verbatim. The 3.5 procedure differs structurally, but the parameter
plumbing is the same.
@xanderbaileyxanderbailey changed the title Spark 4.1: Support cleanup level in ExpireSnapshots action and procedureSpark: Support cleanup level in ExpireSnapshots action and procedureSep 2, 2026
@xanderbaileyxanderbailey changed the title Spark: Support cleanup level in ExpireSnapshots action and procedureAPI, Spark: Support cleanup level in ExpireSnapshots action and procedureSep 2, 2026
@xanderbailey
xanderbailey marked this pull request as ready for review September 8, 2026 09:23
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@xanderbailey