Repository navigation
Description
Is there an existing issue for the same bug?
- I have checked the existing issues.
Branch / commit
origin/main at 7b6603be6a.
What happened?
Local external-file discovery silently returns no files when an explicitly named path component starts with .. For example, files under /path/.data/input/part-*.parquet exist and are visible to os.ReadDir, but plan.ReadDir returns ([], [], nil).
The caller consequently treats the input as empty. In the Parquet LOAD compile path this silently collapses expected file/row-group fanout to one empty/serial scope instead of returning the matched files or an error.
This is not specific to Parquet: pkg/sql/plan.ReadDir is shared by local LOAD/external glob discovery.
Root cause
pkg/sql/plan.ReadDir walks an absolute path component by component by calling ETLFileService.List. pkg/fileservice/LocalETLFS.List unconditionally skips every entry whose name starts with .:
if strings.HasPrefix(name, ".") {
continue
}That filtering is also applied to literal intermediate components. Therefore an explicit .cache, .data, etc. can never be traversed. No error is returned, so the failure is silent.
An explicit path component is selection, not discovery, and should not be excluded by a hidden-file discovery policy.
Deterministic reproduction
The issue was exposed by putting Go's test temp root below a hidden directory:
hidden_tmp=$(mktemp -d /home/user/.cache/mo-gotmp.XXXXXX)
GOTMPDIR="$hidden_tmp" go test -count=10 ./pkg/sql/compile \
-run 'TestCompileExternScanParquet(LoadDefaultAtThresholdUsesFileFanoutWithoutFooterReads|LoadDefaultFanoutContextCancellationTerminatesAllShards|LoadUsesRowGroupFanoutWithEmptyFiles|RowGroupFanoutValidatesEmptyFileColumnCount|LoadUsesFileFanoutMainPath)$'All five tests fail consistently because their t.TempDir() paths contain .cache and ReadDir reports zero files.
A/B control using an otherwise equivalent temp root with no hidden component passes 10/10:
visible_tmp=$(mktemp -d /home/user/mo-gotmp.XXXXXX)
GOTMPDIR="$visible_tmp" go test -count=10 ./pkg/sql/compile -run '<same regex>'Direct instrumentation at the failing point showed:
os.ReadDir(<hidden temp input dir>):part-0.parquet,part-1.parquetplan.ReadDir(param):files=[] sizes=[] err=nil
Expected behavior
A literal hidden intermediate directory in an explicit input path is traversed normally. The final glob should match its files, or discovery should return a meaningful error; it must not silently convert an existing input into an empty input.
Suggested systematic fix / regression matrix
Preserve the distinction between literal path traversal and wildcard discovery:
- literal intermediate component such as
.data: traverse it; - wildcard that explicitly matches hidden names: define and test the intended behavior;
- wildcard that does not match hidden names: retain the intended hidden-file policy, if any;
- hidden final file explicitly named vs. discovered by glob;
- local LOAD and external-table callers;
- file and directory symlinks;
- missing literal component must still report/produce the documented result rather than matching unrelated entries.
One possible implementation is for ReadDir to handle non-glob path components directly instead of filtering them through directory discovery. Another is to make LocalETLFS.List complete and move any hidden-entry policy to callers/pattern matching. The ownership of that policy should be explicit and covered at both FileService and plan layers.
Activity
fix(fileservice): honor explicit hidden paths in external scans (#28362)
fix(fileservice): honor explicit hidden paths in external scans (matr…
fix(fileservice): honor explicit hidden paths in external scans (matr…
fix(fileservice): honor explicit hidden paths in external scans (matr…