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: 11 additions & 0 deletions cpp/src/arrow/filesystem/azurefs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3561,4 +3561,15 @@ Result<std::string> AzureFileSystem::PathFromUri(const std::string& uri_string)
return path;
}

static Result<std::shared_ptr<FileSystem>> AzureFileSystemFactory(
const Uri& uri, const io::IOContext& io_context, std::string* out_path) {
ARROW_ASSIGN_OR_RAISE(auto options, AzureOptions::FromUri(uri, out_path));
return AzureFileSystem::Make(options, io_context);
}

FileSystemRegistrar kAzureFileSystemRegistrar[]{
ARROW_REGISTER_FILESYSTEM("abfs", AzureFileSystemFactory, {}),
ARROW_REGISTER_FILESYSTEM("abfss", AzureFileSystemFactory, {}),
};

} // namespace arrow::fs
18 changes: 18 additions & 0 deletions cpp/src/arrow/filesystem/azurefs_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,24 @@ TEST(AzureFileSystem, InitializingFilesystemWithoutAccountNameFails) {
ASSERT_RAISES(Invalid, AzureFileSystem::Make(options));
}

TEST(AzureFileSystem, FileSystemFromUriRegistry) {
std::string path;
for (const auto& scheme : {"abfs", "abfss"}) {
ASSERT_OK_AND_ASSIGN(
auto fs, FileSystemFromUri(std::string(scheme) +
"://account.blob.core.windows.net/container/dir/"
"blob?credential_kind=anonymous",
&path));
EXPECT_EQ(fs->type_name(), "abfs");
EXPECT_EQ(path, "container/dir/blob");
}
EXPECT_RAISES_WITH_MESSAGE_THAT(
NotImplemented, ::testing::HasSubstr("Filesystem factory does not support"),
FileSystemFromUriAndOptions(
"abfs://account.blob.core.windows.net/container?credential_kind=anonymous",
{{"foo", std::string{"bar"}}}));
}

TEST(AzureFileSystem, InitializeWithDefaultCredential) {
AzureOptions options;
options.account_name = "dummy-account-name";
Expand Down
13 changes: 0 additions & 13 deletions cpp/src/arrow/filesystem/filesystem.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@
#include "arrow/util/config.h"

#include "arrow/filesystem/filesystem.h"
#ifdef ARROW_AZURE
# include "arrow/filesystem/azurefs.h"
#endif
#ifdef ARROW_HDFS
# include "arrow/filesystem/hdfs.h"
#endif
Expand Down Expand Up @@ -909,16 +906,6 @@ Result<std::shared_ptr<FileSystem>> FileSystemFromUriReal(
scheme, "', got ", options.size(), " option(s)");
}

if (scheme == "abfs" || scheme == "abfss") {
#ifdef ARROW_AZURE
ARROW_ASSIGN_OR_RAISE(auto options, AzureOptions::FromUri(uri, out_path));
return AzureFileSystem::Make(options, io_context);
#else
return Status::NotImplemented(
"Got Azure Blob File System URI but Arrow compiled without Azure Blob File "
"System support");
#endif
}
if (scheme == "hdfs" || scheme == "viewfs") {
#ifdef ARROW_HDFS
ARROW_ASSIGN_OR_RAISE(auto options, HdfsOptions::FromUri(uri));
Expand Down
Loading