GitHub user chitralverma added a comment to the discussion: [Feature Request] 
Support creating operator from resource URI

@Xuanwo @frostming , currently I'm using something like this over a typical 
`Url` as a naive hack. I believe something more sophisticated can be added on 
similar lines?

FYI, link to something similar that object_store does - 
[link](https://github.com/apache/arrow-rs/blob/7355e8392d6e82c28cc54236d79b4dc56d7226d4/object_store/src/parse.rs#L71C9-L71C9)

```
    pub fn infer_operator(&self, opts: HashMap<String, String>) -> 
Result<Operator, Error> {
        let mut _opts = opts;

        let scheme = match (self.url.scheme(), self.url.host_str()) {
            ("file", None) => Scheme::Fs,
            ("az", _) => Scheme::Azblob,
            ("adl" | "adls" | "abfs" | "abfss" | "azdfs" | "azdls", _) => 
Scheme::Azdfs,
            ("s3" | "s3a", Some(bucket)) => {
                _opts.insert("bucket".to_string(), bucket.to_string());
                Scheme::S3
            }
            ("gs", Some(bucket)) => {
                _opts.insert("bucket".to_string(), bucket.to_string());
                Scheme::Gcs
            }
            (scheme, _) => {
                return Err(OpenDalError::new(
                    OpenDalErrorKind::Unsupported,
                    format!("Unable to recognise URL with scheme 
\"{scheme}\"",).as_str(),
                )
                .into());
            } 
        };
```

GitHub link: 
https://github.com/apache/incubator-opendal/discussions/1494#discussioncomment-7014631

----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to: [email protected]

Reply via email to