diff --git a/datafusion/src/datasource/object_store/local.rs b/datafusion/src/datasource/object_store/local.rs index d46be4a5c5b7..edfe5e2cecd6 100644 --- a/datafusion/src/datasource/object_store/local.rs +++ b/datafusion/src/datasource/object_store/local.rs @@ -39,6 +39,11 @@ pub struct LocalFileSystem; #[async_trait] impl ObjectStore for LocalFileSystem { async fn list_file(&self, prefix: &str) -> Result { + let prefix = if let Some((_scheme, path)) = prefix.split_once("://") { + path + } else { + prefix + }; list_all(prefix.to_owned()).await } diff --git a/datafusion/src/datasource/object_store/mod.rs b/datafusion/src/datasource/object_store/mod.rs index 24bdaab55a50..aad70e70a308 100644 --- a/datafusion/src/datasource/object_store/mod.rs +++ b/datafusion/src/datasource/object_store/mod.rs @@ -220,13 +220,12 @@ impl ObjectStoreRegistry { /// Get a suitable store for the URI based on it's scheme. For example: /// - URI with scheme `file://` or no schema will return the default LocalFS store /// - URI with scheme `s3://` will return the S3 store if it's registered - /// Returns a tuple with the store and the path of the file in that store - /// (URI=scheme://path). + /// Returns a tuple with the store and the self-described uri of the file in that store pub fn get_by_uri<'a>( &self, uri: &'a str, ) -> Result<(Arc, &'a str)> { - if let Some((scheme, path)) = uri.split_once("://") { + if let Some((scheme, _path)) = uri.split_once("://") { let stores = self.object_stores.read(); let store = stores .get(&*scheme.to_lowercase()) @@ -237,7 +236,7 @@ impl ObjectStoreRegistry { scheme )) })?; - Ok((store, path)) + Ok((store, uri)) } else { Ok((Arc::new(LocalFileSystem), uri)) }