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

getdozer / dozer / 4007820649

pending completion
4007820649

Pull #734

github

GitHub
Merge b71e66da1 into 6c0ac2b2c
Pull Request #734: Bump ahash from 0.8.2 to 0.8.3

23507 of 35166 relevant lines covered (66.85%)

40241.5 hits per line

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

94.58
/dozer-sql/src/pipeline/expression/tests/execution.rs
1
use crate::pipeline::builder::SchemaSQLContext;
2
use crate::pipeline::expression::execution::{Expression, ExpressionExecutor};
3
use crate::pipeline::expression::operator::{BinaryOperatorType, UnaryOperatorType};
4
use crate::pipeline::expression::scalar::common::ScalarFunctionType;
5
use crate::pipeline::projection::factory::ProjectionProcessorFactory;
6
use crate::pipeline::tests::utils::get_select;
7
use dozer_core::dag::dag::DEFAULT_PORT_HANDLE;
8
use dozer_core::dag::node::ProcessorFactory;
9
use dozer_types::types::{Field, FieldDefinition, FieldType, Record, Schema, SourceDefinition};
10

11
#[test]
1✔
12
fn test_column_execution() {
1✔
13
    use dozer_types::ordered_float::OrderedFloat;
1✔
14

1✔
15
    let schema = Schema::empty()
1✔
16
        .field(
1✔
17
            FieldDefinition::new(
1✔
18
                "int_field".to_string(),
1✔
19
                FieldType::Int,
1✔
20
                false,
1✔
21
                SourceDefinition::Dynamic,
1✔
22
            ),
1✔
23
            false,
1✔
24
        )
1✔
25
        .field(
1✔
26
            FieldDefinition::new(
1✔
27
                "str_field".to_string(),
1✔
28
                FieldType::String,
1✔
29
                false,
1✔
30
                SourceDefinition::Dynamic,
1✔
31
            ),
1✔
32
            false,
1✔
33
        )
1✔
34
        .field(
1✔
35
            FieldDefinition::new(
1✔
36
                "float_field".to_string(),
1✔
37
                FieldType::Float,
1✔
38
                false,
1✔
39
                SourceDefinition::Dynamic,
1✔
40
            ),
1✔
41
            false,
1✔
42
        )
1✔
43
        .clone();
1✔
44

1✔
45
    let record = Record::new(
1✔
46
        None,
1✔
47
        vec![
1✔
48
            Field::Int(1337),
1✔
49
            Field::String("test".to_string()),
1✔
50
            Field::Float(OrderedFloat(10.10)),
1✔
51
        ],
1✔
52
        None,
1✔
53
    );
1✔
54

1✔
55
    // Column
1✔
56
    let e = Expression::Column { index: 0 };
1✔
57
    assert_eq!(
1✔
58
        e.evaluate(&record, &schema)
1✔
59
            .unwrap_or_else(|e| panic!("{}", e.to_string())),
1✔
60
        Field::Int(1337)
1✔
61
    );
1✔
62

63
    let e = Expression::Column { index: 1 };
1✔
64
    assert_eq!(
1✔
65
        e.evaluate(&record, &schema)
1✔
66
            .unwrap_or_else(|e| panic!("{}", e.to_string())),
1✔
67
        Field::String("test".to_string())
1✔
68
    );
1✔
69

70
    let e = Expression::Column { index: 2 };
1✔
71
    assert_eq!(
1✔
72
        e.evaluate(&record, &schema)
1✔
73
            .unwrap_or_else(|e| panic!("{}", e.to_string())),
1✔
74
        Field::Float(OrderedFloat(10.10))
1✔
75
    );
1✔
76

×
77
    // Literal
×
78
    let e = Expression::Literal(Field::Int(1337));
1✔
79
    assert_eq!(
1✔
80
        e.evaluate(&record, &schema)
1✔
81
            .unwrap_or_else(|e| panic!("{}", e.to_string())),
1✔
82
        Field::Int(1337)
1✔
83
    );
1✔
84

×
85
    // UnaryOperator
×
86
    let e = Expression::UnaryOperator {
1✔
87
        operator: UnaryOperatorType::Not,
1✔
88
        arg: Box::new(Expression::Literal(Field::Boolean(true))),
1✔
89
    };
1✔
90
    assert_eq!(
1✔
91
        e.evaluate(&record, &schema)
1✔
92
            .unwrap_or_else(|e| panic!("{}", e.to_string())),
1✔
93
        Field::Boolean(false)
1✔
94
    );
1✔
95

×
96
    // BinaryOperator
×
97
    let e = Expression::BinaryOperator {
1✔
98
        left: Box::new(Expression::Literal(Field::Boolean(true))),
1✔
99
        operator: BinaryOperatorType::And,
1✔
100
        right: Box::new(Expression::Literal(Field::Boolean(false))),
1✔
101
    };
1✔
102
    assert_eq!(
1✔
103
        e.evaluate(&record, &schema)
1✔
104
            .unwrap_or_else(|e| panic!("{}", e.to_string())),
1✔
105
        Field::Boolean(false),
1✔
106
    );
1✔
107

×
108
    // ScalarFunction
×
109
    let e = Expression::ScalarFunction {
1✔
110
        fun: ScalarFunctionType::Abs,
1✔
111
        args: vec![Expression::Literal(Field::Int(-1))],
1✔
112
    };
1✔
113
    assert_eq!(
1✔
114
        e.evaluate(&record, &schema)
1✔
115
            .unwrap_or_else(|e| panic!("{}", e.to_string())),
1✔
116
        Field::Int(1)
1✔
117
    );
1✔
118
}
1✔
119

×
120
#[test]
1✔
121
fn test_alias() {
1✔
122
    let schema = Schema::empty()
1✔
123
        .field(
1✔
124
            FieldDefinition::new(
1✔
125
                String::from("fn"),
1✔
126
                FieldType::Text,
1✔
127
                false,
1✔
128
                SourceDefinition::Dynamic,
1✔
129
            ),
1✔
130
            false,
1✔
131
        )
1✔
132
        .field(
1✔
133
            FieldDefinition::new(
1✔
134
                String::from("ln"),
1✔
135
                FieldType::String,
1✔
136
                false,
1✔
137
                SourceDefinition::Dynamic,
1✔
138
            ),
1✔
139
            false,
1✔
140
        )
1✔
141
        .clone();
1✔
142

1✔
143
    let select = get_select("SELECT count(fn) AS alias1, ln as alias2 FROM t1").unwrap();
1✔
144
    let processor_factory = ProjectionProcessorFactory::_new(select.projection);
1✔
145
    let r = processor_factory
1✔
146
        .get_output_schema(
1✔
147
            &DEFAULT_PORT_HANDLE,
1✔
148
            &[(DEFAULT_PORT_HANDLE, (schema, SchemaSQLContext::default()))]
1✔
149
                .into_iter()
1✔
150
                .collect(),
1✔
151
        )
1✔
152
        .unwrap()
1✔
153
        .0;
1✔
154

1✔
155
    assert_eq!(
1✔
156
        r,
1✔
157
        Schema::empty()
1✔
158
            .field(
1✔
159
                FieldDefinition::new(
1✔
160
                    String::from("alias1"),
1✔
161
                    FieldType::Text,
1✔
162
                    false,
1✔
163
                    SourceDefinition::Dynamic
1✔
164
                ),
1✔
165
                false,
1✔
166
            )
1✔
167
            .field(
1✔
168
                FieldDefinition::new(
1✔
169
                    String::from("alias2"),
1✔
170
                    FieldType::String,
1✔
171
                    false,
1✔
172
                    SourceDefinition::Dynamic
1✔
173
                ),
1✔
174
                false,
1✔
175
            )
1✔
176
            .clone()
1✔
177
    );
1✔
178
}
1✔
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