Parse a provided string as a `ListingTableUrl` A URL can either refer to a single object, or a collection of objects with a common prefix, with the presence of a trailing `/` indicating a collection. For example, `file:///foo.txt` refers to the file at `/foo.txt`, whereas `file:///foo/` refers to all the files under the directory `/foo` and its subdirectories. Similarly `s3://BUCKET/blob.csv` r
(s: impl AsRef<str>)
| 104 | /// [file URI]: https://en.wikipedia.org/wiki/File_URI_scheme |
| 105 | /// [URL]: https://url.spec.whatwg.org/ |
| 106 | pub fn parse(s: impl AsRef<str>) -> Result<Self> { |
| 107 | let s = s.as_ref(); |
| 108 | |
| 109 | // This is necessary to handle the case of a path starting with a drive letter |
| 110 | #[cfg(not(target_arch = "wasm32"))] |
| 111 | if std::path::Path::new(s).is_absolute() { |
| 112 | return Self::parse_path(s); |
| 113 | } |
| 114 | |
| 115 | match Url::parse(s) { |
| 116 | Ok(url) => Self::try_new(url, None), |
| 117 | #[cfg(not(target_arch = "wasm32"))] |
| 118 | Err(url::ParseError::RelativeUrlWithoutBase) => Self::parse_path(s), |
| 119 | Err(e) => Err(DataFusionError::External(Box::new(e))), |
| 120 | } |
| 121 | } |
| 122 | |
| 123 | /// Creates a new [`ListingTableUrl`] interpreting `s` as a filesystem path |
| 124 | #[cfg(not(target_arch = "wasm32"))] |