Skip to content

Commit 63caf50

Browse files
timsaucerclaude
andcommitted
docs: tighten codec dispatch test docstrings
The previous docstrings claimed the tests verify "PythonLogicalCodec delegates non-Python UDFs to the inner codec." That's forward-looking — the codecs currently delegate every UDF unconditionally, so the test would behave identically for Python and non-Python UDFs. Rewrite to describe what the test actually proves: the dispatch chain `PyLogicalPlan.to_bytes -> session.logical_codec -> PythonLogicalCodec -> FFI -> user impl` (and the physical mirror) forwards correctly, observable via the user codec's atomic counter incrementing after one encode pass. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent b2d77f4 commit 63caf50

2 files changed

Lines changed: 24 additions & 7 deletions

File tree

examples/datafusion-ffi-example/python/tests/_test_logical_extension_codec.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,20 @@ def test_ffi_logical_codec_install_and_export():
4141

4242

4343
def test_ffi_logical_codec_consulted_on_udf_encode():
44-
"""Serializing a plan that references an FFI-imported scalar UDF
45-
routes through the installed codec's `try_encode_udf` path —
46-
PythonLogicalCodec delegates non-Python UDFs to the inner codec."""
44+
"""Serializing through ctx.logical_codec() routes try_encode_udf to
45+
the user-installed FFI codec.
46+
47+
Verifies the dispatch chain
48+
`PyLogicalPlan.to_bytes -> session.logical_codec ->
49+
PythonLogicalCodec -> FFI_LogicalExtensionCodec -> user impl`
50+
is wired correctly. The user codec's atomic counter increments
51+
after a serialization pass, proving every hop forwards.
52+
53+
Does not test any Python-UDF-specific dispatch — PythonLogicalCodec
54+
currently delegates all UDF encoding to its inner codec
55+
unconditionally. Python-vs-other branching lands when in-band
56+
scalar UDF encoding is added.
57+
"""
4758
ctx, codec = _setup_session_with_codec()
4859
df = ctx.sql("SELECT abs(-1) AS x")
4960
plan = df.logical_plan()

examples/datafusion-ffi-example/python/tests/_test_physical_extension_codec.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,16 @@ def test_ffi_physical_codec_install_and_export():
4141

4242

4343
def test_ffi_physical_codec_consulted_on_udf_encode():
44-
"""Serializing an ExecutionPlan that references an FFI-imported
45-
scalar UDF routes `try_encode_udf` through the installed physical
46-
codec — PythonPhysicalCodec delegates non-Python UDFs to the inner
47-
codec."""
44+
"""Serializing through ctx.physical_codec() routes try_encode_udf to
45+
the user-installed FFI codec.
46+
47+
Mirror of the logical-side dispatch test: verifies
48+
`PyExecutionPlan.to_bytes -> session.physical_codec ->
49+
PythonPhysicalCodec -> FFI_PhysicalExtensionCodec -> user impl`
50+
forwards correctly. Does not test Python-UDF-specific dispatch —
51+
PythonPhysicalCodec currently delegates all UDF encoding to its
52+
inner codec unconditionally.
53+
"""
4854
ctx, codec = _setup_session_with_codec()
4955
df = ctx.sql("SELECT abs(a) AS x FROM t")
5056
plan = df.execution_plan()

0 commit comments

Comments
 (0)