Skip to main content

gluesql_core/plan/statement/query/
having.rs

1use {
2    super::AggregationPlan,
3    crate::plan::ExprPlan,
4    serde::{Deserialize, Serialize},
5};
6
7#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
8pub struct HavingPlan {
9    pub input: AggregationPlan,
10    pub expr: ExprPlan,
11}
12
13#[cfg(test)]
14mod tests {
15    use {
16        super::HavingPlan,
17        crate::{
18            data::Value,
19            plan::{
20                AggregationInputPlan, AggregationPlan, ExprPlan, SourcePlan, TableAccessPlan,
21                TableSourcePlan,
22            },
23        },
24        pretty_assertions::assert_eq,
25    };
26
27    #[test]
28    fn having_accepts_aggregation_input() {
29        let input = AggregationPlan {
30            input: AggregationInputPlan::Source(SourcePlan::Table(TableSourcePlan {
31                name: "Item".to_owned(),
32                alias: None,
33                access: TableAccessPlan::FullScan,
34            })),
35            group_by: Vec::new(),
36            aggregate_slots: Vec::new(),
37        };
38        let expr = ExprPlan::Value(Value::Bool(true));
39        let having = HavingPlan {
40            input: input.clone(),
41            expr: expr.clone(),
42        };
43
44        assert_eq!(having.input, input);
45        assert_eq!(having.expr, expr);
46    }
47}