Skip to content

Commit

Permalink
fix(iceberg): Handling options like "s3.region" (#16404)
Browse files Browse the repository at this point in the history
Signed-off-by: Xuanwo <github@xuanwo.io>
  • Loading branch information
Xuanwo authored Sep 6, 2024
1 parent a9a6630 commit 125cb42
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions src/query/storages/iceberg/src/catalog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,25 @@ impl IcebergCatalog {
),
};

// Trick
//
// Our parser doesn't allow users to write `s3.region` in options. Instead, users must use
// `"s3.region"`, but it's stored as is. We need to remove the quotes here.
//
// We only do this while building catalog so this won't affect existing catalogs.
let ctl: Arc<dyn iceberg::Catalog> = match opt {
IcebergCatalogOption::Hms(hms) => {
let cfg = HmsCatalogConfig::builder()
.address(hms.address.clone())
.thrift_transport(HmsThriftTransport::Buffered)
.warehouse(hms.warehouse.clone())
.props(hms.props.clone())
.props(
hms.props
.clone()
.into_iter()
.map(|(k, v)| (k.trim_matches('"').to_string(), v))
.collect(),
)
.build();
let ctl = HmsCatalog::new(cfg).map_err(|err| {
ErrorCode::BadArguments(format!("Iceberg build hms catalog failed: {err:?}"))
Expand All @@ -172,7 +184,13 @@ impl IcebergCatalog {
let cfg = RestCatalogConfig::builder()
.uri(rest.uri.clone())
.warehouse(rest.warehouse.clone())
.props(rest.props.clone())
.props(
rest.props
.clone()
.into_iter()
.map(|(k, v)| (k.trim_matches('"').to_string(), v))
.collect(),
)
.build();
let ctl = RestCatalog::new(cfg);
Arc::new(ctl)
Expand Down

0 comments on commit 125cb42

Please sign in to comment.