MCPcopy Create free account
hub / github.com/apache/datafusion / parse

Method parse

datafusion/execution/src/object_store.rs:58–72  ·  view source on GitHub ↗

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(), So

(s: impl AsRef<str>)

Source from the content-addressed store, hash-verified

56 /// assert_eq!(url.path(), "/");
57 /// ```
58 pub fn parse(s: impl AsRef<str>) -> Result<Self> {
59 let mut parsed =
60 Url::parse(s.as_ref()).map_err(|e| DataFusionError::External(Box::new(e)))?;
61
62 let remaining = &parsed[url::Position::BeforePath..];
63 if !remaining.is_empty() && remaining != "/" {
64 return exec_err!(
65 "ObjectStoreUrl must only contain scheme and authority, got: {remaining}"
66 );
67 }
68
69 // Always set path for consistency
70 parsed.set_path("/");
71 Ok(Self { url: parsed })
72 }
73
74 /// An [`ObjectStoreUrl`] for the local filesystem (`file://`)
75 ///

Callers

nothing calls this directly

Calls 3

newFunction · 0.85
as_refMethod · 0.45
is_emptyMethod · 0.45

Tested by

no test coverage detected