diff --git a/datafusion/core/src/execution/context/mod.rs b/datafusion/core/src/execution/context/mod.rs index 3455cce132b6..f20475df150b 100644 --- a/datafusion/core/src/execution/context/mod.rs +++ b/datafusion/core/src/execution/context/mod.rs @@ -391,8 +391,11 @@ impl SessionContext { current_catalog_list, Arc::clone(&factory) as Arc, )); + + let session_id = self.session_id.clone(); let ctx: SessionContext = self .into_state_builder() + .with_session_id(session_id) .with_catalog_list(catalog_list) .build() .into(); @@ -2222,6 +2225,16 @@ mod tests { assert_batches_eq!(expected, &result); Ok(()) } + #[test] + fn preserve_session_context_id() -> Result<()> { + let ctx = SessionContext::new(); + // it does make sense to preserve session id in this case + // as `enable_url_table()` can be seen as additional configuration + // option on ctx. + // some systems like datafusion ballista relies on stable session_id + assert_eq!(ctx.session_id(), ctx.enable_url_table().session_id()); + Ok(()) + } struct MyPhysicalPlanner {}