Skip to content

Apache DataFusion SQL Query Engine

add method SessionStateBuilder::new_with_default_features() (#14998)

Shruti Sharmac0d53adf8323
diff --git a/datafusion/core/src/execution/session_state.rs b/datafusion/core/src/execution/session_state.rs
index 2ec1ba07b9..d26d5a219e 100644
--- a/datafusion/core/src/execution/session_state.rs
+++ b/datafusion/core/src/execution/session_state.rs
@@ -1023,6 +1023,9 @@ impl SessionStateBuilder {
///
/// See [`Self::with_default_features`] to install the default set of functions,
/// catalogs, etc.
+ ///
+ /// To create a `SessionStateBuilder` with default features such as functions,
+ /// please see [`Self::new_with_default_features`].
pub fn new() -> Self {
Self {
session_id: None,
@@ -1144,6 +1147,22 @@ impl SessionStateBuilder {
self
}
+ /// Returns a new [`SessionStateBuilder`] with default features.
+ ///
+ /// This is equivalent to calling [`Self::new()`] followed by [`Self::with_default_features()`].
+ ///
+ /// ```
+ /// use datafusion::execution::session_state::SessionStateBuilder;
+ ///
+ /// // Create a new SessionState with default features
+ /// let session_state = SessionStateBuilder::new_with_default_features()
+ /// .with_session_id("my_session".to_string())
+ /// .build();
+ /// ```
+ pub fn new_with_default_features() -> Self {
+ Self::new().with_default_features()
+ }
+
/// Set the session id.
pub fn with_session_id(mut self, session_id: String) -> Self {
self.session_id = Some(session_id);