Skip to content

Commit 6216bf1

Browse files
timsaucerclaude
andcommitted
docs: pass volatility by keyword, drop a dead cross-reference
The new bundle examples spelled volatility positionally while the neighbouring `context.py` examples name it, which leaves a bare "stable" sitting among three pyarrow arguments with nothing to say what it is. Two docstrings alongside: `_components` pointed a `:py:meth:` role at `__post_init__`, which Sphinx has no target for and never renders anyway from a private helper; and `_resolve_declared_functions` said its `wrapper` argument was "passed through already", which says nothing. It is the class a declaration may already be an instance of. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent 2dc1159 commit 6216bf1

3 files changed

Lines changed: 21 additions & 7 deletions

File tree

python/datafusion/context.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,8 @@ def _resolve_declared_functions(
304304
305305
Args:
306306
declared: ``(extension, function)`` pairs in declaration order.
307-
wrapper: The Python wrapper class for this kind, passed through already.
307+
wrapper: The wrapper class a declaration may already be an instance of,
308+
in which case it is taken as-is.
308309
getter: The capsule getter an unwrapped declaration must expose.
309310
factory: The helper that wraps a declaration — ``udf`` and friends.
310311
kind: What to call this sort of function in an error.

python/datafusion/extensions.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@ def _components(noun: str) -> Any:
121121
122122
``noun`` names what the field holds, for the error a bundle sees when it
123123
hands over one component instead of a collection of them. Carrying it in
124-
the field metadata is what lets :py:meth:`SessionExtensionComponents.__post_init__`
125-
normalize a field it was never told about by name.
124+
the field metadata is what lets ``__post_init__`` normalize a field it was
125+
never told about by name.
126126
"""
127127
return field(default=(), metadata={"datafusion_component": noun})
128128

@@ -190,7 +190,7 @@ class SessionExtensionComponents:
190190
... lambda arr: pa.array([v.as_py() * 2 for v in arr]),
191191
... [pa.int64()],
192192
... pa.int64(),
193-
... "stable",
193+
... volatility="stable",
194194
... name="double",
195195
... )
196196
>>> components = SessionExtensionComponents(udfs=(double,))

python/tests/test_context.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1422,7 +1422,7 @@ def _doubler(name="double"):
14221422
lambda arr: pa.array([v.as_py() * 2 for v in arr]),
14231423
[pa.int64()],
14241424
pa.int64(),
1425-
"stable",
1425+
volatility="stable",
14261426
name=name,
14271427
)
14281428

@@ -1483,8 +1483,21 @@ def test_with_extensions_registers_a_declared_udf(ctx):
14831483

14841484
def test_with_extensions_registers_udafs_and_udwfs(ctx):
14851485
"""The other two function kinds install the same way."""
1486-
total = udaf(_Total, pa.int64(), pa.int64(), [pa.int64()], "stable", name="total")
1487-
first = udwf(_First, pa.int64(), pa.int64(), "immutable", name="first_value_of")
1486+
total = udaf(
1487+
_Total,
1488+
pa.int64(),
1489+
pa.int64(),
1490+
[pa.int64()],
1491+
volatility="stable",
1492+
name="total",
1493+
)
1494+
first = udwf(
1495+
_First,
1496+
pa.int64(),
1497+
pa.int64(),
1498+
volatility="immutable",
1499+
name="first_value_of",
1500+
)
14881501

14891502
result = ctx.with_extensions(_FunctionExtension(udafs=(total,), udwfs=(first,)))
14901503
result.from_pydict({"a": [1, 2, 3]}, name="nums")

0 commit comments

Comments
 (0)