diff --git a/datafusion/execution/src/object_store.rs b/datafusion/execution/src/object_store.rs index 7697c01d63f2..3ba21e399f93 100644 --- a/datafusion/execution/src/object_store.rs +++ b/datafusion/execution/src/object_store.rs @@ -27,7 +27,12 @@ use object_store::ObjectStore; use std::sync::Arc; use url::Url; -/// A parsed URL identifying a particular [`ObjectStore`] +/// A parsed URL identifying a particular [`ObjectStore`] instance +/// +/// For example: +/// * `file://` for local file system +/// * `s3://bucket` for AWS S3 bucket +/// * `oss://bucket` for Aliyun OSS bucket #[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct ObjectStoreUrl { url: Url, @@ -35,6 +40,19 @@ pub struct ObjectStoreUrl { impl ObjectStoreUrl { /// Parse an [`ObjectStoreUrl`] from a string + /// + /// # Example + /// ``` + /// # use url::Url; + /// # use datafusion_execution::object_store::ObjectStoreUrl; + /// let object_store_url = ObjectStoreUrl::parse("s3://bucket").unwrap(); + /// assert_eq!(object_store_url.as_str(), "s3://bucket/"); + /// // can also access the underlying `Url` + /// let url: &Url = object_store_url.as_ref(); + /// assert_eq!(url.scheme(), "s3"); + /// assert_eq!(url.host_str(), Some("bucket")); + /// assert_eq!(url.path(), "/"); + /// ``` pub fn parse(s: impl AsRef) -> Result { let mut parsed = Url::parse(s.as_ref()).map_err(|e| DataFusionError::External(Box::new(e)))?;