westonpace commented on code in PR #14974:
URL: https://github.com/apache/arrow/pull/14974#discussion_r1050139903


##########
cpp/src/arrow/util/uri.cc:
##########
@@ -306,14 +311,29 @@ Status Uri::Parse(const std::string& uri_string) {
   return Status::OK();
 }
 
-std::string UriFromAbsolutePath(const std::string& path) {
+Result<std::string> UriFromAbsolutePath(const std::string_view& path) {
+  if (path.empty()) {
+    return Status::Invalid(
+        "UriFromAbsolutePath expected an absolute path, got an empty string");
+  }
+  std::string out;
 #ifdef _WIN32
-  // Path is supposed to start with "X:/..."
-  return "file:///" + path;
+  // Turn "/" separators into "\", as Windows recognizes both but uriparser
+  // only the latter.
+  std::string fixed_path(path);
+  std::replace(fixed_path.begin(), fixed_path.end(), '/', '\\');
+  out.resize(8 + 3 * fixed_path.length() + 1);

Review Comment:
   Minor nit: Maybe a comment explaining this math?  Probably not needed if 
this is a normal Windows thing.



##########
cpp/src/arrow/util/uri.cc:
##########
@@ -58,10 +59,10 @@ bool IsDriveSpec(const std::string_view s) {
 
 }  // namespace
 
-std::string UriEscape(const std::string& s) {
+std::string UriEscape(const std::string_view& s) {

Review Comment:
   Minor nit: I think we've been preferring to pass `string_view` by value in 
Substrait per 
https://quuxplusone.github.io/blog/2021/11/09/pass-string-view-by-value/ and 
@bkietz 's advice



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

Reply via email to