MisterRaindrop commented on code in PR #703:
URL: https://github.com/apache/iceberg-cpp/pull/703#discussion_r3372473240


##########
src/iceberg/arrow/arrow_io.cc:
##########
@@ -473,11 +473,26 @@ class ArrowOutputFile : public OutputFile {
 }  // namespace
 
 Result<std::string> ArrowFileSystemFileIO::ResolvePath(const std::string& 
file_location) {
-  if (file_location.find("://") != std::string::npos) {
-    ICEBERG_ARROW_ASSIGN_OR_RETURN(auto path, 
arrow_fs_->PathFromUri(file_location));
-    return path;
+  const auto pos = file_location.find("://");
+  if (pos == std::string::npos) {
+    return file_location;
   }
-  return file_location;
+
+  auto path = arrow_fs_->PathFromUri(file_location);
+  if (path.ok()) {
+    return std::move(path).ValueOrDie();
+  }
+
+  // Only fall back for Arrow's scheme-mismatch error; propagate anything else.
+  const auto& status = path.status();
+  if (status.message().find("expected a URI with one of the schemes") ==
+      std::string::npos) {
+    return std::unexpected<Error>{
+        {.kind = ToErrorKind(status), .message = status.ToString()}};
+  }
+  // Scheme-less bucket/key, dropping any ?query / #fragment.
+  std::string bucket_key = file_location.substr(pos + 3);
+  return bucket_key.substr(0, bucket_key.find_first_of("?#"));

Review Comment:
   One subtle concern: s3:// and s3a:// currently use different parsing 
semantics. s3:// goes through Arrow's PathFromUri, while s3a/s3n use the 
fallback substring parser. This means percent-encoded keys may resolve 
differently.
   example:
   s3://bucket/a%20b   -> Arrow PathFromUri -> bucket/a b
     s3a://bucket/a%20b  -> fallback          -> bucket/a%20b



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to