Skip to content

feat(table): Add cleanup orphan files features - #525

Merged
zeroshade merged 8 commits into
apache:mainfrom
dttung2905:add-cleanup-orphan-files
Sep 5, 2025
Merged

zeroshade merged 8 commits into
apache:mainfrom
dttung2905:add-cleanup-orphan-files

Conversation

@dttung2905

Copy link
Copy Markdown
Contributor

Hi team,

I believe the DeleteOrphanFiles functionality is a valuable addition toward making iceberg-go more feature-complete. This implementation was drafted with reference to the official Iceberg Java API specification.

The PR also includes corresponding unit and integration tests to ensure reliability. Below is some example usages:

// Example usage:

// Dry run to see what would be deleted
result, err := table.DeleteOrphanFiles(ctx,
	WithDryRun(true),
	WithOlderThan(time.Now().AddDate(0, 0, -7)),
)

// Actually delete orphan files with parallel execution
result, err = table.DeleteOrphanFiles(ctx,
	WithOlderThan(time.Now().AddDate(0, 0, -3)),
	WithMaxConcurrency(8),
)

// Advanced usage with scheme equivalence and prefix mismatch handling
result, err = table.DeleteOrphanFiles(ctx,
	WithLocation("s3://my-bucket/table/data"),
	WithOlderThan(time.Now().AddDate(0, 0, -7)),
	WithEqualSchemes(map[string]string{"s3,s3a,s3n": "s3"}),
	WithPrefixMismatchMode(PrefixMismatchIgnore),
	WithDeleteFunc(customDeleteFunction),
)

@zeroshade zeroshade left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

first pass of comments

Comment thread io/blob.go Resolved
Comment thread io/io.go Resolved
Comment thread table/orphan_cleanup.go Resolved
Comment thread table/orphan_cleanup.go Resolved
Comment thread table/orphan_cleanup.go Resolved
Comment thread table/orphan_cleanup.go Resolved
Comment thread table/orphan_cleanup.go Resolved
Comment thread io/blob.go Resolved
Comment thread io/blob.go Resolved
Comment thread io/io.go Resolved
Comment thread table/orphan_cleanup.go Resolved
Comment thread table/orphan_cleanup.go Resolved
Comment thread table/orphan_cleanup.go Resolved
Comment thread table/orphan_cleanup.go Resolved
Comment thread table/orphan_cleanup.go Resolved
Comment thread table/orphan_cleanup.go Resolved
Comment thread table/orphan_cleanup.go Resolved
Comment thread table/orphan_cleanup.go Resolved
@dttung2905

Copy link
Copy Markdown
Contributor Author

I see WithOlderThan() is also recently introduced in expired snapshot ops https://github.com/apache/iceberg-go/actions/runs/17081949920/job/48596478018?pr=525. I will work on unifying this in my next commit

@dttung2905
dttung2905 force-pushed the add-cleanup-orphan-files branch from cc963f2 to 079d0df Compare August 22, 2025 20:29
@dttung2905
dttung2905 requested a review from zeroshade August 27, 2025 21:20
Signed-off-by: dttung2905 <[email protected]>
Signed-off-by: dttung2905 <[email protected]>
@zeroshade
zeroshade merged commit 8d84100 into apache:main Sep 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants