-
Notifications
You must be signed in to change notification settings - Fork 1.8k
chore: Update SessionStateBuilder::with_default_features does not replace existing features
#14935
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this @irenjj -- I am not 100% sure about this implementation; let me know what you think
cc @milenkovicm
| expr_planners: Vec<Arc<dyn ExprPlanner>>, | ||
| ) -> Self { | ||
| self.expr_planners = Some(expr_planners); | ||
| if self.expr_planners.is_none() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By putting these checks here I think the API will be quite confusing to use -- it means that calling with_expr_planners and the other methods below will only set the fields if there is no existing field set and silently ignore the argument if there is already planners specified
| /// scalar, aggregate and windows functions. | ||
| /// For each setter method call, default values will only be created and set if the corresponding | ||
| /// field is currently None, otherwise the existing value will be preserved. | ||
| pub fn with_default_features(self) -> Self { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @irenjj
I thought the idea was that with_default_features would be additive to the existing set of features
That is, instead of replacing any existing factors/formats/etc this methods would append the default features
So instead of
self.with_table_factories(SessionStateDefaults::default_table_factories())Something more like
let mut table_factories = self.with_table_factories.take().unwrap_or_default();
table_factories.extend(SessionStateDefaults::default_table_factories())
self.table_factories = Some(table_factories)🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the suggestion. I think the second approach is more suitable.
|
I just wonder if we should provide |
alamb
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @irenjj -- I think this makes a lot of sense to me
I just wonder if we should provide with_default_features or Default::default implementation for this case as well? wdyt @alamb ?
@milenkovicm I think the usecase of not automatically registering all the default features is to allow creating a SessionState without the defaults (e.g. if you don't want to defaults).
Since there is no method like SessionStateBuilder::clear I am not sure how else one would accomplish this usecase 🤔
than makes sense, what I suggest is to keep all (new) methods as they are just provide new method which will create new with defaults. but I don't have strong opinion about it |
with_default_features override existing informationSessionStateBuilder::with_default_features does not replace existing features
|
I also made a small PR to try and clarify the docs: |
Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
|
|
Thanks again @irenjj and @milenkovicm It seems as if @shruti2522 already has a PR to implement the new_with_default_features 🎉 |
Which issue does this PR close?
SessionStateBuilder::with_default_featuresergonomics #14899Rationale for this change
What changes are included in this PR?
Are these changes tested?
Are there any user-facing changes?