• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

getdozer / dozer / 4370408272

pending completion
4370408272

push

github

GitHub
fix: Fix compilation error introduced in #1158 (#1183)

3 of 3 new or added lines in 1 file covered. (100.0%)

28163 of 39541 relevant lines covered (71.22%)

73625.66 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

78.57
/dozer-sql/src/pipeline/aggregation/max.rs
1
use crate::pipeline::aggregation::aggregator::{update_map, Aggregator};
2
use crate::pipeline::errors::PipelineError;
3
use crate::pipeline::expression::aggregate::AggregateFunctionType::Max;
4
use crate::{calculate_err, calculate_err_field};
5
use dozer_core::errors::ExecutionError::InvalidType;
6

7
use dozer_types::ordered_float::OrderedFloat;
8
use dozer_types::types::{Field, FieldType};
9
use std::collections::BTreeMap;
10

11
#[derive(Debug)]
×
12
pub struct MaxAggregator {
13
    current_state: BTreeMap<Field, u64>,
14
    return_type: Option<FieldType>,
15
}
16

17
impl MaxAggregator {
18
    pub fn new() -> Self {
33✔
19
        Self {
33✔
20
            current_state: BTreeMap::new(),
33✔
21
            return_type: None,
33✔
22
        }
33✔
23
    }
33✔
24
}
25

26
impl Aggregator for MaxAggregator {
27
    fn init(&mut self, return_type: FieldType) {
32✔
28
        self.return_type = Some(return_type);
32✔
29
    }
32✔
30

31
    fn update(&mut self, old: &[Field], new: &[Field]) -> Result<Field, PipelineError> {
32
        self.delete(old)?;
11✔
33
        self.insert(new)
11✔
34
    }
11✔
35

36
    fn delete(&mut self, old: &[Field]) -> Result<Field, PipelineError> {
43✔
37
        update_map(old, 1_u64, true, &mut self.current_state);
43✔
38
        get_max(&self.current_state, self.return_type)
43✔
39
    }
43✔
40

41
    fn insert(&mut self, new: &[Field]) -> Result<Field, PipelineError> {
44✔
42
        update_map(new, 1_u64, false, &mut self.current_state);
44✔
43
        get_max(&self.current_state, self.return_type)
44✔
44
    }
44✔
45
}
46

47
fn get_max(
90✔
48
    field_map: &BTreeMap<Field, u64>,
90✔
49
    return_type: Option<FieldType>,
90✔
50
) -> Result<Field, PipelineError> {
90✔
51
    if field_map.is_empty() {
90✔
52
        Ok(Field::Null)
37✔
53
    } else {
54
        let val = calculate_err!(field_map.keys().max(), Max).clone();
53✔
55
        match return_type {
53✔
56
            Some(FieldType::UInt) => Ok(Field::UInt(calculate_err_field!(val.to_uint(), Max, val))),
8✔
57
            Some(FieldType::Int) => Ok(Field::Int(calculate_err_field!(val.to_int(), Max, val))),
9✔
58
            Some(FieldType::Float) => Ok(Field::Float(OrderedFloat::from(calculate_err_field!(
9✔
59
                val.to_float(),
9✔
60
                Max,
9✔
61
                val
9✔
62
            )))),
9✔
63
            Some(FieldType::Decimal) => Ok(Field::Decimal(calculate_err_field!(
9✔
64
                val.to_decimal(),
9✔
65
                Max,
9✔
66
                val
9✔
67
            ))),
9✔
68
            Some(FieldType::Timestamp) => Ok(Field::Timestamp(calculate_err_field!(
9✔
69
                val.to_timestamp()?,
9✔
70
                Max,
71
                val
72
            ))),
73
            Some(FieldType::Date) => {
74
                Ok(Field::Date(calculate_err_field!(val.to_date()?, Max, val)))
9✔
75
            }
76
            Some(not_supported_return_type) => {
×
77
                Err(PipelineError::InternalExecutionError(InvalidType(format!(
×
78
                    "Not supported return type {not_supported_return_type} for {Max}"
×
79
                ))))
×
80
            }
×
81
            None => Err(PipelineError::InternalExecutionError(InvalidType(format!(
×
82
                "Not supported None return type for {Max}"
×
83
            )))),
×
84
        }
×
85
    }
×
86
}
90✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc