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

getdozer / dozer / 4050821206

pending completion
4050821206

Pull #715

github

GitHub
Merge a6e2547ce into 799cc6ea0
Pull Request #715: Refactor: expression parsing refactor to support nested aggregations

1356 of 1356 new or added lines in 14 files covered. (100.0%)

24526 of 37344 relevant lines covered (65.68%)

35564.6 hits per line

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

73.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)]
16✔
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 {
4✔
24
        match self {
4✔
25
            ScalarFunctionType::Abs => f.write_str("ABS"),
×
26
            ScalarFunctionType::Round => f.write_str("ROUND"),
3✔
27
            ScalarFunctionType::Ucase => f.write_str("UCASE"),
×
28
            ScalarFunctionType::Concat => f.write_str("CONCAT"),
1✔
29
            ScalarFunctionType::Length => f.write_str("LENGTH"),
×
30
        }
31
    }
4✔
32
}
33

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

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

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