Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions velox/connectors/hive/storage_adapters/abfs/AbfsPath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
* limitations under the License.
*/

#include <azure/core/url.hpp>
#include <azure/storage/common/crypt.hpp>

#include "velox/connectors/hive/storage_adapters/abfs/AbfsPath.h"
#include "velox/connectors/hive/storage_adapters/abfs/AbfsUtil.h"

Expand All @@ -32,9 +35,12 @@ AbfsPath::AbfsPath(std::string_view path) {
}

auto firstAt = file.find_first_of("@");
fileSystem_ = file.substr(0, firstAt);
fileSystem_ = Azure::Storage::_internal::UrlEncodePath(
Azure::Core::Url::Decode(std::string(file.substr(0, firstAt))));
auto firstSep = file.find_first_of("/");
filePath_ = file.substr(firstSep + 1);
filePath_ = Azure::Storage::_internal::UrlEncodePath(
Azure::Core::Url::Decode(std::string(file.substr(firstSep + 1))));

accountNameWithSuffix_ = file.substr(firstAt + 1, firstSep - firstAt - 1);
auto firstDot = accountNameWithSuffix_.find_first_of(".");
accountName_ = accountNameWithSuffix_.substr(0, firstDot);
Expand All @@ -49,6 +55,7 @@ std::string AbfsPath::getUrl(bool withblobSuffix) const {
accountNameWithSuffixForUrl.replace(startPos, 3, "blob");
}
}

return fmt::format(
"{}{}/{}/{}",
isHttps_ ? "https://" : "http://",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#include "velox/connectors/hive/storage_adapters/abfs/AbfsPath.h"
#include "velox/connectors/hive/storage_adapters/abfs/AbfsUtil.h"

#include "gtest/gtest.h"

using namespace facebook::velox::filesystems;

TEST(AbfsPathTest, encodedPath) {
auto abfssAccountWithSpecialCharacters = AbfsPath(
"abfss://[email protected]/main@dir/brand#51/sub dir/test.txt");
EXPECT_EQ(
abfssAccountWithSpecialCharacters.accountNameWithSuffix(),
"test.dfs.core.windows.net");
EXPECT_EQ(abfssAccountWithSpecialCharacters.accountName(), "test");
EXPECT_EQ(abfssAccountWithSpecialCharacters.fileSystem(), "testc");
EXPECT_EQ(
abfssAccountWithSpecialCharacters.filePath(),
"main@dir/brand#51/sub dir/test.txt");
EXPECT_EQ(
abfssAccountWithSpecialCharacters.getUrl(true),
"https://test.blob.core.windows.net/testc/main@dir/brand%2351/sub%20dir/test.txt");
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ add_executable(
velox_abfs_test
AbfsFileSystemTest.cpp
AbfsUtilTest.cpp
AbfsPathTest.cpp
AzureClientProvidersTest.cpp
AzureClientProviderFactoriesTest.cpp
DynamicSasTokenClientProviderTest.cpp
Expand Down
Loading