Skip to content

Spark: Fix orphan file matching for sibling table prefixes - #17448

Open
alessandro-nori wants to merge 2 commits into
apache:mainfrom
alessandro-nori:anori/delete-orphan-files-sibling-prefix
Open

Spark: Fix orphan file matching for sibling table prefixes#17448
alessandro-nori wants to merge 2 commits into
apache:mainfrom
alessandro-nori:anori/delete-orphan-files-sibling-prefix

Conversation

@alessandro-nori

@alessandro-nori alessandro-nori commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Summary

  • In DeleteOrphanFilesSparkAction.filteredCompareToFileList(), when compareToFileList is used, files are filtered with startsWith(location). If location doesn't end with /, this can also match sibling table paths (e.g. /ns/my_table matches /ns/my_table_2), incorrectly marking their files as orphans of the wrong table.
  • Normalize location to always end with / before filtering, mirroring the behavior of the default directory-listing path.

Motivation

Prevents deleteOrphanFiles with a custom compareToFileList from deleting files belonging to a different table that merely shares a path prefix with the target table's location.

See #17449 for a repro-only PR (test without the fix) demonstrating the bug — CI fails there as expected.

@alessandro-nori
alessandro-nori marked this pull request as ready for review July 31, 2026 12:13

@uros-b uros-b 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.

@alessandro-nori Please note that this may have already been in progress: #16498.

@uros-b

uros-b commented Jul 31, 2026

Copy link
Copy Markdown
Member

cc @wombatu-kun ^^

Sign up for free to 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.

2 participants