Skip to content

Conversation

@alamb
Copy link
Contributor

@alamb alamb commented Sep 23, 2023

Which issue does this PR close?

N/A

Rationale for this change

The names for creating SessionContext and SessionState are inconsistent, which has bothered me for a long time.

It is confusing that SessionContext::with_config_rt creates a new SessionContext while most methods in DataFusion that start with with are used to update a field.

This is a small papercut but I think it makes DataFusion that much harder to use / embed as it doesn't follow existing Rust Idioms

What changes are included in this PR?

  1. Add a new prefix to SessionContext::with_config_rt and related functions so they are called SessionContext::new_with_config_from_rt
  2. Add deprecation notes for the old names
  3. Remove default_session_builder which was deprecated almost 10 releases ago

Are these changes tested?

Existing tests

Are there any user-facing changes?

@alamb alamb marked this pull request as draft September 23, 2023 11:10
@github-actions github-actions bot added core Core DataFusion crate sqllogictest SQL Logic Tests (.slt) substrait Changes to the substrait crate labels Sep 23, 2023
@alamb alamb marked this pull request as ready for review September 25, 2023 18:54
Copy link
Member

@Weijun-H Weijun-H left a comment

Choose a reason for hiding this comment

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

LGTM 👍

Copy link
Contributor

@comphead comphead left a comment

Choose a reason for hiding this comment

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

LGTM
Probably we can also consider create_ instead of new_ to be more like Factory method pattern
https://en.wikipedia.org/wiki/Factory_method_pattern#UML_class_diagram

Thanks for supporting old and new method names to provide backward compatibility with downstream

Copy link
Contributor Author

@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 @viirya @comphead and @Weijun-H

@alamb alamb merged commit f16bc8b into apache:main Oct 4, 2023
Ted-Jiang pushed a commit to Ted-Jiang/arrow-datafusion that referenced this pull request Oct 7, 2023
…config_from_rt`, etc (apache#7631)

* Rename `SessionContext::with_config_rt` to `SessionContext::new_with_config_from_rt`, etc

* update other references

* Apply suggestions from code review

Co-authored-by: Liang-Chi Hsieh <[email protected]>

---------

Co-authored-by: Liang-Chi Hsieh <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Core DataFusion crate sqllogictest SQL Logic Tests (.slt) substrait Changes to the substrait crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants