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 e387bdb  Ensure that RestCatalog passes user config to FileIO (#476)
e387bdb is described below

commit e387bdbbcc64837dd37ddd4a0f37dbad59c874b6
Author: Scott Donnelly <[email protected]>
AuthorDate: Tue Aug 20 02:50:36 2024 +0100

    Ensure that RestCatalog passes user config to FileIO (#476)
    
    * fix: ensure that RestCatalog passes user config to FileIO
    
    * docs: added some doc comments to clarify override order for config
---
 crates/catalog/rest/src/catalog.rs | 28 ++++++++++++++++++++++++++--
 1 file changed, 26 insertions(+), 2 deletions(-)

diff --git a/crates/catalog/rest/src/catalog.rs 
b/crates/catalog/rest/src/catalog.rs
index 2afefad..1181c3c 100644
--- a/crates/catalog/rest/src/catalog.rs
+++ b/crates/catalog/rest/src/catalog.rs
@@ -474,6 +474,11 @@ impl Catalog for RestCatalog {
     }
 
     /// Create a new table inside the namespace.
+    ///
+    /// In the resulting table, if there are any config properties that
+    /// are present in both the response from the REST server and the
+    /// config provided when creating this `RestCatalog` instance then
+    /// the value provided locally to the `RestCatalog` will take precedence.
     async fn create_table(
         &self,
         namespace: &NamespaceIdent,
@@ -512,8 +517,15 @@ impl Catalog for RestCatalog {
             .query::<LoadTableResponse, ErrorResponse, OK>(request)
             .await?;
 
+        let config = resp
+            .config
+            .unwrap_or_default()
+            .into_iter()
+            .chain(self.user_config.props.clone().into_iter())
+            .collect();
+
         let file_io = self
-            .load_file_io(resp.metadata_location.as_deref(), resp.config)
+            .load_file_io(resp.metadata_location.as_deref(), Some(config))
             .await?;
 
         Table::builder()
@@ -530,6 +542,11 @@ impl Catalog for RestCatalog {
     }
 
     /// Load table from the catalog.
+    ///
+    /// If there are any config properties that are present in
+    /// both the response from the REST server and the config provided
+    /// when creating this `RestCatalog` instance then the value
+    /// provided locally to the `RestCatalog` will take precedence.
     async fn load_table(&self, table: &TableIdent) -> Result<Table> {
         let request = self
             .context()
@@ -548,8 +565,15 @@ impl Catalog for RestCatalog {
             .query::<LoadTableResponse, ErrorResponse, OK>(request)
             .await?;
 
+        let config = resp
+            .config
+            .unwrap_or_default()
+            .into_iter()
+            .chain(self.user_config.props.clone().into_iter())
+            .collect();
+
         let file_io = self
-            .load_file_io(resp.metadata_location.as_deref(), resp.config)
+            .load_file_io(resp.metadata_location.as_deref(), Some(config))
             .await?;
 
         let table_builder = Table::builder()

Reply via email to