use crate::db::{
executor::ScalarProjectionBoundaryRequest,
query::{
builder::aggregate::{ProjectionExplain, ProjectionExplainDescriptor},
plan::{AggregateKind, FieldSlot},
},
};
#[derive(Clone, Debug, Eq, PartialEq)]
pub(in crate::db) struct ValuesBySlotTerminal {
target_field: FieldSlot,
}
impl ValuesBySlotTerminal {
#[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, ScalarProjectionBoundaryRequest) {
(self.target_field, ScalarProjectionBoundaryRequest::Values)
}
#[must_use]
pub(in crate::db::query::builder::aggregate) fn explain_descriptor(
&self,
) -> ProjectionExplainDescriptor<'_> {
ProjectionExplainDescriptor {
terminal: "values_by",
field: self.target_field.field(),
output: "values",
}
}
}
impl ProjectionExplain for ValuesBySlotTerminal {
fn explain_projection_descriptor(&self) -> ProjectionExplainDescriptor<'_> {
self.explain_descriptor()
}
}
#[derive(Clone, Debug, Eq, PartialEq)]
pub(in crate::db) struct DistinctValuesBySlotTerminal {
target_field: FieldSlot,
}
impl DistinctValuesBySlotTerminal {
#[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, ScalarProjectionBoundaryRequest) {
(
self.target_field,
ScalarProjectionBoundaryRequest::DistinctValues,
)
}
#[must_use]
pub(in crate::db::query::builder::aggregate) fn explain_descriptor(
&self,
) -> ProjectionExplainDescriptor<'_> {
ProjectionExplainDescriptor {
terminal: "distinct_values_by",
field: self.target_field.field(),
output: "values",
}
}
}
impl ProjectionExplain for DistinctValuesBySlotTerminal {
fn explain_projection_descriptor(&self) -> ProjectionExplainDescriptor<'_> {
self.explain_descriptor()
}
}
#[derive(Clone, Debug, Eq, PartialEq)]
pub(in crate::db) struct CountDistinctBySlotTerminal {
target_field: FieldSlot,
}
impl CountDistinctBySlotTerminal {
#[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, ScalarProjectionBoundaryRequest) {
(
self.target_field,
ScalarProjectionBoundaryRequest::CountDistinct,
)
}
#[must_use]
pub(in crate::db::query::builder::aggregate) fn explain_descriptor(
&self,
) -> ProjectionExplainDescriptor<'_> {
ProjectionExplainDescriptor {
terminal: "count_distinct_by",
field: self.target_field.field(),
output: "count",
}
}
}
impl ProjectionExplain for CountDistinctBySlotTerminal {
fn explain_projection_descriptor(&self) -> ProjectionExplainDescriptor<'_> {
self.explain_descriptor()
}
}
#[derive(Clone, Debug, Eq, PartialEq)]
pub(in crate::db) struct ValuesBySlotWithIdsTerminal {
target_field: FieldSlot,
}
impl ValuesBySlotWithIdsTerminal {
#[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, ScalarProjectionBoundaryRequest) {
(
self.target_field,
ScalarProjectionBoundaryRequest::ValuesWithIds,
)
}
#[must_use]
pub(in crate::db::query::builder::aggregate) fn explain_descriptor(
&self,
) -> ProjectionExplainDescriptor<'_> {
ProjectionExplainDescriptor {
terminal: "values_by_with_ids",
field: self.target_field.field(),
output: "values_with_ids",
}
}
}
impl ProjectionExplain for ValuesBySlotWithIdsTerminal {
fn explain_projection_descriptor(&self) -> ProjectionExplainDescriptor<'_> {
self.explain_descriptor()
}
}
#[derive(Clone, Debug, Eq, PartialEq)]
pub(in crate::db) struct FirstValueBySlotTerminal {
target_field: FieldSlot,
}
impl FirstValueBySlotTerminal {
#[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, ScalarProjectionBoundaryRequest) {
(
self.target_field,
ScalarProjectionBoundaryRequest::TerminalValue {
terminal_kind: AggregateKind::First,
},
)
}
#[must_use]
pub(in crate::db::query::builder::aggregate) fn explain_descriptor(
&self,
) -> ProjectionExplainDescriptor<'_> {
ProjectionExplainDescriptor {
terminal: "first_value_by",
field: self.target_field.field(),
output: "terminal_value",
}
}
}
impl ProjectionExplain for FirstValueBySlotTerminal {
fn explain_projection_descriptor(&self) -> ProjectionExplainDescriptor<'_> {
self.explain_descriptor()
}
}
#[derive(Clone, Debug, Eq, PartialEq)]
pub(in crate::db) struct LastValueBySlotTerminal {
target_field: FieldSlot,
}
impl LastValueBySlotTerminal {
#[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, ScalarProjectionBoundaryRequest) {
(
self.target_field,
ScalarProjectionBoundaryRequest::TerminalValue {
terminal_kind: AggregateKind::Last,
},
)
}
#[must_use]
pub(in crate::db::query::builder::aggregate) fn explain_descriptor(
&self,
) -> ProjectionExplainDescriptor<'_> {
ProjectionExplainDescriptor {
terminal: "last_value_by",
field: self.target_field.field(),
output: "terminal_value",
}
}
}
impl ProjectionExplain for LastValueBySlotTerminal {
fn explain_projection_descriptor(&self) -> ProjectionExplainDescriptor<'_> {
self.explain_descriptor()
}
}