Merge pull request #42223 from qoega/hdfs-empty-url

This commit is contained in:
Ilya Yatsishin 2022-10-18 09:34:10 +02:00 committed by GitHub
commit 36b63badb3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 2 deletions

View File

@ -120,8 +120,15 @@ namespace
std::pair<String, String> getPathFromUriAndUriWithoutPath(const String & uri) std::pair<String, String> getPathFromUriAndUriWithoutPath(const String & uri)
{ {
const size_t begin_of_path = uri.find('/', uri.find("//") + 2); auto pos = uri.find("//");
return {uri.substr(begin_of_path), uri.substr(0, begin_of_path)}; if (pos != std::string::npos && pos + 2 < uri.length())
{
pos = uri.find('/', pos + 2);
if (pos != std::string::npos)
return {uri.substr(pos), uri.substr(0, pos)};
}
throw Exception("Storage HDFS requires valid URL to be set", ErrorCodes::BAD_ARGUMENTS);
} }
std::vector<String> getPathsList(const String & path_from_uri, const String & uri_without_path, ContextPtr context, std::unordered_map<String, time_t> * last_mod_times = nullptr) std::vector<String> getPathsList(const String & path_from_uri, const String & uri_without_path, ContextPtr context, std::unordered_map<String, time_t> * last_mod_times = nullptr)

View File

@ -0,0 +1,5 @@
-- Tags: no-fasttest, no-cpu-aarch64
SELECT * FROM hdfsCluster('test_shard_localhost', '', 'TSV'); -- { serverError BAD_ARGUMENTS }
SELECT * FROM hdfsCluster('test_shard_localhost', ' ', 'TSV'); -- { serverError BAD_ARGUMENTS }
SELECT * FROM hdfsCluster('test_shard_localhost', '/', 'TSV'); -- { serverError BAD_ARGUMENTS }
SELECT * FROM hdfsCluster('test_shard_localhost', 'http/', 'TSV'); -- { serverError BAD_ARGUMENTS }