use crate::db::{
executor::ScalarNumericFieldBoundaryRequest,
query::{
builder::aggregate::AggregateExplain,
plan::{AggregateKind, FieldSlot},
},
};
#[derive(Clone, Debug, Eq, PartialEq)]
pub(in crate::db) struct SumBySlotTerminal {
target_field: FieldSlot,
}
impl SumBySlotTerminal {
#[must_use]
pub(in crate::db) const fn new(target_field: FieldSlot) -> Self {
Self { target_field }
}
#[must_use]
pub(in crate::db) fn into_executor_request(
self,
) -> (FieldSlot, ScalarNumericFieldBoundaryRequest) {
(self.target_field, ScalarNumericFieldBoundaryRequest::Sum)
}
}
impl AggregateExplain for SumBySlotTerminal {
fn explain_aggregate_kind(&self) -> Option<AggregateKind> {
Some(AggregateKind::Sum)
}
fn explain_projected_field(&self) -> Option<&str> {
Some(self.target_field.field())
}
}
#[derive(Clone, Debug, Eq, PartialEq)]
pub(in crate::db) struct SumDistinctBySlotTerminal {
target_field: FieldSlot,
}
impl SumDistinctBySlotTerminal {
#[must_use]
pub(in crate::db) const fn new(target_field: FieldSlot) -> Self {
Self { target_field }
}
#[must_use]
pub(in crate::db) fn into_executor_request(
self,
) -> (FieldSlot, ScalarNumericFieldBoundaryRequest) {
(
self.target_field,
ScalarNumericFieldBoundaryRequest::SumDistinct,
)
}
}
impl AggregateExplain for SumDistinctBySlotTerminal {
fn explain_aggregate_kind(&self) -> Option<AggregateKind> {
Some(AggregateKind::Sum)
}
fn explain_projected_field(&self) -> Option<&str> {
Some(self.target_field.field())
}
}
#[derive(Clone, Debug, Eq, PartialEq)]
pub(in crate::db) struct AvgBySlotTerminal {
target_field: FieldSlot,
}
impl AvgBySlotTerminal {
#[must_use]
pub(in crate::db) const fn new(target_field: FieldSlot) -> Self {
Self { target_field }
}
#[must_use]
pub(in crate::db) fn into_executor_request(
self,
) -> (FieldSlot, ScalarNumericFieldBoundaryRequest) {
(self.target_field, ScalarNumericFieldBoundaryRequest::Avg)
}
}
impl AggregateExplain for AvgBySlotTerminal {
fn explain_aggregate_kind(&self) -> Option<AggregateKind> {
Some(AggregateKind::Avg)
}
fn explain_projected_field(&self) -> Option<&str> {
Some(self.target_field.field())
}
}
#[derive(Clone, Debug, Eq, PartialEq)]
pub(in crate::db) struct AvgDistinctBySlotTerminal {
target_field: FieldSlot,
}
impl AvgDistinctBySlotTerminal {
#[must_use]
pub(in crate::db) const fn new(target_field: FieldSlot) -> Self {
Self { target_field }
}
#[must_use]
pub(in crate::db) fn into_executor_request(
self,
) -> (FieldSlot, ScalarNumericFieldBoundaryRequest) {
(
self.target_field,
ScalarNumericFieldBoundaryRequest::AvgDistinct,
)
}
}
impl AggregateExplain for AvgDistinctBySlotTerminal {
fn explain_aggregate_kind(&self) -> Option<AggregateKind> {
Some(AggregateKind::Avg)
}
fn explain_projected_field(&self) -> Option<&str> {
Some(self.target_field.field())
}
}