Skip to content

Commit

Permalink
[BugFix] Fix list files when no files were found
Browse files Browse the repository at this point in the history
Signed-off-by: wyb <[email protected]>
  • Loading branch information
wyb committed Dec 13, 2024
1 parent 1300393 commit 675f0de
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,9 @@ public List<List<String>> listFilesAndDirs() {
files.add(fileInfo);
}
}
if (files.isEmpty()) {
ErrorReport.reportDdlException(ErrorCode.ERR_NO_FILES_FOUND, path);
}
return files;
} catch (StarRocksException e) {
LOG.warn("failed to parse files", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1203,7 +1203,7 @@ public List<FileStatus> listFileMeta(String path, Map<String, String> properties
Path pathPattern = new Path(pathUri.getPath());
try {
FileStatus[] files = fileSystem.getDFSFileSystem().globStatus(pathPattern);
return Lists.newArrayList(files);
return files != null ? Lists.newArrayList(files) : Lists.newArrayList();
} catch (FileNotFoundException e) {
LOG.info("file not found: " + path, e);
throw new StarRocksException("file not found: " + path, e);
Expand Down
11 changes: 11 additions & 0 deletions test/sql/test_files/R/csv_format
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,17 @@ select path, size, is_dir from files(
"aws.s3.secret_key" = "${oss_sk}",
"aws.s3.endpoint" = "${oss_endpoint}");
-- result:
[REGEX].*failed to parse files: No files were found matching the pattern\(s\) or path\(s\).*
-- !result

select path, size, is_dir from files(
"path" = "oss://${oss_bucket}/test_files/csv_format/${uuid0}/xxxxxx",
"list_files_only" = "true",
"aws.s3.access_key" = "${oss_ak}",
"aws.s3.secret_key" = "${oss_sk}",
"aws.s3.endpoint" = "${oss_endpoint}");
-- result:
[REGEX].*failed to parse files: No files were found matching the pattern\(s\) or path\(s\).*
-- !result

shell: ossutil64 rm -rf oss://${oss_bucket}/test_files/csv_format/${uuid0}/ > /dev/null
7 changes: 7 additions & 0 deletions test/sql/test_files/T/csv_format
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,12 @@ select path, size, is_dir from files(
"aws.s3.secret_key" = "${oss_sk}",
"aws.s3.endpoint" = "${oss_endpoint}");

select path, size, is_dir from files(
"path" = "oss://${oss_bucket}/test_files/csv_format/${uuid0}/xxxxxx",
"list_files_only" = "true",
"aws.s3.access_key" = "${oss_ak}",
"aws.s3.secret_key" = "${oss_sk}",
"aws.s3.endpoint" = "${oss_endpoint}");

-- clean
shell: ossutil64 rm -rf oss://${oss_bucket}/test_files/csv_format/${uuid0}/ > /dev/null

0 comments on commit 675f0de

Please sign in to comment.