Apache DataFusion SQL Query Engine
Docs: add examples for `RuntimeEnv::register_object_store`, improve error messages (#10617)
Adrian Tanase513d8d1d2afd
diff --git a/datafusion/execution/src/object_store.rs b/datafusion/execution/src/object_store.rsindex c0c58a87dc..126f83f7e2 100644--- a/datafusion/execution/src/object_store.rs+++ b/datafusion/execution/src/object_store.rs@@ -212,7 +212,7 @@ impl ObjectStoreRegistry for DefaultObjectStoreRegistry {.map(|o| o.value().clone()).ok_or_else(|| {DataFusionError::Internal(format!(- "No suitable object store found for {url}"+ "No suitable object store found for {url}. See `RuntimeEnv::register_object_store`"))})}diff --git a/datafusion/execution/src/runtime_env.rs b/datafusion/execution/src/runtime_env.rsindex e78a9e0de9..25573d9159 100644--- a/datafusion/execution/src/runtime_env.rs+++ b/datafusion/execution/src/runtime_env.rs@@ -89,6 +89,39 @@ impl RuntimeEnv {/// scheme, if any.////// See [`ObjectStoreRegistry`] for more details+ ///+ /// # Example: Register local file system object store+ /// ```+ /// # use std::sync::Arc;+ /// # use url::Url;+ /// # use datafusion_execution::runtime_env::RuntimeEnv;+ /// # let runtime_env = RuntimeEnv::new(Default::default()).unwrap();+ /// let url = Url::try_from("file://").unwrap();+ /// let object_store = object_store::local::LocalFileSystem::new();+ /// // register the object store with the runtime environment+ /// runtime_env.register_object_store(&url, Arc::new(object_store));+ /// ```+ ///+ /// # Example: Register local file system object store+ ///+ /// To register reading from urls such as <https://github.com>`+ ///+ /// ```+ /// # use std::sync::Arc;+ /// # use url::Url;+ /// # use datafusion_execution::runtime_env::RuntimeEnv;+ /// # let runtime_env = RuntimeEnv::new(Default::default()).unwrap();+ /// # // use local store for example as http feature is not enabled+ /// # let http_store = object_store::local::LocalFileSystem::new();+ /// // create a new object store via object_store::http::HttpBuilder;+ /// let base_url = Url::parse("https://github.com").unwrap();+ /// // let http_store = HttpBuilder::new()+ /// // .with_url(base_url.clone())+ /// // .build()+ /// // .unwrap();+ /// // register the object store with the runtime environment+ /// runtime_env.register_object_store(&base_url, Arc::new(http_store));+ /// ```pub fn register_object_store(&self,url: &Url,