#[derive(Clone, Debug, Eq, PartialEq)]
pub(crate) enum SecondaryOrderPushdownEligibility {
Eligible {
index: &'static str,
prefix_len: usize,
},
Rejected(SecondaryOrderPushdownRejection),
}
#[derive(Clone, Debug, Eq, PartialEq)]
pub(crate) enum PushdownApplicability {
NotApplicable,
Applicable(SecondaryOrderPushdownEligibility),
}
impl PushdownApplicability {
#[must_use]
pub(crate) const fn is_eligible(&self) -> bool {
matches!(
self,
Self::Applicable(SecondaryOrderPushdownEligibility::Eligible { .. })
)
}
}
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub(crate) enum PushdownSurfaceEligibility<'a> {
EligibleSecondaryIndex {
index: &'static str,
prefix_len: usize,
},
Rejected {
reason: &'a SecondaryOrderPushdownRejection,
},
}
impl<'a> From<&'a SecondaryOrderPushdownEligibility> for PushdownSurfaceEligibility<'a> {
fn from(value: &'a SecondaryOrderPushdownEligibility) -> Self {
match value {
SecondaryOrderPushdownEligibility::Eligible { index, prefix_len } => {
Self::EligibleSecondaryIndex {
index,
prefix_len: *prefix_len,
}
}
SecondaryOrderPushdownEligibility::Rejected(reason) => Self::Rejected { reason },
}
}
}
#[derive(Clone, Debug, Eq, PartialEq)]
pub enum SecondaryOrderPushdownRejection {
NoOrderBy,
AccessPathNotSingleIndexPrefix,
AccessPathIndexRangeUnsupported {
index: &'static str,
prefix_len: usize,
},
InvalidIndexPrefixBounds {
prefix_len: usize,
index_field_len: usize,
},
MissingPrimaryKeyTieBreak {
field: String,
},
PrimaryKeyDirectionNotAscending {
field: String,
},
MixedDirectionNotEligible {
field: String,
},
OrderFieldsDoNotMatchIndex {
index: &'static str,
prefix_len: usize,
expected_suffix: Vec<String>,
expected_full: Vec<String>,
actual: Vec<String>,
},
}