This is an automated email from the ASF dual-hosted git repository.
liurenjie1024 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/iceberg-rust.git
The following commit(s) were added to refs/heads/main by this push:
new 3dcb3a9 feat: support uri redirect in rest client (#310)
3dcb3a9 is described below
commit 3dcb3a9d91d6ed30f0b74a9ff2acdbbb561ac17f
Author: TennyZhuang <[email protected]>
AuthorDate: Wed Apr 3 09:12:28 2024 +0800
feat: support uri redirect in rest client (#310)
Signed-off-by: TennyZhuang <[email protected]>
---
crates/catalog/rest/src/catalog.rs | 30 ++++++++++++++++++++----------
1 file changed, 20 insertions(+), 10 deletions(-)
diff --git a/crates/catalog/rest/src/catalog.rs
b/crates/catalog/rest/src/catalog.rs
index 85996f8..e7c773c 100644
--- a/crates/catalog/rest/src/catalog.rs
+++ b/crates/catalog/rest/src/catalog.rs
@@ -623,13 +623,16 @@ impl RestCatalog {
request = request.query(&[("warehouse", warehouse_location)]);
}
- let config = self
+ let mut config = self
.client
.query::<CatalogConfig, ErrorResponse, OK>(request.build()?)
.await?;
let mut props = config.defaults;
props.extend(self.config.props.clone());
+ if let Some(uri) = config.overrides.remove("uri") {
+ self.config.uri = uri;
+ }
props.extend(config.overrides);
self.config.props = props;
@@ -845,6 +848,7 @@ mod tests {
};
use iceberg::transaction::Transaction;
use mockito::{Mock, Server, ServerGuard};
+ use serde_json::json;
use std::fs::File;
use std::io::BufReader;
use std::sync::Arc;
@@ -1097,25 +1101,31 @@ mod tests {
}
#[tokio::test]
- async fn test_config_override_prefix() {
+ async fn test_config_override() {
let mut server = Server::new_async().await;
+ let mut redirect_server = Server::new_async().await;
+ let new_uri = redirect_server.url();
let config_mock = server
.mock("GET", "/v1/config")
.with_status(200)
.with_body(
- r#"{
- "overrides": {
- "warehouse": "s3://iceberg-catalog",
- "prefix": "ice/warehouses/my"
- },
- "defaults": {}
- }"#,
+ json!(
+ {
+ "overrides": {
+ "uri": new_uri,
+ "warehouse": "s3://iceberg-catalog",
+ "prefix": "ice/warehouses/my"
+ },
+ "defaults": {},
+ }
+ )
+ .to_string(),
)
.create_async()
.await;
- let list_ns_mock = server
+ let list_ns_mock = redirect_server
.mock("GET", "/v1/ice/warehouses/my/namespaces")
.with_body(
r#"{