felipecrv commented on code in PR #39361:
URL: https://github.com/apache/arrow/pull/39361#discussion_r1442213883
##########
cpp/src/arrow/filesystem/azurefs.cc:
##########
@@ -1645,21 +1748,93 @@ Result<FileInfoVector>
AzureFileSystem::GetFileInfo(const FileSelector& select)
Status AzureFileSystem::CreateDir(const std::string& path, bool recursive) {
ARROW_ASSIGN_OR_RAISE(auto location, AzureLocation::FromString(path));
- if (recursive) {
- return impl_->CreateDirRecursive(location);
- } else {
- return impl_->CreateDir(location);
+ if (location.container.empty()) {
+ return Status::Invalid("CreateDir requires a non-empty path.");
}
+
+ auto container_client = impl_->GetBlobContainerClient(location.container);
+ if (location.path.empty()) {
+ // If the path is just the container, the parent (root) trivially exists,
+ // and the CreateDir operation comes down to just creating the container.
+ return CreateContainerIfNotExists(location.container, container_client);
+ }
+
+ auto adlfs_client = impl_->GetFileSystemClient(location.container);
+ ARROW_ASSIGN_OR_RAISE(auto hns_support,
+ impl_->HierarchicalNamespaceSupport(adlfs_client));
+ if (hns_support == HNSSupport::kContainerNotFound) {
+ if (!recursive) {
+ auto parent = location.parent();
+ return PathNotFound(parent);
+ }
+ RETURN_NOT_OK(CreateContainerIfNotExists(location.container,
container_client));
+ // Perform a second check for HNS support after creating the container.
+ ARROW_ASSIGN_OR_RAISE(hns_support,
impl_->HierarchicalNamespaceSupport(adlfs_client));
+ }
+ if (hns_support == HNSSupport::kContainerNotFound) {
+ // We only get kContainerNotFound if we are unable to read the properties
of the
+ // container we just created. This is very unlikely, but theoretically
possible in
+ // a concurrent system, so the error is handled to avoid infinite
recursion.
+ return Status::IOError("Unable to read properties of a newly created
container: ",
+ location.container, ": " +
container_client.GetUrl());
+ }
Review Comment:
Sure. Pushing soon.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]