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

getdozer / dozer / 4007818786

pending completion
4007818786

Pull #733

github

GitHub
Merge baf5c38aa into 6c0ac2b2c
Pull Request #733: Bump diesel from 2.0.2 to 2.0.3

23389 of 34432 relevant lines covered (67.93%)

40326.78 hits per line

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

66.13
/dozer-sql/src/pipeline/expression/scalar/common.rs
1
use crate::argv;
2
use crate::pipeline::errors::PipelineError;
3
use crate::pipeline::expression::execution::{Expression, ExpressionExecutor, ExpressionType};
4
use crate::pipeline::expression::scalar::number::{evaluate_abs, evaluate_round};
5
use crate::pipeline::expression::scalar::string::{
6
    evaluate_concat, evaluate_length, evaluate_ucase, validate_concat, validate_ucase,
7
};
8

9
use dozer_types::types::{Field, FieldType, Record, Schema};
10

11
use std::fmt::{Display, Formatter};
12

13
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Hash)]
7✔
14
pub enum ScalarFunctionType {
15
    Abs,
16
    Round,
17
    Ucase,
18
    Concat,
19
    Length,
20
}
21

22
impl Display for ScalarFunctionType {
23
    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
1✔
24
        match self {
1✔
25
            ScalarFunctionType::Abs => f.write_str("ABS"),
×
26
            ScalarFunctionType::Round => f.write_str("ROUND"),
×
27
            ScalarFunctionType::Ucase => f.write_str("UCASE"),
×
28
            ScalarFunctionType::Concat => f.write_str("CONCAT"),
1✔
29
            ScalarFunctionType::Length => f.write_str("LENGTH"),
×
30
        }
31
    }
1✔
32
}
33

34
pub(crate) fn get_scalar_function_type(
8✔
35
    function: &ScalarFunctionType,
8✔
36
    args: &[Expression],
8✔
37
    schema: &Schema,
8✔
38
) -> Result<ExpressionType, PipelineError> {
8✔
39
    match function {
8✔
40
        ScalarFunctionType::Abs => argv!(args, 0, ScalarFunctionType::Abs)?.get_type(schema),
1✔
41
        ScalarFunctionType::Round => Ok(ExpressionType::new(
×
42
            FieldType::Int,
×
43
            true,
×
44
            dozer_types::types::SourceDefinition::Dynamic,
×
45
        )),
×
46
        ScalarFunctionType::Ucase => {
×
47
            validate_ucase(argv!(args, 0, ScalarFunctionType::Ucase)?, schema)
2✔
48
        }
×
49
        ScalarFunctionType::Concat => validate_concat(args, schema),
4✔
50
        ScalarFunctionType::Length => Ok(ExpressionType::new(
1✔
51
            FieldType::UInt,
1✔
52
            false,
1✔
53
            dozer_types::types::SourceDefinition::Dynamic,
1✔
54
        )),
1✔
55
    }
×
56
}
8✔
57

×
58
impl ScalarFunctionType {
×
59
    pub fn new(name: &str) -> Result<ScalarFunctionType, PipelineError> {
348✔
60
        match name {
348✔
61
            "abs" => Ok(ScalarFunctionType::Abs),
348✔
62
            "round" => Ok(ScalarFunctionType::Round),
346✔
63
            "ucase" => Ok(ScalarFunctionType::Ucase),
346✔
64
            "concat" => Ok(ScalarFunctionType::Concat),
342✔
65
            "length" => Ok(ScalarFunctionType::Length),
335✔
66
            _ => Err(PipelineError::InvalidFunction(name.to_string())),
333✔
67
        }
×
68
    }
348✔
69

70
    pub(crate) fn evaluate(
8✔
71
        &self,
8✔
72
        schema: &Schema,
8✔
73
        args: &[Expression],
8✔
74
        record: &Record,
8✔
75
    ) -> Result<Field, PipelineError> {
8✔
76
        match self {
8✔
77
            ScalarFunctionType::Abs => {
78
                evaluate_abs(schema, argv!(args, 0, ScalarFunctionType::Abs)?, record)
2✔
79
            }
×
80
            ScalarFunctionType::Round => evaluate_round(
81
                schema,
×
82
                argv!(args, 0, ScalarFunctionType::Round)?,
×
83
                args.get(1),
×
84
                record,
×
85
            ),
86
            ScalarFunctionType::Ucase => {
×
87
                evaluate_ucase(schema, argv!(args, 0, ScalarFunctionType::Ucase)?, record)
2✔
88
            }
89
            ScalarFunctionType::Concat => evaluate_concat(schema, args, record),
3✔
90
            ScalarFunctionType::Length => {
91
                evaluate_length(schema, argv!(args, 0, ScalarFunctionType::Length)?, record)
1✔
92
            }
93
        }
94
    }
8✔
95
}
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