Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion datafusion/execution/src/object_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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`"
))
})
}
Expand Down
33 changes: 33 additions & 0 deletions datafusion/execution/src/runtime_env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These examples are run automatically via cargo test --doc -- so they need to be completely standlone

I took the liberty of pushing a commit to this PR that did so

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks so much for making these pass, I'll remember to run the doc tests next time, only looked at the doc site before submitting the PR.

/// // 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,
Expand Down