@@ -107,6 +107,9 @@ impl SqlCatalog {
107107 object_store : self . object_store . clone ( ) ,
108108 } )
109109 }
110+ fn default_object_store ( & self , bucket : Bucket ) -> Arc < dyn object_store:: ObjectStore > {
111+ Arc :: new ( self . object_store . build ( bucket) . unwrap ( ) )
112+ }
110113}
111114
112115#[ derive( Debug ) ]
@@ -281,7 +284,7 @@ impl Catalog for SqlCatalog {
281284 } ;
282285
283286 let bucket = Bucket :: from_path ( & path) ?;
284- let object_store = self . object_store ( bucket) ;
287+ let object_store = self . default_object_store ( bucket) ;
285288
286289 let bytes = object_store
287290 . get ( & strip_prefix ( & path) . as_str ( ) . into ( ) )
@@ -317,7 +320,7 @@ impl Catalog for SqlCatalog {
317320
318321 // Write metadata to object_store
319322 let bucket = Bucket :: from_path ( & location) ?;
320- let object_store = self . object_store ( bucket) ;
323+ let object_store = self . default_object_store ( bucket) ;
321324
322325 let metadata_location = new_metadata_location ( & metadata) ;
323326 object_store
@@ -351,7 +354,7 @@ impl Catalog for SqlCatalog {
351354
352355 // Write metadata to object_store
353356 let bucket = Bucket :: from_path ( & location) ?;
354- let object_store = self . object_store ( bucket) ;
357+ let object_store = self . default_object_store ( bucket) ;
355358
356359 let metadata_location = new_metadata_location ( & metadata) ;
357360 object_store
@@ -387,7 +390,7 @@ impl Catalog for SqlCatalog {
387390
388391 // Write metadata to object_store
389392 let bucket = Bucket :: from_path ( & location) ?;
390- let object_store = self . object_store ( bucket) ;
393+ let object_store = self . default_object_store ( bucket) ;
391394
392395 let metadata_location = new_metadata_location ( & metadata) ;
393396
@@ -443,7 +446,7 @@ impl Catalog for SqlCatalog {
443446 let ( previous_metadata_location, metadata) = entry;
444447
445448 let bucket = Bucket :: from_path ( & previous_metadata_location) ?;
446- let object_store = self . object_store ( bucket) ;
449+ let object_store = self . default_object_store ( bucket) ;
447450
448451 let TabularMetadata :: Table ( mut metadata) = metadata else {
449452 return Err ( IcebergError :: InvalidFormat (
@@ -491,7 +494,7 @@ impl Catalog for SqlCatalog {
491494 let ( previous_metadata_location, mut metadata) = entry;
492495
493496 let bucket = Bucket :: from_path ( & previous_metadata_location) ?;
494- let object_store = self . object_store ( bucket) ;
497+ let object_store = self . default_object_store ( bucket) ;
495498
496499 let metadata_location = match & mut metadata {
497500 TabularMetadata :: View ( metadata) => {
@@ -546,7 +549,7 @@ impl Catalog for SqlCatalog {
546549 let ( previous_metadata_location, mut metadata) = entry;
547550
548551 let bucket = Bucket :: from_path ( & previous_metadata_location) ?;
549- let object_store = self . object_store ( bucket) ;
552+ let object_store = self . default_object_store ( bucket) ;
550553
551554 let metadata_location = match & mut metadata {
552555 TabularMetadata :: MaterializedView ( metadata) => {
@@ -596,7 +599,7 @@ impl Catalog for SqlCatalog {
596599 metadata_location : & str ,
597600 ) -> Result < Table , IcebergError > {
598601 let bucket = Bucket :: from_path ( metadata_location) ?;
599- let object_store = self . object_store ( bucket) ;
602+ let object_store = self . default_object_store ( bucket) ;
600603
601604 let metadata: TableMetadata = serde_json:: from_slice (
602605 & object_store
@@ -620,10 +623,6 @@ impl Catalog for SqlCatalog {
620623 ) ;
621624 Ok ( Table :: new ( identifier. clone ( ) , self . clone ( ) , metadata) . await ?)
622625 }
623-
624- fn object_store ( & self , bucket : Bucket ) -> Arc < dyn object_store:: ObjectStore > {
625- Arc :: new ( self . object_store . build ( bucket) . unwrap ( ) )
626- }
627626}
628627
629628impl SqlCatalog {
@@ -937,8 +936,8 @@ pub mod tests {
937936
938937 assert ! ( once) ;
939938
940- let object_store =
941- iceberg_catalog . object_store ( iceberg_rust:: object_store:: Bucket :: S3 ( "warehouse" ) ) ;
939+ let object_store = iceberg_catalog
940+ . default_object_store ( iceberg_rust:: object_store:: Bucket :: S3 ( "warehouse" ) ) ;
942941
943942 let version_hint = object_store
944943 . get ( & strip_prefix ( "s3://warehouse/tpch/lineitem/metadata/version-hint.text" ) . into ( ) )
0 commit comments