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

getdozer / dozer / 4382731818

pending completion
4382731818

push

github

GitHub
fix: Fix publication slot creation (#1202)

60 of 60 new or added lines in 24 files covered. (100.0%)

27881 of 39907 relevant lines covered (69.86%)

58951.75 hits per line

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

56.1
/dozer-sql/src/pipeline/aggregation/count.rs
1
use crate::calculate_err_type;
2
use crate::pipeline::aggregation::aggregator::Aggregator;
3
use crate::pipeline::errors::PipelineError;
4
use crate::pipeline::expression::aggregate::AggregateFunctionType::Count;
5
use dozer_core::errors::ExecutionError::InvalidType;
6
use dozer_types::ordered_float::OrderedFloat;
7
use dozer_types::rust_decimal::Decimal;
8
use dozer_types::types::{Field, FieldType};
9
use num_traits::FromPrimitive;
10

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

17
impl CountAggregator {
18
    pub fn new() -> Self {
21,076✔
19
        Self {
21,076✔
20
            current_state: 0_u64,
21,076✔
21
            return_type: None,
21,076✔
22
        }
21,076✔
23
    }
21,076✔
24
}
25

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

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

36
    fn delete(&mut self, old: &[Field]) -> Result<Field, PipelineError> {
61✔
37
        self.current_state -= old.len() as u64;
61✔
38
        get_count(self.current_state, self.return_type)
61✔
39
    }
61✔
40

41
    fn insert(&mut self, new: &[Field]) -> Result<Field, PipelineError> {
21,092✔
42
        self.current_state += new.len() as u64;
21,092✔
43
        get_count(self.current_state, self.return_type)
21,092✔
44
    }
21,092✔
45
}
46

47
fn get_count(count: u64, return_type: Option<FieldType>) -> Result<Field, PipelineError> {
48
    match return_type {
21,153✔
49
        Some(FieldType::UInt) => Ok(Field::UInt(count)),
×
50
        Some(FieldType::Int) => Ok(Field::Int(count as i64)),
21,153✔
51
        Some(FieldType::Float) => Ok(Field::Float(OrderedFloat::from(count as f64))),
×
52
        Some(FieldType::Decimal) => Ok(Field::Decimal(calculate_err_type!(
×
53
            Decimal::from_f64(count as f64),
×
54
            Count,
×
55
            FieldType::Decimal
×
56
        ))),
×
57
        Some(not_supported_return_type) => Err(PipelineError::InternalExecutionError(InvalidType(
×
58
            format!("Not supported return type {not_supported_return_type} for {Count}"),
×
59
        ))),
×
60
        None => Err(PipelineError::InternalExecutionError(InvalidType(format!(
×
61
            "Not supported None return type for {Count}"
×
62
        )))),
×
63
    }
×
64
}
21,153✔
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

© 2025 Coveralls, Inc