use super::{NativeOptimizerChange, NodeId, QueryPlan};
pub const AGGREGATE_JOIN_PUSHDOWN_RULE_NAME: &str = "aggregate_join_pushdown";
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct AggregateJoinPushdownOptions {
pub enabled: bool,
}
impl AggregateJoinPushdownOptions {
pub fn disabled() -> Self {
Self { enabled: false }
}
}
impl Default for AggregateJoinPushdownOptions {
fn default() -> Self {
Self { enabled: true }
}
}
#[derive(Debug, Clone, Default, PartialEq, Eq)]
pub struct AggregateJoinPushdownDiagnostics {
pub considered_count: usize,
pub applied_count: usize,
pub candidates: Vec<AggregateJoinPushdownCandidateDiagnostics>,
}
impl AggregateJoinPushdownDiagnostics {
pub(crate) fn is_empty(&self) -> bool {
self.considered_count == 0 && self.applied_count == 0 && self.candidates.is_empty()
}
pub(crate) fn merge(&mut self, other: Self) {
self.considered_count += other.considered_count;
self.applied_count += other.applied_count;
self.candidates.extend(other.candidates);
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct AggregateJoinPushdownCandidateDiagnostics {
pub rule_name: &'static str,
pub aggregate_node_id: NodeId,
pub join_node_id: Option<NodeId>,
pub applied: bool,
pub rejected_reason: Option<AggregateJoinPushdownRejectedReason>,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum AggregateJoinPushdownRejectedReason {
InputNotJoin,
UnsupportedJoinType,
JoinResidualUnsupported,
UnsupportedAggregateExpression,
UnsupportedGroupExpression,
MissingJoinOutputLineage,
UnsupportedSidePattern,
MissingInputField,
ConflictingPreAggregateOutputName,
DetailKeyPreAggregateReductionNotEvidenced,
LeftSemiAlreadyFiltersFinalGroups,
}
pub(crate) struct AggregateJoinPushdownResult {
pub(crate) plan: QueryPlan,
pub(crate) change: NativeOptimizerChange,
pub(crate) diagnostics: AggregateJoinPushdownDiagnostics,
}