Skip to content
Merged
Prev Previous commit
Next Next commit
Minor documentation update.
  • Loading branch information
Omega359 committed Jul 10, 2024
commit 7d1bc09a1c20d8a2f7560032b5b29624b4fae164
4 changes: 2 additions & 2 deletions datafusion/core/src/execution/session_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -886,8 +886,8 @@ impl SessionStateBuilder {
}

/// Returns a new [SessionStateBuilder] based on an existing [SessionState]
/// The session id for the new builder will be reset to a unique value, all
/// other fields will be set to what is set in the provided session state
/// The session id for the new builder will be set to a unique value; all
/// other fields will be cloned from what is set in the provided session state
pub fn new_from_existing(existing: &SessionState) -> Self {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this clones SessionState anyways, I think it would make more sense for this to take the argument by value

Suggested change
pub fn new_from_existing(existing: &SessionState) -> Self {
pub fn new_from_existing(existing: SessionState) -> Self {

The rationale being there if the caller already has an owned SessionState they can use that and avoid a clone. This API basically requires them to do a clone

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In addition to this function, another nice to have UX feature would be a From impl, so users could do

let state: SessionState = get_existing_state();
let state = SessionStateBuilder::from(state)
  .with_optimizer_pass(Arc::new(MyNewOptimizer{}))
  .build()

let session_id = Uuid::new_v4().to_string();

Expand Down