Skip to content

Commit e02357b

Browse files
timsaucerclaude
andcommitted
docs: demonstrate strict-mode refusal in with_python_udf_inlining docstring
Replace placeholder isinstance check with a doctest that registers a Python UDF, encodes an expression on the default session, then shows the strict session refusing to decode the inline payload. Exercises the actual behavior the toggle controls. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 16756f1 commit e02357b

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

python/datafusion/context.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1809,9 +1809,18 @@ def with_python_udf_inlining(self, *, enabled: bool) -> SessionContext:
18091809
the original session is unchanged.
18101810
18111811
Examples:
1812-
>>> from datafusion import SessionContext
1812+
>>> import pyarrow as pa
1813+
>>> from datafusion import SessionContext, Expr, col, udf
1814+
>>> ctx = SessionContext()
1815+
>>> identity = udf(lambda a: a, [pa.int64()], pa.int64(),
1816+
... volatility="immutable", name="identity_demo")
1817+
>>> ctx.register_udf(identity)
1818+
>>> blob = identity(col("x")).to_bytes(ctx)
18131819
>>> strict = SessionContext().with_python_udf_inlining(enabled=False)
1814-
>>> isinstance(strict, SessionContext)
1820+
>>> try:
1821+
... Expr.from_bytes(blob, strict)
1822+
... except Exception as e:
1823+
... print("Refusing to deserialize" in str(e))
18151824
True
18161825
"""
18171826
new_internal = self.ctx.with_python_udf_inlining(enabled)

0 commit comments

Comments
 (0)