drin commented on code in PR #14071:
URL: https://github.com/apache/arrow/pull/14071#discussion_r983929261


##########
cpp/src/arrow/engine/substrait/relation_internal.cc:
##########
@@ -212,43 +204,102 @@ Result<DeclarationInfo> FromProto(const substrait::Rel& 
rel, const ExtensionSet&
               "non-default 
substrait::ReadRel::LocalFiles::FileOrFiles::length");
         }
 
-        path = path.substr(7);
+        // Extract and parse the read relation's source URI
+        ::arrow::internal::Uri item_uri;
         switch (item.path_type_case()) {
-          case substrait::ReadRel::LocalFiles::FileOrFiles::kUriPath: {
-            ARROW_ASSIGN_OR_RAISE(auto file, filesystem->GetFileInfo(path));
-            if (file.type() == fs::FileType::File) {
-              files.push_back(std::move(file));
-            } else if (file.type() == fs::FileType::Directory) {
-              fs::FileSelector selector;
-              selector.base_dir = path;
-              selector.recursive = true;
-              ARROW_ASSIGN_OR_RAISE(auto discovered_files,
-                                    filesystem->GetFileInfo(selector));
-              std::move(files.begin(), files.end(), 
std::back_inserter(discovered_files));
-            }
+          case substrait::ReadRel::LocalFiles::FileOrFiles::kUriPath:
+            RETURN_NOT_OK(item_uri.Parse(item.uri_path()));
             break;
-          }
+
+          case substrait::ReadRel::LocalFiles::FileOrFiles::kUriFile:
+            RETURN_NOT_OK(item_uri.Parse(item.uri_file()));
+            break;
+
+          case substrait::ReadRel::LocalFiles::FileOrFiles::kUriFolder:
+            RETURN_NOT_OK(item_uri.Parse(item.uri_folder()));
+            break;
+
+          default:
+            RETURN_NOT_OK(item_uri.Parse(item.uri_path_glob()));
+            break;
+        }
+
+        // Validate the URI before processing
+        if (!item_uri.is_file_scheme()) {
+          return Status::NotImplemented("substrait::ReadRel::LocalFiles item 
(",
+                                        item_uri.ToString(),
+                                        ") with non-filesystem scheme 
(file:///)");

Review Comment:
   I changed `with non-file scheme` to `does not have file scheme`  so that 
it's also clear that the `(file://)` portion part *is* a file scheme (just 
fixing grammar ambiguity)



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