feat: implicitly append wildcard if querying directory in file engine

This commit is contained in:
gun9nir 2024-07-02 21:42:59 -07:00
parent e3f821573e
commit be9a17f2cc
3 changed files with 25 additions and 5 deletions

View File

@ -366,12 +366,18 @@ Strings StorageFile::getPathsList(const String & table_path, const String & user
}
else if (path.find_first_of("*?{") == std::string::npos)
{
std::error_code error;
size_t size = fs::file_size(path, error);
if (!error)
total_bytes_to_read += size;
if (!fs::is_directory(path)) {
std::error_code error;
size_t size = fs::file_size(path, error);
if (!error)
total_bytes_to_read += size;
paths.push_back(path);
paths.push_back(path);
} else {
/// We list non-directory files under that directory.
paths = listFilesWithRegexpMatching(path / fs::path("*"), total_bytes_to_read);
can_be_directory = false;
}
}
else
{

View File

@ -0,0 +1,3 @@
2
2
1

View File

@ -0,0 +1,11 @@
INSERT INTO FUNCTION file('data_03198_table_function_directory_path/1.csv', 'csv') SELECT '1.csv';
INSERT INTO FUNCTION file('data_03198_table_function_directory_path/2.csv', 'csv') SELECT '2.csv';
INSERT INTO FUNCTION file('data_03198_table_function_directory_path/dir/3.csv', 'csv') SELECT '3.csv';
INSERT INTO FUNCTION file('data_03198_table_function_directory_path/dir1/dir/4.csv', 'csv') SELECT '4.csv';
INSERT INTO FUNCTION file('data_03198_table_function_directory_path/dir2/dir/5.csv', 'csv') SELECT '5.csv';
SELECT COUNT(*) FROM file('data_03198_table_function_directory_path');
SELECT COUNT(*) FROM file('data_03198_table_function_directory_path/');
SELECT COUNT(*) FROM file('data_03198_table_function_directory_path/dir');
SELECT COUNT(*) FROM file('data_03198_table_function_directory_path/*/dir', 'csv'); -- { serverError 74, 636 }
SELECT COUNT(*) FROM file('data_03198_table_function_directory_pat'); -- { serverError 400 }