alamb commented on code in PR #2906:
URL: https://github.com/apache/arrow-datafusion/pull/2906#discussion_r922320602


##########
datafusion/core/src/datasource/object_store.rs:
##########
@@ -132,19 +149,51 @@ impl ObjectStoreRegistry {
     ///
     /// - URL with scheme `file:///` or no schema will return the default 
LocalFS store
     /// - URL with scheme `s3://bucket/` will return the S3 store if it's 
registered
+    /// - URL with scheme `hdfs://hostname:port` will return the hdfs store if 
it's registered
     ///
     pub fn get_by_url(&self, url: impl AsRef<Url>) -> Result<Arc<dyn 
ObjectStore>> {
         let url = url.as_ref();
-        let s = &url[url::Position::BeforeScheme..url::Position::AfterHost];
-        let stores = self.object_stores.read();
-        let store = stores.get(s).ok_or_else(|| {
-            DataFusionError::Internal(format!(
-                "No suitable object store found for {}",
-                url
-            ))
-        })?;
-
-        Ok(store.clone())
+        // First check whether can get object store from registry
+        let store = {
+            let stores = self.object_stores.read();
+            let s = 
&url[url::Position::BeforeScheme..url::Position::BeforeHost];

Review Comment:
   What I don't like about the current code is that it is hard to concisely 
explain how urls are resolved as various parts of the URL are tried in a 
sequence that I find confusing. 
   
   I guess I was thinking that we could keep the logic in DataFusion simple,  
Ballista or some other system could implement whatever arbitrary logic was 
needed in its implementation of the detector. If the detector wanted to first 
try the registered object stores it could do so.  



-- 
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: github-unsubscr...@arrow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to