Is your feature request related to a problem or challenge?
JoinSelection's internal stats helpers (get_stats, should_swap_join_order,
supports_collect_by_thresholds) take Option<&StatisticsRegistry> and
&ConfigOptions pre-extracted from the PhysicalOptimizerContext. Every new
session-scoped input added to the context for cost-based estimation forces a
signature change across all three helpers and their call sites.
Describe the solution you'd like
Pass &dyn PhysicalOptimizerContext to these helpers instead; they read
statistics_registry() / config_options() off it. New context inputs then need
no helper-signature changes.
This is also the pattern any future physical optimizer rule implementing CBO
should follow: take the PhysicalOptimizerContext and read what it needs off it,
rather than threading individual extracted inputs.
Describe alternatives you've considered
- Keep threading individual params — every new input churns all three signatures.
- Pass
SessionState directly — not possible; datafusion-physical-optimizer
can't depend on datafusion-core, which is why PhysicalOptimizerContext
exists.
Additional context
Non-breaking, mechanical: the helpers are crate-internal (get_stats /
supports_collect_by_thresholds private, should_swap_join_order pub(crate)),
no cross-crate callers, public PhysicalOptimizerRule methods unchanged.
Is your feature request related to a problem or challenge?
JoinSelection's internal stats helpers (get_stats,should_swap_join_order,supports_collect_by_thresholds) takeOption<&StatisticsRegistry>and&ConfigOptionspre-extracted from thePhysicalOptimizerContext. Every newsession-scoped input added to the context for cost-based estimation forces a
signature change across all three helpers and their call sites.
Describe the solution you'd like
Pass
&dyn PhysicalOptimizerContextto these helpers instead; they readstatistics_registry()/config_options()off it. New context inputs then needno helper-signature changes.
This is also the pattern any future physical optimizer rule implementing CBO
should follow: take the
PhysicalOptimizerContextand read what it needs off it,rather than threading individual extracted inputs.
Describe alternatives you've considered
SessionStatedirectly — not possible;datafusion-physical-optimizercan't depend on
datafusion-core, which is whyPhysicalOptimizerContextexists.
Additional context
Non-breaking, mechanical: the helpers are crate-internal (
get_stats/supports_collect_by_thresholdsprivate,should_swap_join_orderpub(crate)),no cross-crate callers, public
PhysicalOptimizerRulemethods unchanged.