Skip to content

[FLINK-38774][table-common] Skip hidden directories when recursively listing partitions - #28913

Open
hulincup wants to merge 1 commit into
apache:masterfrom
hulincup:FLINK-38774
Open

[FLINK-38774][table-common] Skip hidden directories when recursively listing partitions#28913
hulincup wants to merge 1 commit into
apache:masterfrom
hulincup:FLINK-38774

Conversation

@hulincup

@hulincup hulincup commented Aug 4, 2026

Copy link
Copy Markdown

What

PartitionPathUtils.listStatusRecursively descended into every subdirectory returned by fs.listStatus, including hidden ones such as _temporary. A non-hidden child of a hidden dir (e.g. _temporary/job-123) sitting at partition depth was then collected with an empty partition spec, which later surfaces as a TableException: incomplete partition spec in the filesystem connector source.

Reported in FLINK-38774 (supersedes the older FLINK-31975).

Fix

Reuse the existing listStatusWithoutHidden helper to filter hidden children at every recursion level — not only at the leaf, where searchPartSpecAndPaths already filtered via isHiddenFile. Add a null guard consistent with listStatusWithoutHidden's contract (returns null when fs.listStatus returns null), which also removes a latent NPE in the old for-each over a null list.

if (fileStatus.isDir()) {
    FileStatus[] children = listStatusWithoutHidden(fs, fileStatus.getPath());
    if (children == null) {
        return;
    }
    for (FileStatus stat : children) {
        listStatusRecursively(fs, stat, level + 1, expectLevel, results);
    }
}

Test

Adds a @TempDir regression test that creates a real partition (date=2019-8-30/country=China) alongside a hidden _temporary/job-123 subtree and asserts searchPartSpecAndPaths returns only the real partition. Without the fix the hidden job-123 leaf leaks in with an empty spec (2 entries); with the fix only the real partition is returned (1 entry).

Notes

…listing partitions

listStatusRecursively descended into every subdirectory returned by
fs.listStatus, including hidden ones such as _temporary. A non-hidden
child of a hidden dir (e.g. _temporary/job-123) sitting at partition
depth was then collected with an empty partition spec, which later
surfaces as 'TableException: incomplete partition spec' in the
filesystem connector source.

Reuse the existing listStatusWithoutHidden helper to filter hidden
children at every recursion level (not only at the leaf, where
searchPartSpecAndPaths already filtered). Add a null guard consistent
with listStatusWithoutHidden's contract (returns null when
fs.listStatus returns null), which also removes a latent NPE in the
old for-each over a null list.

Adds a @tempdir regression test that creates a real partition
(date=2019-8-30/country=China) alongside a hidden _temporary/job-123
subtree and asserts only the real partition is returned.

This supersedes the abandoned apache#27314.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@flinkbot

flinkbot commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator

CI report:

Bot commands The @flinkbot bot supports the following commands:
  • @flinkbot run azure re-run the last Azure build

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