Skip to content

Commit f621431

Browse files
committed
session state: allow to set None as catalog in builder
It is useful when there is need to create builder based on the existing state but hide the catalog list.
1 parent 43aa441 commit f621431

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

datafusion/core/src/execution/context/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ impl SessionContext {
397397
Arc::clone(&factory) as Arc<dyn UrlTableFactory>,
398398
));
399399
let new_state = SessionStateBuilder::new_from_existing(self.state())
400-
.with_catalog_list(catalog_list)
400+
.with_catalog_list(Some(catalog_list))
401401
.build();
402402
let ctx = SessionContext::new_with_state(new_state);
403403
factory.session_store().with_state(ctx.state_weak_ref());

datafusion/core/src/execution/session_state.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ impl SessionState {
280280
SessionStateBuilder::new()
281281
.with_config(config)
282282
.with_runtime_env(runtime)
283-
.with_catalog_list(catalog_list)
283+
.with_catalog_list(Some(catalog_list))
284284
.with_default_features()
285285
.build()
286286
}
@@ -296,7 +296,7 @@ impl SessionState {
296296
SessionStateBuilder::new()
297297
.with_config(config)
298298
.with_runtime_env(runtime)
299-
.with_catalog_list(catalog_list)
299+
.with_catalog_list(Some(catalog_list))
300300
.with_default_features()
301301
.build()
302302
}
@@ -1140,9 +1140,9 @@ impl SessionStateBuilder {
11401140
/// Set the [`CatalogProviderList`]
11411141
pub fn with_catalog_list(
11421142
mut self,
1143-
catalog_list: Arc<dyn CatalogProviderList>,
1143+
catalog_list: Option<Arc<dyn CatalogProviderList>>,
11441144
) -> Self {
1145-
self.catalog_list = Some(catalog_list);
1145+
self.catalog_list = catalog_list;
11461146
self
11471147
}
11481148

@@ -1876,7 +1876,7 @@ mod tests {
18761876
let table = MemTable::try_new(batch.schema(), vec![vec![batch]])?;
18771877

18781878
let session_state = SessionStateBuilder::new()
1879-
.with_catalog_list(Arc::new(MemoryCatalogProviderList::new()))
1879+
.with_catalog_list(Some(Arc::new(MemoryCatalogProviderList::new())))
18801880
.build();
18811881
let table_ref = session_state.resolve_table_ref("employee").to_string();
18821882
session_state

0 commit comments

Comments
 (0)