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

getdozer / dozer / 3978628498

pending completion
3978628498

Pull #705

github

GitHub
Merge 8775fcda7 into e2f9ad287
Pull Request #705: chore: support for generic schema context in `Sink`, `Processor` and `Source` factories

572 of 572 new or added lines in 35 files covered. (100.0%)

22294 of 34850 relevant lines covered (63.97%)

40332.28 hits per line

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

93.85
/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};
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("int_field".to_string(), FieldType::Int, false),
1✔
18
            false,
1✔
19
        )
1✔
20
        .field(
1✔
21
            FieldDefinition::new("str_field".to_string(), FieldType::String, false),
1✔
22
            false,
1✔
23
        )
1✔
24
        .field(
1✔
25
            FieldDefinition::new("float_field".to_string(), FieldType::Float, false),
1✔
26
            false,
1✔
27
        )
1✔
28
        .clone();
1✔
29

1✔
30
    let record = Record::new(
1✔
31
        None,
1✔
32
        vec![
1✔
33
            Field::Int(1337),
1✔
34
            Field::String("test".to_string()),
1✔
35
            Field::Float(OrderedFloat(10.10)),
1✔
36
        ],
1✔
37
        None,
1✔
38
    );
1✔
39

1✔
40
    // Column
1✔
41
    let e = Expression::Column { index: 0 };
1✔
42
    assert_eq!(
1✔
43
        e.evaluate(&record, &schema)
1✔
44
            .unwrap_or_else(|e| panic!("{}", e.to_string())),
1✔
45
        Field::Int(1337)
1✔
46
    );
1✔
47

×
48
    let e = Expression::Column { index: 1 };
1✔
49
    assert_eq!(
1✔
50
        e.evaluate(&record, &schema)
1✔
51
            .unwrap_or_else(|e| panic!("{}", e.to_string())),
1✔
52
        Field::String("test".to_string())
1✔
53
    );
1✔
54

×
55
    let e = Expression::Column { index: 2 };
1✔
56
    assert_eq!(
1✔
57
        e.evaluate(&record, &schema)
1✔
58
            .unwrap_or_else(|e| panic!("{}", e.to_string())),
1✔
59
        Field::Float(OrderedFloat(10.10))
1✔
60
    );
1✔
61

62
    // Literal
×
63
    let e = Expression::Literal(Field::Int(1337));
1✔
64
    assert_eq!(
1✔
65
        e.evaluate(&record, &schema)
1✔
66
            .unwrap_or_else(|e| panic!("{}", e.to_string())),
1✔
67
        Field::Int(1337)
1✔
68
    );
1✔
69

70
    // UnaryOperator
×
71
    let e = Expression::UnaryOperator {
1✔
72
        operator: UnaryOperatorType::Not,
1✔
73
        arg: Box::new(Expression::Literal(Field::Boolean(true))),
1✔
74
    };
1✔
75
    assert_eq!(
1✔
76
        e.evaluate(&record, &schema)
1✔
77
            .unwrap_or_else(|e| panic!("{}", e.to_string())),
1✔
78
        Field::Boolean(false)
1✔
79
    );
1✔
80

81
    // BinaryOperator
×
82
    let e = Expression::BinaryOperator {
1✔
83
        left: Box::new(Expression::Literal(Field::Boolean(true))),
1✔
84
        operator: BinaryOperatorType::And,
1✔
85
        right: Box::new(Expression::Literal(Field::Boolean(false))),
1✔
86
    };
1✔
87
    assert_eq!(
1✔
88
        e.evaluate(&record, &schema)
1✔
89
            .unwrap_or_else(|e| panic!("{}", e.to_string())),
1✔
90
        Field::Boolean(false),
1✔
91
    );
1✔
92

93
    // ScalarFunction
×
94
    let e = Expression::ScalarFunction {
1✔
95
        fun: ScalarFunctionType::Abs,
1✔
96
        args: vec![Expression::Literal(Field::Int(-1))],
1✔
97
    };
1✔
98
    assert_eq!(
1✔
99
        e.evaluate(&record, &schema)
1✔
100
            .unwrap_or_else(|e| panic!("{}", e.to_string())),
1✔
101
        Field::Int(1)
1✔
102
    );
1✔
103
}
1✔
104

×
105
#[test]
1✔
106
fn test_alias() {
1✔
107
    let schema = Schema::empty()
1✔
108
        .field(
1✔
109
            FieldDefinition::new(String::from("fn"), FieldType::Text, false),
1✔
110
            false,
1✔
111
        )
1✔
112
        .field(
1✔
113
            FieldDefinition::new(String::from("ln"), FieldType::String, false),
1✔
114
            false,
1✔
115
        )
1✔
116
        .clone();
1✔
117

1✔
118
    let select = get_select("SELECT count(fn) AS alias1, ln as alias2 FROM t1").unwrap();
1✔
119
    let processor_factory = ProjectionProcessorFactory::_new(select.projection);
1✔
120
    let r = processor_factory
1✔
121
        .get_output_schema(
1✔
122
            &DEFAULT_PORT_HANDLE,
1✔
123
            &[(DEFAULT_PORT_HANDLE, (schema, SchemaSQLContext {}))]
1✔
124
                .into_iter()
1✔
125
                .collect(),
1✔
126
        )
1✔
127
        .unwrap()
1✔
128
        .0;
1✔
129

1✔
130
    assert_eq!(
1✔
131
        r,
1✔
132
        Schema::empty()
1✔
133
            .field(
1✔
134
                FieldDefinition::new(String::from("alias1"), FieldType::Text, false),
1✔
135
                false,
1✔
136
            )
1✔
137
            .field(
1✔
138
                FieldDefinition::new(String::from("alias2"), FieldType::String, false),
1✔
139
                false,
1✔
140
            )
1✔
141
            .clone()
1✔
142
    );
1✔
143
}
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