Skip to main content

query_planning/
policy.rs

1//! Execution policy shared by optimization, admission, and execution.
2
3use crate::{capability::KeyedHashJoinStrategyOptions, dynamic_filter::DynamicFilterExecutionOptions, error::Result};
4
5/// Thresholds applied during plan optimization, admission, and execution.
6///
7/// The policy accompanies the [`AnalysisContext`](crate::backend::AnalysisContext)
8/// across planning passes and is captured in the resulting admission artifact
9/// rather than embedded directly in plan IR. This separation allows plan IR
10/// fingerprints to remain invariant to policy adjustments while recording the
11/// active policy in the admitted artifact. The type implements `Copy` because
12/// passes receive it by value without shared state.
13#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
14pub struct PlanningPolicy {
15    /// Keyed-hash join strategy thresholds.
16    pub keyed_hash_join: KeyedHashJoinStrategyOptions,
17    /// Dynamic-filter route and application thresholds.
18    pub dynamic_filter: DynamicFilterExecutionOptions,
19}
20
21impl PlanningPolicy {
22    /// Rejects thresholds the optimizer and the engine cannot honor.
23    ///
24    /// Each component policy validates its own ordering constraints and
25    /// reports the first failure with the field names in its facts. Zero is
26    /// accepted everywhere as "branch disabled"; see the component docs.
27    pub fn validate(&self) -> Result<()> {
28        self.keyed_hash_join.validate()?;
29        self.dynamic_filter.validate()
30    }
31}