Skip to content
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

Deprecate RuntimeConfig, update code to use new builder style #13635

Merged
merged 2 commits into from
Dec 4, 2024

Conversation

alamb
Copy link
Contributor

@alamb alamb commented Dec 4, 2024

Which issue does this PR close?

Follow on to

Rationale for this change

I hit this while working on #13424 and was a bit confused

@devanbenz added a nice builder style API to the RuntimeEnv as well as some backwards compatibility APIs which is great

However all the examples and code still use the old pattern, which means we aren't getting the benefit of the new API

What changes are included in this PR?

Changes:

  1. Make RuntimeConfig deprecated and update all examples to use builder style
  2. Add docs / examples to help migration
  3. Clean up some other uses of state creation

Are these changes tested?

By existing tests and new doc tests

Are there any user-facing changes?

Some APIs are now deprecated, but no APIs are removed

@alamb alamb marked this pull request as draft December 4, 2024 00:04
@github-actions github-actions bot added sql SQL Planner physical-expr Physical Expressions core Core DataFusion crate execution Related to the execution crate labels Dec 4, 2024
.with_memory_pool(Arc::new(FairSpillPool::new(mem_limit as usize)))
.build_arc()?;
let ctx = SessionContext::new_with_config_rt(config, runtime_config);
let state = SessionStateBuilder::new()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this follows the new builder style model more fully

}
} else {
rt_config
let mut rt_builder = RuntimeEnvBuilder::new();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this code is now clearer -- previously the rt_config was actually a builder and used as such, but that was someone confusing given the code style

@@ -984,12 +983,10 @@ mod tests {
async fn query_compress_data(
file_compression_type: FileCompressionType,
) -> Result<()> {
let runtime = Arc::new(RuntimeEnvBuilder::new().build()?);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This simply creates a default RuntimeEnv which the SessionStateBuilder already does, so there is no need to do it again

@@ -1932,14 +1931,12 @@ mod tests {
let path = path.join("tests/tpch-csv");
let url = format!("file://{}", path.display());

let runtime = RuntimeEnvBuilder::new().build_arc()?;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

likewise here, this is the default runtime env, it isn't needed

/// following resource management functionality:
///
/// * [`MemoryPool`]: Manage memory
/// * [`DiskManager`]: Manage temporary files on local disk
/// * [`CacheManager`]: Manage temporary cache data during the session lifetime
/// * [`ObjectStoreRegistry`]: Manage mapping URLs to object store instances
///
/// # Example: Create default `RuntimeEnv`
Copy link
Contributor Author

Choose a reason for hiding this comment

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

new doc examples

pub fn try_new(config: RuntimeConfig) -> Result<Self> {
let RuntimeConfig {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this code is literally the same as RuntimeConfig::build so just call that directly

let runtime = RuntimeEnvBuilder::new()
.build_arc()
.expect("default runtime created successfully");
let runtime = Arc::new(RuntimeEnv::default());
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this does the same thing, just makes the intent clearer

@alamb alamb force-pushed the alamb/runtime_env branch from 32113c9 to d043f63 Compare December 4, 2024 00:10
@alamb alamb marked this pull request as ready for review December 4, 2024 00:35
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 thanks @alamb

@comphead comphead merged commit 5e9979c into apache:main Dec 4, 2024
25 checks passed
@alamb alamb deleted the alamb/runtime_env branch December 5, 2024 03:43
@alamb
Copy link
Contributor Author

alamb commented Dec 5, 2024

Thanks again for the review @comphead

zhuliquan pushed a commit to zhuliquan/datafusion that referenced this pull request Dec 6, 2024
…he#13635)

* Deprecate `RuntimeConfig`, update code to use new builder style

* Update datafusion/execution/src/runtime_env.rs

---------

Co-authored-by: Oleks V <[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 execution Related to the execution crate physical-expr Physical Expressions sql SQL Planner
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants