You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datafusion.apache.org by ti...@apache.org on 2026/10/08 15:43:13 UTC
(datafusion-python) 02/04: test: pin that a planner hook returning None keeps the chain
This is an automated email from the ASF dual-hosted git repository.
timsaucer pushed a commit to branch feat/bundle-functions
in repository https://gitbox.apache.org/repos/asf/datafusion-python.git
commit 1c3c72b3b7399f3c146465038a0a8f5b6976895e
Author: Tim Saucer <ti...@gmail.com>
AuthorDate: Thu Oct 8 09:02:38 2026 -0400
test: pin that a planner hook returning None keeps the chain
A None-returning hook between two planner-producing hooks must leave the
accumulated planner in place, so the outer hook is handed the inner one's
planner. The existing None test only put the None hook first, where
resetting the chain and preserving it look the same.
Parametrize the nesting test with a NoOpExtension between the two
planners. Verified by mutation: resetting the planner on None in
_commit_extensions fails the new case with inner.planner.plan_calls() == 0.
Co-Authored-By: Claude Opus 5.5 (1M context) <no...@anthropic.com>
---
.../python/tests/_test_three_library_query_planner.py | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/examples/datafusion-ffi-query-planner-example/python/tests/_test_three_library_query_planner.py b/examples/datafusion-ffi-query-planner-example/python/tests/_test_three_library_query_planner.py
index 8984b8ac..3e1019e5 100644
--- a/examples/datafusion-ffi-query-planner-example/python/tests/_test_three_library_query_planner.py
+++ b/examples/datafusion-ffi-query-planner-example/python/tests/_test_three_library_query_planner.py
@@ -991,7 +991,8 @@ class PlannerOnlyExtension:
return self.planner
-def test_with_extensions_nests_planners_in_argument_order():
+@pytest.mark.parametrize("none_between", [False, True], ids=["adjacent", "none"])
+def test_with_extensions_nests_planners_in_argument_order(none_between: bool):
"""Two planner-shipping libraries compose instead of displacing each other.
This is the four-library case: A and C contribute codecs, B an optimizing
@@ -999,12 +1000,19 @@ def test_with_extensions_nests_planners_in_argument_order():
for one query, which is only possible if D delegates to B rather than
replacing it — a session holds exactly one planner, so the nesting is the
only way both are reachable.
+
+ With a hook returning ``None`` between the two, ``outer`` must still be
+ handed ``inner``'s planner. A host that reset the chain on ``None`` would
+ hand it the session's planner instead, and ``inner`` would never run.
+ Pure Python cannot see this: a capsule is opaque, so only a planner that
+ counts its calls tells the two fallbacks apart.
"""
config = SessionConfig().with_extension(MyPlannerConfig(max_rows=3))
codecs = ProviderCodecsExtension()
inner = PlannerOnlyExtension()
outer = PlannerOnlyExtension()
- ctx = SessionContext(config).with_extensions(codecs, inner, outer)
+ between = (NoOpExtension(),) if none_between else ()
+ ctx = SessionContext(config).with_extensions(codecs, inner, *between, outer)
ctx.register_table("numbers", MyTableProvider(1, 6, 1))
batches = ctx.sql('SELECT "A" FROM numbers ORDER BY "A"').collect()
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datafusion.apache.org
For additional commands, e-mail: commits-help@datafusion.apache.org