You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Installing a codec rebuilds the installed planner against it, but the
rebuild reaches exactly one `ForeignQueryPlanner`. A planner that resolved
a fallback at install time keeps that fallback's codecs, and neither side
can repair it: the host has no handle past the first layer, and the planner
library cannot re-derive codecs at plan time because `FFI_QueryPlanner`
holds them by value and `Session` exposes no accessor for the host's
current ones. Tracked upstream in apache/datafusion#24762.
The examples cannot demonstrate it. Their fallback lives in the same cdylib
as its wrapper, and `From<&FFI_QueryPlanner>` short-circuits on a matching
`library_marker_id`, so a same-library hop never serializes. Measured: a
layered planner produces the same codec traffic as a flat one.
What is demonstrable is that the session's planner tracks whichever handle
wrote it last, so re-installing a planner from the original handle rebinds
the session back to that handle's codecs rather than picking up a codec
installed through a derived one. Pinned by a new test as the sequel to
`test_a_discarded_derived_context_still_rebinds_the_planner`.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Installing a codec after the planner rebuilds the planner against it, so this order is a recommendation rather than a requirement. Planner-last states the ownership flow more clearly.
46
+
Installing a codec after the planner rebuilds the planner against it, so this order is a recommendation rather than a requirement. Planner-last states the ownership flow more clearly. The exception is a planner that wraps a fallback: the rebuild reaches the installed planner only, not the fallback inside it, so codecs-first is a requirement there. See [Rebinding a planner's codecs is one level deep](../../docs/source/contributor-guide/ffi.md#rebinding-a-planners-codecs-is-one-level-deep), which also covers why re-installing a planner rebinds the session to the codecs of whichever handle it was installed on.
47
47
48
48
For the limits behind that choice — why there is one external codec owner rather than a registry, which node kinds survive the boundary, and what a derived context shares with the context it came from — see [Query Planners Across Multiple Libraries](../../docs/source/contributor-guide/ffi.md#query-planners-across-multiple-libraries) in the contributor guide.
`MyPlannerConfig` is transferred through the foreign session. `MyQueryPlanner` reads `ffi_query_planner.max_rows`, creates the plan with `DefaultPhysicalPlanner`, and adds a built-in `GlobalLimitExec`. The test changes the setting with `SET` and verifies the new row limit.
57
57
58
-
The provider's codec pair is attached to the planner when it is installed and is also used to decode the returned physical plan in `datafusion-python`. This planner deliberately uses only built-in physical nodes. Install the codecs before the planner where possible; installing a codec afterwards rebuilds the planner against it, but planner-last order is easier to audit.
58
+
The provider's codec pair is attached to the planner when it is installed and is also used to decode the returned physical plan in `datafusion-python`. This planner deliberately uses only built-in physical nodes. Install the codecs before the planner where possible; installing a codec afterwards rebuilds the planner against it, but planner-last order is easier to audit. That rebuild is one level deep — a planner constructed with `fallback=` keeps the codecs its fallback was imported with — so codecs-first is a requirement rather than a preference once planners are layered. See [Rebinding a planner's codecs is one level deep](../../docs/source/contributor-guide/ffi.md#rebinding-a-planners-codecs-is-one-level-deep).
59
59
60
60
For the limits behind that choice — why there is one external codec owner rather than a registry, which node kinds survive the boundary, and what a derived context shares with the context it came from — see [Query Planners Across Multiple Libraries](../../docs/source/contributor-guide/ffi.md#query-planners-across-multiple-libraries) in the contributor guide.
0 commit comments