mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-24 00:22:29 +00:00
Fix behaviour of globs in filepath with leading zeros
This commit is contained in:
parent
816eccde11
commit
834e458f26
@ -4,6 +4,7 @@
|
||||
#include <algorithm>
|
||||
#include <sstream>
|
||||
#include <cassert>
|
||||
#include <iomanip>
|
||||
|
||||
|
||||
namespace DB
|
||||
@ -46,10 +47,17 @@ std::string makeRegexpPatternFromGlobs(const std::string & initial_str_with_glob
|
||||
std::istringstream iss_range(buffer);
|
||||
iss_range >> range_begin >> point >> point >> range_end;
|
||||
assert(iss_range.good());
|
||||
bool leading_zeros = buffer[0] == '0';
|
||||
size_t num_len = std::to_string(range_end).size();
|
||||
if (leading_zeros)
|
||||
oss_for_replacing << std::setfill('0') << std::setw(num_len);
|
||||
oss_for_replacing << range_begin;
|
||||
for (size_t i = range_begin + 1; i <= range_end; ++i)
|
||||
{
|
||||
oss_for_replacing << '|' << i;
|
||||
oss_for_replacing << '|';
|
||||
if (leading_zeros)
|
||||
oss_for_replacing << std::setfill('0') << std::setw(num_len);
|
||||
oss_for_replacing << i;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -64,6 +64,7 @@ def test_linear_structure(start_cluster):
|
||||
("file?", "10"),
|
||||
("nothing*", "0"),
|
||||
("file{0..9}{0..9}{0..9}", "10"),
|
||||
("file{000..999}", "10"),
|
||||
("file???", "10"),
|
||||
("file*", "20"),
|
||||
("a_{file,data}", "4"),
|
||||
|
Loading…
Reference in New Issue
Block a user