Skip to content

Commit 99004ef

Browse files
timsaucerclaude
andcommitted
Remove unused Config class that could not be connected to a SessionContext
Closes #322. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 3585c11 commit 99004ef

File tree

7 files changed

+30
-198
lines changed

7 files changed

+30
-198
lines changed

crates/core/src/config.rs

Lines changed: 0 additions & 104 deletions
This file was deleted.

crates/core/src/lib.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ use pyo3::prelude::*;
3030
pub mod catalog;
3131
pub mod common;
3232

33-
#[allow(clippy::borrow_deref_ref)]
34-
mod config;
3533
#[allow(clippy::borrow_deref_ref)]
3634
pub mod context;
3735
#[allow(clippy::borrow_deref_ref)]
@@ -90,7 +88,6 @@ fn _internal(py: Python, m: Bound<'_, PyModule>) -> PyResult<()> {
9088
m.add_class::<udaf::PyAggregateUDF>()?;
9189
m.add_class::<udwf::PyWindowUDF>()?;
9290
m.add_class::<udtf::PyTableFunction>()?;
93-
m.add_class::<config::PyConfig>()?;
9491
m.add_class::<sql::logical::PyLogicalPlan>()?;
9592
m.add_class::<physical_plan::PyExecutionPlan>()?;
9693
m.add_class::<record_batch::PyRecordBatch>()?;

docs/source/contributor-guide/ffi.rst

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -149,20 +149,7 @@ interior-mutable state. In practice this means that any ``#[pyclass]`` containin
149149
``Arc<RwLock<_>>`` or similar synchronized primitive must opt into ``#[pyclass(frozen)]``
150150
unless there is a compelling reason not to.
151151

152-
The :mod:`datafusion` configuration helpers illustrate the preferred pattern. The
153-
``PyConfig`` class in :file:`src/config.rs` stores an ``Arc<RwLock<ConfigOptions>>`` and is
154-
explicitly frozen so callers interact with configuration state through provided methods
155-
instead of mutating the container directly:
156-
157-
.. code-block:: rust
158-
159-
#[pyclass(from_py_object, name = "Config", module = "datafusion", subclass, frozen)]
160-
#[derive(Clone)]
161-
pub(crate) struct PyConfig {
162-
config: Arc<RwLock<ConfigOptions>>,
163-
}
164-
165-
The same approach applies to execution contexts. ``PySessionContext`` in
152+
The execution context illustrates the preferred pattern. ``PySessionContext`` in
166153
:file:`src/context.rs` stays frozen even though it shares mutable state internally via
167154
``SessionContext``. This ensures PyO3 tracks borrows correctly while Python-facing APIs
168155
clone the inner ``SessionContext`` or return new wrappers instead of mutating the

docs/source/user-guide/upgrade-guides.rst

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,33 @@
1818
Upgrade Guides
1919
==============
2020

21+
DataFusion 54.0.0
22+
-----------------
23+
24+
The ``Config`` class has been removed. It was a standalone wrapper around
25+
``ConfigOptions`` that could not be connected to a ``SessionContext``, making it
26+
effectively unusable. Use :py:class:`~datafusion.context.SessionConfig` instead,
27+
which is passed directly to ``SessionContext``.
28+
29+
Before:
30+
31+
.. code-block:: python
32+
33+
from datafusion import Config
34+
35+
config = Config()
36+
config.set("datafusion.execution.batch_size", "4096")
37+
# config could not be passed to SessionContext
38+
39+
After:
40+
41+
.. code-block:: python
42+
43+
from datafusion import SessionConfig, SessionContext
44+
45+
config = SessionConfig().set("datafusion.execution.batch_size", "4096")
46+
ctx = SessionContext(config)
47+
2148
DataFusion 53.0.0
2249
-----------------
2350

python/datafusion/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
from . import functions, object_store, substrait, unparser
3535

3636
# The following imports are okay to remain as opaque to the user.
37-
from ._internal import Config
3837
from .catalog import Catalog, Table
3938
from .col import col, column
4039
from .common import DFSchema
@@ -76,7 +75,6 @@
7675
"Accumulator",
7776
"AggregateUDF",
7877
"Catalog",
79-
"Config",
8078
"CsvReadOptions",
8179
"DFSchema",
8280
"DataFrame",

python/tests/test_concurrency.py

Lines changed: 2 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from concurrent.futures import ThreadPoolExecutor
2121

2222
import pyarrow as pa
23-
from datafusion import Config, SessionContext, col, lit
23+
from datafusion import SessionContext, col, lit
2424
from datafusion import functions as f
2525
from datafusion.common import SqlSchema
2626

@@ -34,16 +34,14 @@ def _run_in_threads(fn, count: int = 8) -> None:
3434

3535

3636
def test_concurrent_access_to_shared_structures() -> None:
37-
"""Exercise SqlSchema, Config, and DataFrame concurrently."""
37+
"""Exercise SqlSchema and DataFrame concurrently."""
3838

3939
schema = SqlSchema("concurrency")
40-
config = Config()
4140
ctx = SessionContext()
4241

4342
batch = pa.record_batch([pa.array([1, 2, 3], type=pa.int32())], names=["value"])
4443
df = ctx.create_dataframe([[batch]])
4544

46-
config_key = "datafusion.execution.batch_size"
4745
expected_rows = batch.num_rows
4846

4947
def worker(index: int) -> None:
@@ -54,41 +52,12 @@ def worker(index: int) -> None:
5452
assert isinstance(schema.views, list)
5553
assert isinstance(schema.functions, list)
5654

57-
config.set(config_key, str(1024 + index))
58-
assert config.get(config_key) is not None
59-
# Access the full config map to stress lock usage.
60-
assert config_key in config.get_all()
61-
6255
batches = df.collect()
6356
assert sum(batch.num_rows for batch in batches) == expected_rows
6457

6558
_run_in_threads(worker, count=12)
6659

6760

68-
def test_config_set_during_get_all() -> None:
69-
"""Ensure config writes proceed while another thread reads all entries."""
70-
71-
config = Config()
72-
key = "datafusion.execution.batch_size"
73-
74-
def reader() -> None:
75-
for _ in range(200):
76-
# get_all should not hold the lock while converting to Python objects
77-
config.get_all()
78-
79-
def writer() -> None:
80-
for index in range(200):
81-
config.set(key, str(1024 + index))
82-
83-
with ThreadPoolExecutor(max_workers=2) as executor:
84-
reader_future = executor.submit(reader)
85-
writer_future = executor.submit(writer)
86-
reader_future.result(timeout=10)
87-
writer_future.result(timeout=10)
88-
89-
assert config.get(key) is not None
90-
91-
9261
def test_case_builder_reuse_from_multiple_threads() -> None:
9362
"""Ensure the case builder can be safely reused across threads."""
9463

python/tests/test_config.py

Lines changed: 0 additions & 42 deletions
This file was deleted.

0 commit comments

Comments
 (0)