Skip to content

Commit 3a795a4

Browse files
authored
Minor: Improve ObjectStoreUrl docs + examples (#10619)
1 parent 6167ce9 commit 3a795a4

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

datafusion/execution/src/object_store.rs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,32 @@ use object_store::ObjectStore;
2727
use std::sync::Arc;
2828
use url::Url;
2929

30-
/// A parsed URL identifying a particular [`ObjectStore`]
30+
/// A parsed URL identifying a particular [`ObjectStore`] instance
31+
///
32+
/// For example:
33+
/// * `file://` for local file system
34+
/// * `s3://bucket` for AWS S3 bucket
35+
/// * `oss://bucket` for Aliyun OSS bucket
3136
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
3237
pub struct ObjectStoreUrl {
3338
url: Url,
3439
}
3540

3641
impl ObjectStoreUrl {
3742
/// Parse an [`ObjectStoreUrl`] from a string
43+
///
44+
/// # Example
45+
/// ```
46+
/// # use url::Url;
47+
/// # use datafusion_execution::object_store::ObjectStoreUrl;
48+
/// let object_store_url = ObjectStoreUrl::parse("s3://bucket").unwrap();
49+
/// assert_eq!(object_store_url.as_str(), "s3://bucket/");
50+
/// // can also access the underlying `Url`
51+
/// let url: &Url = object_store_url.as_ref();
52+
/// assert_eq!(url.scheme(), "s3");
53+
/// assert_eq!(url.host_str(), Some("bucket"));
54+
/// assert_eq!(url.path(), "/");
55+
/// ```
3856
pub fn parse(s: impl AsRef<str>) -> Result<Self> {
3957
let mut parsed =
4058
Url::parse(s.as_ref()).map_err(|e| DataFusionError::External(Box::new(e)))?;

0 commit comments

Comments
 (0)