Skip to content

Commit 05802ab

Browse files
committed
RuntimeConfig is now deprecated
1 parent 307d30b commit 05802ab

File tree

2 files changed

+33
-33
lines changed

2 files changed

+33
-33
lines changed

src/context.rs

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ use datafusion::execution::context::{
6262
use datafusion::execution::disk_manager::DiskManagerConfig;
6363
use datafusion::execution::memory_pool::{FairSpillPool, GreedyMemoryPool, UnboundedMemoryPool};
6464
use datafusion::execution::options::ReadOptions;
65-
use datafusion::execution::runtime_env::{RuntimeConfig, RuntimeEnv};
65+
use datafusion::execution::runtime_env::RuntimeEnvBuilder;
6666
use datafusion::physical_plan::SendableRecordBatchStream;
6767
use datafusion::prelude::{
6868
AvroReadOptions, CsvReadOptions, DataFrame, NdJsonReadOptions, ParquetReadOptions,
@@ -165,62 +165,62 @@ impl PySessionConfig {
165165
}
166166

167167
/// Runtime options for a SessionContext
168-
#[pyclass(name = "RuntimeConfig", module = "datafusion", subclass)]
168+
#[pyclass(name = "RuntimeEnvBuilder", module = "datafusion", subclass)]
169169
#[derive(Clone)]
170-
pub struct PyRuntimeConfig {
171-
pub config: RuntimeConfig,
170+
pub struct PyRuntimeEnvBuilder {
171+
pub builder: RuntimeEnvBuilder,
172172
}
173173

174174
#[pymethods]
175-
impl PyRuntimeConfig {
175+
impl PyRuntimeEnvBuilder {
176176
#[new]
177177
fn new() -> Self {
178178
Self {
179-
config: RuntimeConfig::default(),
179+
builder: RuntimeEnvBuilder::default(),
180180
}
181181
}
182182

183183
fn with_disk_manager_disabled(&self) -> Self {
184-
let config = self.config.clone();
185-
let config = config.with_disk_manager(DiskManagerConfig::Disabled);
186-
Self { config }
184+
let mut builder = self.builder.clone();
185+
builder = builder.with_disk_manager(DiskManagerConfig::Disabled);
186+
Self { builder }
187187
}
188188

189189
fn with_disk_manager_os(&self) -> Self {
190-
let config = self.config.clone();
191-
let config = config.with_disk_manager(DiskManagerConfig::NewOs);
192-
Self { config }
190+
let builder = self.builder.clone();
191+
let builder = builder.with_disk_manager(DiskManagerConfig::NewOs);
192+
Self { builder }
193193
}
194194

195195
fn with_disk_manager_specified(&self, paths: Vec<String>) -> Self {
196-
let config = self.config.clone();
196+
let builder = self.builder.clone();
197197
let paths = paths.iter().map(|s| s.into()).collect();
198-
let config = config.with_disk_manager(DiskManagerConfig::NewSpecified(paths));
199-
Self { config }
198+
let builder = builder.with_disk_manager(DiskManagerConfig::NewSpecified(paths));
199+
Self { builder }
200200
}
201201

202202
fn with_unbounded_memory_pool(&self) -> Self {
203-
let config = self.config.clone();
204-
let config = config.with_memory_pool(Arc::new(UnboundedMemoryPool::default()));
205-
Self { config }
203+
let builder = self.builder.clone();
204+
let builder = builder.with_memory_pool(Arc::new(UnboundedMemoryPool::default()));
205+
Self { builder }
206206
}
207207

208208
fn with_fair_spill_pool(&self, size: usize) -> Self {
209-
let config = self.config.clone();
210-
let config = config.with_memory_pool(Arc::new(FairSpillPool::new(size)));
211-
Self { config }
209+
let builder = self.builder.clone();
210+
let builder = builder.with_memory_pool(Arc::new(FairSpillPool::new(size)));
211+
Self { builder }
212212
}
213213

214214
fn with_greedy_memory_pool(&self, size: usize) -> Self {
215-
let config = self.config.clone();
216-
let config = config.with_memory_pool(Arc::new(GreedyMemoryPool::new(size)));
217-
Self { config }
215+
let builder = self.builder.clone();
216+
let builder = builder.with_memory_pool(Arc::new(GreedyMemoryPool::new(size)));
217+
Self { builder }
218218
}
219219

220220
fn with_temp_file_path(&self, path: &str) -> Self {
221-
let config = self.config.clone();
222-
let config = config.with_temp_file_path(path);
223-
Self { config }
221+
let builder = self.builder.clone();
222+
let builder = builder.with_temp_file_path(path);
223+
Self { builder }
224224
}
225225
}
226226

@@ -276,19 +276,19 @@ impl PySessionContext {
276276
#[new]
277277
pub fn new(
278278
config: Option<PySessionConfig>,
279-
runtime: Option<PyRuntimeConfig>,
279+
runtime: Option<PyRuntimeEnvBuilder>,
280280
) -> PyResult<Self> {
281281
let config = if let Some(c) = config {
282282
c.config
283283
} else {
284284
SessionConfig::default().with_information_schema(true)
285285
};
286-
let runtime_config = if let Some(c) = runtime {
287-
c.config
286+
let runtime_env_builder = if let Some(c) = runtime {
287+
c.builder
288288
} else {
289-
RuntimeConfig::default()
289+
RuntimeEnvBuilder::default()
290290
};
291-
let runtime = Arc::new(RuntimeEnv::try_new(runtime_config)?);
291+
let runtime = Arc::new(runtime_env_builder.build()?);
292292
let session_state = SessionStateBuilder::new()
293293
.with_config(config)
294294
.with_runtime_env(runtime)

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ fn _internal(py: Python, m: Bound<'_, PyModule>) -> PyResult<()> {
7878
m.add_class::<catalog::PyCatalog>()?;
7979
m.add_class::<catalog::PyDatabase>()?;
8080
m.add_class::<catalog::PyTable>()?;
81-
m.add_class::<context::PyRuntimeConfig>()?;
81+
m.add_class::<context::PyRuntimeEnvBuilder>()?;
8282
m.add_class::<context::PySessionConfig>()?;
8383
m.add_class::<context::PySessionContext>()?;
8484
m.add_class::<context::PySQLOptions>()?;

0 commit comments

Comments
 (0)