Skip to content

Commit 68a487f

Browse files
committed
Revert "Use @subkanthi way"
This reverts commit ddd34ac.
1 parent e485a91 commit 68a487f

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

src/IO/S3/URI.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ namespace DB
1616

1717
struct URIConverter
1818
{
19-
static void modifyURI(Poco::URI & uri, std::unordered_map<std::string, std::string> mapper)
19+
static void modifyURI(Poco::URI & uri, std::unordered_map<std::string, std::string> mapper, bool enable_url_encoding)
2020
{
2121
Macros macros({{"bucket", uri.getHost()}});
2222
uri = macros.expand(mapper[uri.getScheme()]).empty()
2323
? uri
24-
: Poco::URI(macros.expand(mapper[uri.getScheme()]) + uri.getPathAndQuery());
24+
: Poco::URI(macros.expand(mapper[uri.getScheme()]) + uri.getPathAndQuery(), enable_url_encoding);
2525
}
2626
};
2727

@@ -33,7 +33,7 @@ namespace ErrorCodes
3333
namespace S3
3434
{
3535

36-
URI::URI(const std::string & uri_, bool allow_archive_path_syntax)
36+
URI::URI(const std::string & uri_, bool allow_archive_path_syntax, bool enable_url_encoding)
3737
{
3838
/// Case when bucket name represented in domain name of S3 URL.
3939
/// E.g. (https://bucket-name.s3.region.amazonaws.com/key)
@@ -55,7 +55,7 @@ URI::URI(const std::string & uri_, bool allow_archive_path_syntax)
5555
else
5656
uri_str = uri_;
5757

58-
uri = Poco::URI(uri_str);
58+
uri = Poco::URI(uri_str, enable_url_encoding);
5959

6060
std::unordered_map<std::string, std::string> mapper;
6161
auto context = Context::getGlobalContextInstance();
@@ -77,7 +77,7 @@ URI::URI(const std::string & uri_, bool allow_archive_path_syntax)
7777
}
7878

7979
if (!mapper.empty())
80-
URIConverter::modifyURI(uri, mapper);
80+
URIConverter::modifyURI(uri, mapper, enable_url_encoding);
8181
}
8282

8383
storage_name = "S3";

src/IO/S3/URI.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ struct URI
3636
bool is_virtual_hosted_style;
3737

3838
URI() = default;
39-
explicit URI(const std::string & uri_, bool allow_archive_path_syntax = false);
39+
explicit URI(const std::string & uri_, bool allow_archive_path_syntax = false, bool enable_url_encoding = true);
4040
void addRegionToURI(const std::string & region);
4141

4242
static void validateBucket(const std::string & bucket, const Poco::URI & uri);

src/Storages/ObjectStorage/Utils.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -342,9 +342,9 @@ std::pair<DB::ObjectStoragePtr, std::string> resolveObjectStorageForPath(
342342
normalized_path = "s3://" + target_decomposed.authority + "/" + target_decomposed.key;
343343
}
344344
// enable_url_encoding=false, path from metadata must have correct encoding already
345-
S3::URI s3_uri(normalized_path);
345+
S3::URI s3_uri(normalized_path, /*allow_archive_path_syntax*/ false, /*enable_url_encoding*/ false);
346346

347-
std::string key_to_use = target_decomposed.key;
347+
std::string key_to_use = s3_uri.key;
348348

349349
bool use_base_storage = false;
350350
if (base_storage->getType() == ObjectStorageType::S3)
@@ -366,7 +366,7 @@ std::pair<DB::ObjectStoragePtr, std::string> resolveObjectStorageForPath(
366366
{
367367
normalized_table_location = "s3://" + table_location_decomposed.authority + "/" + table_location_decomposed.key;
368368
}
369-
S3::URI base_s3_uri(normalized_table_location);
369+
S3::URI base_s3_uri(normalized_table_location, /*allow_archive_path_syntax*/ false, /*enable_url_encoding*/ false);
370370

371371
if (s3URIMatches(s3_uri, base_s3_uri.bucket, base_s3_uri.endpoint, target_scheme_normalized))
372372
use_base_storage = true;

0 commit comments

Comments
 (0)