Skip to content

Conversation

@shruti2522
Copy link
Contributor

Which issue does this PR close?

Rationale for this change

What changes are included in this PR?

added method new_with_defaults to StreamStateBuilder

Are these changes tested?

Are there any user-facing changes?

@github-actions github-actions bot added the core Core DataFusion crate label Mar 4, 2025
@berkaysynnada
Copy link
Contributor

Why don't we just implement Default trait?

@alamb
Copy link
Contributor

alamb commented Mar 4, 2025

Why don't we just implement Default trait?

There is some more backstory here:

Basically the question is what "defaults" means -- is default an empty builder or does it have all the default functions, etc.

An alternate design might be to always create SessionStateBuilder with all default functions and have a clear() method or something to reset the state.

Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

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

Thank you @shruti2522 -- this looks great. I think we just need to improve the name and it will be good to go (assuming it is ok with @berkaysynnada and other reviewers)

Could you also add a comment to SessionStateBuilder::new() here:

/// Returns a new empty [`SessionStateBuilder`].
///
/// See [`Self::with_default_features`] to install the default set of functions,
/// catalogs, etc.

Something like "to create a SessionStateBuilder with default features such as functions please see [SessionStateBuilder::new_with_default_features}

/// .with_session_id("my_session".to_string())
/// .build();
/// ```
pub fn new_with_defaults() -> Self {
Copy link
Contributor

Choose a reason for hiding this comment

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

To keep the name consistent (and make it harder to confuse this with default()) could we please name this default_features? Like:

Suggested change
pub fn new_with_defaults() -> Self {
pub fn new_with_default_features() -> Self {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done @alamb

@shruti2522 shruti2522 changed the title add method SessionStateBuilder::new_with_defaults() add method SessionStateBuilder::new_with_default_features() Mar 4, 2025
Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

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

Thanks @shruti2522

@alamb alamb changed the title add method SessionStateBuilder::new_with_default_features() Minor: add method SessionStateBuilder::new_with_default_features() Mar 5, 2025
@alamb alamb merged commit c0d53ad into apache:main Mar 5, 2025
24 checks passed
danila-b pushed a commit to danila-b/datafusion that referenced this pull request Mar 8, 2025
…4998)

* add func SessionStateBuilder::new_with_defaults()

* update name

* add comment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Core DataFusion crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add method to SessionStateBuilder that has all the defaut features

3 participants