Skip to content

Commit de89982

Browse files
timsaucerclaude
andcommitted
Remove shared ctx from doctest namespace, use inline SessionContext
Avoid shared SessionContext state across doctests by having each docstring example create its own ctx instance, matching the pattern used throughout the rest of the codebase. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent af08ee6 commit de89982

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

conftest.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,3 @@ def _doctest_namespace(doctest_namespace: dict) -> None:
3434
doctest_namespace["col"] = col
3535
doctest_namespace["lit"] = lit
3636
doctest_namespace["F"] = F
37-
doctest_namespace["ctx"] = dfn.SessionContext()

python/datafusion/context.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -911,6 +911,7 @@ def register_batch(self, name: str, batch: pa.RecordBatch) -> None:
911911
batch: Record batch to register as a table.
912912
913913
Examples:
914+
>>> ctx = dfn.SessionContext()
914915
>>> batch = pa.RecordBatch.from_pydict({"a": [1, 2, 3]})
915916
>>> ctx.register_batch("batch_tbl", batch)
916917
>>> ctx.sql("SELECT * FROM batch_tbl").collect()[0].column(0)
@@ -1151,6 +1152,7 @@ def register_arrow(
11511152
11521153
Examples:
11531154
>>> import tempfile, os
1155+
>>> ctx = dfn.SessionContext()
11541156
>>> table = pa.table({"x": [10, 20, 30]})
11551157
>>> with tempfile.TemporaryDirectory() as tmpdir:
11561158
... path = os.path.join(tmpdir, "data.arrow")
@@ -1488,6 +1490,7 @@ def read_arrow(
14881490
14891491
Examples:
14901492
>>> import tempfile, os
1493+
>>> ctx = dfn.SessionContext()
14911494
>>> table = pa.table({"a": [1, 2, 3]})
14921495
>>> with tempfile.TemporaryDirectory() as tmpdir:
14931496
... path = os.path.join(tmpdir, "data.arrow")

0 commit comments

Comments
 (0)