@@ -22,6 +22,7 @@ use datafusion::{
2222} ;
2323use datafusion_iceberg:: catalog:: catalog:: IcebergCatalog as DataFusionIcebergCatalog ;
2424use futures:: future:: join_all;
25+ use iceberg_rust:: catalog:: Catalog ;
2526use iceberg_rust:: object_store:: ObjectStoreBuilder ;
2627use iceberg_s3tables_catalog:: S3TablesCatalog ;
2728use object_store:: ObjectStore ;
@@ -155,9 +156,8 @@ impl EmbucketCatalogList {
155156 err
156157 ) ]
157158 pub async fn register_catalogs ( self : & Arc < Self > ) -> Result < ( ) > {
158- let mut all_catalogs = Vec :: new ( ) ;
159159 // Add metastore databases as catalogs
160- all_catalogs. extend ( self . internal_catalogs ( ) . await ?) ;
160+ let all_catalogs = self . metastore_catalogs ( ) . await ?;
161161 for catalog in all_catalogs {
162162 self . catalogs
163163 . insert ( catalog. name . clone ( ) , Arc :: new ( catalog) ) ;
@@ -171,7 +171,7 @@ impl EmbucketCatalogList {
171171 skip( self ) ,
172172 err
173173 ) ]
174- pub async fn internal_catalogs ( & self ) -> Result < Vec < CachingCatalog > > {
174+ pub async fn metastore_catalogs ( & self ) -> Result < Vec < CachingCatalog > > {
175175 let mut catalogs = Vec :: new ( ) ;
176176 let databases = self
177177 . metastore
@@ -198,19 +198,23 @@ impl EmbucketCatalogList {
198198 }
199199
200200 fn get_embucket_catalog ( & self , db : & RwObject < Database > ) -> Result < CachingCatalog > {
201- let iceberg_catalog = EmbucketIcebergCatalog :: new ( self . metastore . clone ( ) , db. ident . clone ( ) )
202- . context ( MetastoreSnafu ) ?;
203- let catalog: Arc < dyn CatalogProvider > = Arc :: new ( EmbucketCatalog :: new (
201+ let iceberg_catalog: Arc < dyn Catalog > = Arc :: new (
202+ EmbucketIcebergCatalog :: new ( self . metastore . clone ( ) , db. ident . clone ( ) )
203+ . context ( MetastoreSnafu ) ?,
204+ ) ;
205+ let catalog_provider: Arc < dyn CatalogProvider > = Arc :: new ( EmbucketCatalog :: new (
204206 db. ident . clone ( ) ,
205207 self . metastore . clone ( ) ,
206- Arc :: new ( iceberg_catalog) ,
208+ iceberg_catalog. clone ( ) ,
207209 ) ) ;
208- Ok ( CachingCatalog :: new ( catalog, db. ident . clone ( ) )
209- . with_refresh ( true )
210- . with_properties ( Properties {
211- created_at : db. created_at ,
212- updated_at : db. created_at ,
213- } ) )
210+ Ok (
211+ CachingCatalog :: new ( catalog_provider, db. ident . clone ( ) , Some ( iceberg_catalog) )
212+ . with_refresh ( true )
213+ . with_properties ( Properties {
214+ created_at : db. created_at ,
215+ updated_at : db. created_at ,
216+ } ) ,
217+ )
214218 }
215219
216220 #[ tracing:: instrument(
@@ -238,19 +242,23 @@ impl EmbucketCatalogList {
238242 . credentials_provider ( SharedCredentialsProvider :: new ( creds) )
239243 . region ( Region :: new ( volume. region ( ) ) )
240244 . build ( ) ;
241- let catalog = S3TablesCatalog :: new (
242- & config,
243- volume. arn . as_str ( ) ,
244- ObjectStoreBuilder :: S3 ( Box :: new ( volume. s3_builder ( ) ) ) ,
245- )
246- . context ( catalog_error:: S3TablesSnafu ) ?;
245+ let iceberg_catalog: Arc < dyn Catalog > = Arc :: new (
246+ S3TablesCatalog :: new (
247+ & config,
248+ volume. arn . as_str ( ) ,
249+ ObjectStoreBuilder :: S3 ( Box :: new ( volume. s3_builder ( ) ) ) ,
250+ )
251+ . context ( catalog_error:: S3TablesSnafu ) ?,
252+ ) ;
247253
248- let catalog = DataFusionIcebergCatalog :: new ( Arc :: new ( catalog ) , None )
254+ let catalog = DataFusionIcebergCatalog :: new ( iceberg_catalog . clone ( ) , None )
249255 . await
250256 . context ( catalog_error:: DataFusionSnafu ) ?;
251- Ok ( CachingCatalog :: new ( Arc :: new ( catalog) , name. to_string ( ) )
252- . with_refresh ( true )
253- . with_catalog_type ( CatalogType :: S3tables ) )
257+ Ok (
258+ CachingCatalog :: new ( Arc :: new ( catalog) , name. to_string ( ) , Some ( iceberg_catalog) )
259+ . with_refresh ( false )
260+ . with_catalog_type ( CatalogType :: S3tables ) ,
261+ )
254262 }
255263
256264 /// Do not keep returned references to avoid deadlocks
@@ -302,6 +310,7 @@ impl EmbucketCatalogList {
302310 schema : schema_provider,
303311 tables_cache : DashMap :: default ( ) ,
304312 name : schema. clone ( ) ,
313+ iceberg_catalog : catalog_ref. iceberg_catalog . clone ( ) ,
305314 } ;
306315 catalog_ref
307316 . schemas_cache
@@ -386,6 +395,7 @@ impl EmbucketCatalogList {
386395 schema : schema_provider,
387396 tables_cache : DashMap :: default ( ) ,
388397 name : schema. clone ( ) ,
398+ iceberg_catalog : catalog. iceberg_catalog . clone ( ) ,
389399 } ;
390400 let tables = schema. schema . table_names ( ) ;
391401
@@ -457,7 +467,7 @@ impl EmbucketCatalogList {
457467 let mut interval = interval ( Duration :: from_secs ( interval_secs) ) ;
458468 loop {
459469 interval. tick ( ) . await ;
460- match self . internal_catalogs ( ) . await {
470+ match self . metastore_catalogs ( ) . await {
461471 Ok ( catalogs) => {
462472 for catalog in catalogs {
463473 if self . catalogs . contains_key ( & catalog. name ) {
@@ -539,7 +549,7 @@ impl CatalogProviderList for EmbucketCatalogList {
539549 name : String ,
540550 catalog : Arc < dyn CatalogProvider > ,
541551 ) -> Option < Arc < dyn CatalogProvider > > {
542- let catalog = CachingCatalog :: new ( catalog, name) ;
552+ let catalog = CachingCatalog :: new ( catalog, name, None ) ;
543553 self . catalogs
544554 . insert ( catalog. name . clone ( ) , Arc :: new ( catalog) )
545555 . map ( |arc| {
0 commit comments