Deprecate RuntimeConfig, update code to use new builder style#13635
Deprecate RuntimeConfig, update code to use new builder style#13635comphead merged 2 commits intoapache:mainfrom
RuntimeConfig, update code to use new builder style#13635Conversation
| .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() |
There was a problem hiding this comment.
this follows the new builder style model more fully
| } | ||
| } else { | ||
| rt_config | ||
| let mut rt_builder = RuntimeEnvBuilder::new(); |
There was a problem hiding this comment.
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
| async fn query_compress_data( | ||
| file_compression_type: FileCompressionType, | ||
| ) -> Result<()> { | ||
| let runtime = Arc::new(RuntimeEnvBuilder::new().build()?); |
There was a problem hiding this comment.
This simply creates a default RuntimeEnv which the SessionStateBuilder already does, so there is no need to do it again
| let path = path.join("tests/tpch-csv"); | ||
| let url = format!("file://{}", path.display()); | ||
|
|
||
| let runtime = RuntimeEnvBuilder::new().build_arc()?; |
There was a problem hiding this comment.
likewise here, this is the default runtime env, it isn't needed
| /// * [`CacheManager`]: Manage temporary cache data during the session lifetime | ||
| /// * [`ObjectStoreRegistry`]: Manage mapping URLs to object store instances | ||
| /// | ||
| /// # Example: Create default `RuntimeEnv` |
| #[deprecated(since = "44.0.0", note = "please use `RuntimeEnvBuilder` instead")] | ||
| #[allow(deprecated)] | ||
| pub fn try_new(config: RuntimeConfig) -> Result<Self> { | ||
| let RuntimeConfig { |
There was a problem hiding this comment.
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()); |
There was a problem hiding this comment.
this does the same thing, just makes the intent clearer
32113c9 to
d043f63
Compare
|
Thanks again for the review @comphead |
…he#13635) * Deprecate `RuntimeConfig`, update code to use new builder style * Update datafusion/execution/src/runtime_env.rs --------- Co-authored-by: Oleks V <comphead@users.noreply.github.com>
Which issue does this PR close?
Follow on to
RuntimeEnvBuilderrather thanRuntimeConfig#12156Rationale for this change
I hit this while working on #13424 and was a bit confused
@devanbenz added a nice builder style API to the
RuntimeEnvas well as some backwards compatibility APIs which is greatHowever 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:
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