Skip to content

Commit f7bffb1

Browse files
authored
Support identifier warehouses (#308)
* Support identifier warehouses This is a bit confusing if you come from a Hive background where the warehouse is always a path to hdfs/s3/etc. With the REST catalog, the warehouse can also be a logical identifier: https://github.com/apache/iceberg/blob/main/open-api/rest-catalog-open-api.yaml#L72-L78 This means that we have to make sure that we only parse paths that are an actual path, and not an identifier. I'm open to suggestions. The check is now very simple, but can be extended for example using a regex. But I'm not sure what the implications are of importing additional packages (in Python you want to keep it as lightweight as possible). * Use `if Url::parse().is_ok()`
1 parent 301a0af commit f7bffb1

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

crates/catalog/rest/src/catalog.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use std::str::FromStr;
2323
use async_trait::async_trait;
2424
use itertools::Itertools;
2525
use reqwest::header::{self, HeaderMap, HeaderName, HeaderValue};
26-
use reqwest::{Client, Request, Response, StatusCode};
26+
use reqwest::{Client, Request, Response, StatusCode, Url};
2727
use serde::de::DeserializeOwned;
2828
use typed_builder::TypedBuilder;
2929
use urlencoding::encode;
@@ -650,7 +650,15 @@ impl RestCatalog {
650650
props.extend(config);
651651
}
652652

653-
let file_io = match self.config.warehouse.as_deref().or(metadata_location) {
653+
// If the warehouse is a logical identifier instead of a URL we don't want
654+
// to raise an exception
655+
let warehouse_path = match self.config.warehouse.as_deref() {
656+
Some(url) if Url::parse(url).is_ok() => Some(url),
657+
Some(_) => None,
658+
None => None,
659+
};
660+
661+
let file_io = match warehouse_path.or(metadata_location) {
654662
Some(url) => FileIO::from_path(url)?.with_props(props).build()?,
655663
None => {
656664
return Err(Error::new(

0 commit comments

Comments
 (0)