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

getdozer / dozer / 4124646176

pending completion
4124646176

Pull #811

github

GitHub
Merge c6bc261de into f4fe30c14
Pull Request #811: chore: integrating sql planner

737 of 737 new or added lines in 23 files covered. (100.0%)

23321 of 35114 relevant lines covered (66.42%)

35990.16 hits per line

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

67.44
/dozer-sql/src/pipeline/expression/scalar/number.rs
1
use crate::pipeline::errors::PipelineError;
2
use crate::pipeline::errors::PipelineError::InvalidFunctionArgument;
3
use crate::pipeline::expression::execution::{Expression, ExpressionExecutor};
4
use crate::pipeline::expression::scalar::common::ScalarFunctionType;
5
use dozer_types::ordered_float::OrderedFloat;
6
use dozer_types::types::{Field, Record, Schema};
7
use num_traits::Float;
8

9
pub(crate) fn evaluate_abs(
2✔
10
    schema: &Schema,
2✔
11
    arg: &Expression,
2✔
12
    record: &Record,
2✔
13
) -> Result<Field, PipelineError> {
2✔
14
    let value = arg.evaluate(record, schema)?;
2✔
15
    match value {
2✔
16
        Field::Int(i) => Ok(Field::Int(i.abs())),
2✔
17
        Field::Float(f) => Ok(Field::Float(f.abs())),
×
18
        _ => Err(PipelineError::InvalidFunctionArgument(
×
19
            ScalarFunctionType::Abs.to_string(),
×
20
            value,
×
21
            0,
×
22
        )),
×
23
    }
24
}
2✔
25

26
pub(crate) fn evaluate_round(
9✔
27
    schema: &Schema,
9✔
28
    arg: &Expression,
9✔
29
    decimals: Option<&Expression>,
9✔
30
    record: &Record,
9✔
31
) -> Result<Field, PipelineError> {
9✔
32
    let value = arg.evaluate(record, schema)?;
9✔
33
    let mut places = 0;
9✔
34
    if let Some(expression) = decimals {
9✔
35
        match expression.evaluate(record, schema)? {
9✔
36
            Field::Int(i) => places = i as i32,
5✔
37
            Field::Float(f) => places = f.round().0 as i32,
1✔
38
            _ => {} // Truncate value to 0 decimals
3✔
39
        }
40
    }
×
41
    let order = OrderedFloat(10.0_f64.powi(places));
9✔
42

9✔
43
    match value {
9✔
44
        Field::Int(i) => Ok(Field::Int(i)),
1✔
45
        Field::Float(f) => Ok(Field::Float((f * order).round() / order)),
6✔
46
        Field::Decimal(_) => Err(PipelineError::InvalidOperandType("ROUND()".to_string())),
×
47
        Field::Null => Ok(Field::Null),
2✔
48
        _ => Err(InvalidFunctionArgument(
×
49
            ScalarFunctionType::Round.to_string(),
×
50
            value,
×
51
            0,
×
52
        )),
×
53
    }
×
54
}
9✔
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