Skip to content

Commit 3987ff9

Browse files
authored
Merge branch 'customizations/24.3.11' into 24.3.5_aarch64-integration-tests
2 parents a494831 + 8536c5a commit 3987ff9

File tree

3 files changed

+46
-3
lines changed

3 files changed

+46
-3
lines changed

src/IO/S3/URI.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,17 @@ namespace S3
3333
URI::URI(const std::string & uri_)
3434
{
3535
/// Case when bucket name represented in domain name of S3 URL.
36-
/// E.g. (https://bucket-name.s3.Region.amazonaws.com/key)
36+
/// E.g. (https://bucket-name.s3.region.amazonaws.com/key)
3737
/// https://docs.aws.amazon.com/AmazonS3/latest/dev/VirtualHosting.html#virtual-hosted-style-access
3838
static const RE2 virtual_hosted_style_pattern(R"((.+)\.(s3express[\-a-z0-9]+|s3|cos|obs|oss|eos)([.\-][a-z0-9\-.:]+))");
3939

40+
/// Case when AWS Private Link Interface is being used
41+
/// E.g. (bucket.vpce-07a1cd78f1bd55c5f-j3a3vg6w.s3.us-east-1.vpce.amazonaws.com/bucket-name/key)
42+
/// https://docs.aws.amazon.com/AmazonS3/latest/userguide/privatelink-interface-endpoints.html
43+
static const RE2 aws_private_link_style_pattern(R"(bucket\.vpce\-([a-z0-9\-.]+)\.vpce.amazonaws.com(:\d{1,5})?)");
44+
4045
/// Case when bucket name and key represented in path of S3 URL.
41-
/// E.g. (https://s3.Region.amazonaws.com/bucket-name/key)
46+
/// E.g. (https://s3.region.amazonaws.com/bucket-name/key)
4247
/// https://docs.aws.amazon.com/AmazonS3/latest/dev/VirtualHosting.html#path-style-access
4348
static const RE2 path_style_pattern("^/([^/]*)/(.*)");
4449

@@ -103,7 +108,10 @@ URI::URI(const std::string & uri_)
103108
String name;
104109
String endpoint_authority_from_uri;
105110

106-
if (re2::RE2::FullMatch(uri.getAuthority(), virtual_hosted_style_pattern, &bucket, &name, &endpoint_authority_from_uri))
111+
bool is_using_aws_private_link_interface = re2::RE2::FullMatch(uri.getAuthority(), aws_private_link_style_pattern);
112+
113+
if (!is_using_aws_private_link_interface
114+
&& re2::RE2::FullMatch(uri.getAuthority(), virtual_hosted_style_pattern, &bucket, &name, &endpoint_authority_from_uri))
107115
{
108116
is_virtual_hosted_style = true;
109117
endpoint = uri.getScheme() + "://" + name + endpoint_authority_from_uri;

src/IO/S3/URI.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ namespace DB::S3
1717
* The following patterns are allowed:
1818
* s3://bucket/key
1919
* http(s)://endpoint/bucket/key
20+
* http(s)://bucket.<vpce_endpoint_id>.s3.<region>.vpce.amazonaws.com<:port_number>/bucket_name/key
2021
*/
2122
struct URI
2223
{

src/IO/tests/gtest_s3_uri.cpp

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,40 @@ const TestCase TestCases[] = {
7474
"data",
7575
"",
7676
true},
77+
{S3::URI("https://bucket.vpce-07a1cd78f1bd55c5f-j3a3vg6w.s3.us-east-1.vpce.amazonaws.com/root/nested/file.txt"),
78+
"https://bucket.vpce-07a1cd78f1bd55c5f-j3a3vg6w.s3.us-east-1.vpce.amazonaws.com",
79+
"root",
80+
"nested/file.txt",
81+
"",
82+
false},
83+
// Test with a file with no extension
84+
{S3::URI("https://bucket.vpce-03b2c987f1bd55c5f-j3b4vg7w.s3.ap-southeast-2.vpce.amazonaws.com/some_bucket/document"),
85+
"https://bucket.vpce-03b2c987f1bd55c5f-j3b4vg7w.s3.ap-southeast-2.vpce.amazonaws.com",
86+
"some_bucket",
87+
"document",
88+
"",
89+
false},
90+
// Test with a deeply nested file path
91+
{S3::URI("https://bucket.vpce-0242cd56f1bd55c5f-l5b7vg8x.s3.sa-east-1.vpce.amazonaws.com/some_bucket/b/c/d/e/f/g/h/i/j/data.json"),
92+
"https://bucket.vpce-0242cd56f1bd55c5f-l5b7vg8x.s3.sa-east-1.vpce.amazonaws.com",
93+
"some_bucket",
94+
"b/c/d/e/f/g/h/i/j/data.json",
95+
"",
96+
false},
97+
// Zonal
98+
{S3::URI("https://bucket.vpce-07a1cd78f1bd55c5f-j3a3vg6w-us-east-1a.s3.us-east-1.vpce.amazonaws.com/root/nested/file.txt"),
99+
"https://bucket.vpce-07a1cd78f1bd55c5f-j3a3vg6w-us-east-1a.s3.us-east-1.vpce.amazonaws.com",
100+
"root",
101+
"nested/file.txt",
102+
"",
103+
false},
104+
// Non standard port
105+
{S3::URI("https://bucket.vpce-07a1cd78f1bd55c5f-j3a3vg6w-us-east-1a.s3.us-east-1.vpce.amazonaws.com:65535/root/nested/file.txt"),
106+
"https://bucket.vpce-07a1cd78f1bd55c5f-j3a3vg6w-us-east-1a.s3.us-east-1.vpce.amazonaws.com:65535",
107+
"root",
108+
"nested/file.txt",
109+
"",
110+
false},
77111
};
78112

79113
class S3UriTest : public testing::TestWithParam<std::string>

0 commit comments

Comments
 (0)