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

getdozer / dozer / 3966459377

pending completion
3966459377

push

github

GitHub
fix: `CONCAT()` to support multiple arguments  (#690)

58 of 58 new or added lines in 3 files covered. (100.0%)

21911 of 32779 relevant lines covered (66.84%)

36246.75 hits per line

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

94.12
/dozer-sql/src/pipeline/expression/scalar/tests/string.rs
1
use crate::pipeline::expression::execution::Expression::Literal;
2
use crate::pipeline::expression::scalar::{
3
    string::evaluate_like, tests::scalar_common::run_scalar_fct,
4
};
5
use dozer_types::types::{Field, FieldDefinition, FieldType, Record, Schema};
6

7
#[test]
1✔
8
fn test_concat() {
1✔
9
    let f = run_scalar_fct(
1✔
10
        "SELECT CONCAT(fn, ln, fn) FROM USERS",
1✔
11
        Schema::empty()
1✔
12
            .field(
1✔
13
                FieldDefinition::new(String::from("fn"), FieldType::String, false),
1✔
14
                false,
1✔
15
            )
1✔
16
            .field(
1✔
17
                FieldDefinition::new(String::from("ln"), FieldType::String, false),
1✔
18
                false,
1✔
19
            )
1✔
20
            .clone(),
1✔
21
        vec![
1✔
22
            Field::String("John".to_string()),
1✔
23
            Field::String("Doe".to_string()),
1✔
24
        ],
1✔
25
    );
1✔
26
    assert_eq!(f, Field::String("JohnDoeJohn".to_string()));
1✔
27
}
1✔
28

29
#[test]
1✔
30
fn test_concat_text() {
1✔
31
    let f = run_scalar_fct(
1✔
32
        "SELECT CONCAT(fn, ln, fn) FROM USERS",
1✔
33
        Schema::empty()
1✔
34
            .field(
1✔
35
                FieldDefinition::new(String::from("fn"), FieldType::Text, false),
1✔
36
                false,
1✔
37
            )
1✔
38
            .field(
1✔
39
                FieldDefinition::new(String::from("ln"), FieldType::String, false),
1✔
40
                false,
1✔
41
            )
1✔
42
            .clone(),
1✔
43
        vec![
1✔
44
            Field::Text("John".to_string()),
1✔
45
            Field::String("Doe".to_string()),
1✔
46
        ],
1✔
47
    );
1✔
48
    assert_eq!(f, Field::Text("JohnDoeJohn".to_string()));
1✔
49
}
1✔
50

51
#[test]
1✔
52
fn test_concat_text_empty() {
1✔
53
    let f = run_scalar_fct(
1✔
54
        "SELECT CONCAT() FROM USERS",
1✔
55
        Schema::empty()
1✔
56
            .field(
1✔
57
                FieldDefinition::new(String::from("fn"), FieldType::String, false),
1✔
58
                false,
1✔
59
            )
1✔
60
            .field(
1✔
61
                FieldDefinition::new(String::from("ln"), FieldType::String, false),
1✔
62
                false,
1✔
63
            )
1✔
64
            .clone(),
1✔
65
        vec![
1✔
66
            Field::String("John".to_string()),
1✔
67
            Field::String("Doe".to_string()),
1✔
68
        ],
1✔
69
    );
1✔
70
    assert_eq!(f, Field::String("".to_string()));
1✔
71
}
1✔
72

×
73
#[test]
1✔
74
#[should_panic]
×
75
fn test_concat_wrong_schema() {
1✔
76
    let f = run_scalar_fct(
1✔
77
        "SELECT CONCAT(fn, ln) FROM USERS",
1✔
78
        Schema::empty()
1✔
79
            .field(
1✔
80
                FieldDefinition::new(String::from("fn"), FieldType::String, false),
1✔
81
                false,
1✔
82
            )
1✔
83
            .field(
1✔
84
                FieldDefinition::new(String::from("ln"), FieldType::Int, false),
1✔
85
                false,
1✔
86
            )
1✔
87
            .clone(),
1✔
88
        vec![Field::String("John".to_string()), Field::Int(0)],
1✔
89
    );
1✔
90
    assert_eq!(f, Field::String("JohnDoe".to_string()));
1✔
91
}
1✔
92

×
93
#[test]
1✔
94
fn test_ucase() {
1✔
95
    let f = run_scalar_fct(
1✔
96
        "SELECT UCASE(fn) FROM USERS",
1✔
97
        Schema::empty()
1✔
98
            .field(
1✔
99
                FieldDefinition::new(String::from("fn"), FieldType::String, false),
1✔
100
                false,
1✔
101
            )
1✔
102
            .clone(),
1✔
103
        vec![Field::String("John".to_string())],
1✔
104
    );
1✔
105
    assert_eq!(f, Field::String("JOHN".to_string()));
1✔
106
}
1✔
107

×
108
#[test]
1✔
109
fn test_ucase_text() {
1✔
110
    let f = run_scalar_fct(
1✔
111
        "SELECT UCASE(fn) FROM USERS",
1✔
112
        Schema::empty()
1✔
113
            .field(
1✔
114
                FieldDefinition::new(String::from("fn"), FieldType::Text, false),
1✔
115
                false,
1✔
116
            )
1✔
117
            .clone(),
1✔
118
        vec![Field::Text("John".to_string())],
1✔
119
    );
1✔
120
    assert_eq!(f, Field::Text("JOHN".to_string()));
1✔
121
}
1✔
122

×
123
#[test]
1✔
124
fn test_length() {
1✔
125
    let f = run_scalar_fct(
1✔
126
        "SELECT LENGTH(fn) FROM USERS",
1✔
127
        Schema::empty()
1✔
128
            .field(
1✔
129
                FieldDefinition::new(String::from("fn"), FieldType::String, false),
1✔
130
                false,
1✔
131
            )
1✔
132
            .clone(),
1✔
133
        vec![Field::String("John".to_string())],
1✔
134
    );
1✔
135
    assert_eq!(f, Field::UInt(4));
1✔
136
}
1✔
137

×
138
#[test]
1✔
139
fn test_trim() {
1✔
140
    let f = run_scalar_fct(
1✔
141
        "SELECT TRIM(fn) FROM USERS",
1✔
142
        Schema::empty()
1✔
143
            .field(
1✔
144
                FieldDefinition::new(String::from("fn"), FieldType::String, false),
1✔
145
                false,
1✔
146
            )
1✔
147
            .clone(),
1✔
148
        vec![Field::String("   John   ".to_string())],
1✔
149
    );
1✔
150
    assert_eq!(f, Field::String("John".to_string()));
1✔
151
}
1✔
152

×
153
#[test]
1✔
154
fn test_trim_null() {
1✔
155
    let f = run_scalar_fct(
1✔
156
        "SELECT TRIM(fn) FROM USERS",
1✔
157
        Schema::empty()
1✔
158
            .field(
1✔
159
                FieldDefinition::new(String::from("fn"), FieldType::String, false),
1✔
160
                false,
1✔
161
            )
1✔
162
            .clone(),
1✔
163
        vec![Field::Null],
1✔
164
    );
1✔
165
    assert_eq!(f, Field::String("".to_string()));
1✔
166
}
1✔
167

×
168
#[test]
1✔
169
fn test_trim_text() {
1✔
170
    let f = run_scalar_fct(
1✔
171
        "SELECT TRIM(fn) FROM USERS",
1✔
172
        Schema::empty()
1✔
173
            .field(
1✔
174
                FieldDefinition::new(String::from("fn"), FieldType::Text, false),
1✔
175
                false,
1✔
176
            )
1✔
177
            .clone(),
1✔
178
        vec![Field::Text("   John   ".to_string())],
1✔
179
    );
1✔
180
    assert_eq!(f, Field::Text("John".to_string()));
1✔
181
}
1✔
182

×
183
#[test]
1✔
184
fn test_trim_value() {
1✔
185
    let f = run_scalar_fct(
1✔
186
        "SELECT TRIM('_' FROM fn) FROM USERS",
1✔
187
        Schema::empty()
1✔
188
            .field(
1✔
189
                FieldDefinition::new(String::from("fn"), FieldType::String, false),
1✔
190
                false,
1✔
191
            )
1✔
192
            .clone(),
1✔
193
        vec![Field::String("___John___".to_string())],
1✔
194
    );
1✔
195
    assert_eq!(f, Field::String("John".to_string()));
1✔
196
}
1✔
197

×
198
#[test]
1✔
199
fn test_btrim_value() {
1✔
200
    let f = run_scalar_fct(
1✔
201
        "SELECT TRIM(BOTH '_' FROM fn) FROM USERS",
1✔
202
        Schema::empty()
1✔
203
            .field(
1✔
204
                FieldDefinition::new(String::from("fn"), FieldType::String, false),
1✔
205
                false,
1✔
206
            )
1✔
207
            .clone(),
1✔
208
        vec![Field::String("___John___".to_string())],
1✔
209
    );
1✔
210
    assert_eq!(f, Field::String("John".to_string()));
1✔
211
}
1✔
212

×
213
#[test]
1✔
214
fn test_ltrim_value() {
1✔
215
    let f = run_scalar_fct(
1✔
216
        "SELECT TRIM(LEADING '_' FROM fn) FROM USERS",
1✔
217
        Schema::empty()
1✔
218
            .field(
1✔
219
                FieldDefinition::new(String::from("fn"), FieldType::String, false),
1✔
220
                false,
1✔
221
            )
1✔
222
            .clone(),
1✔
223
        vec![Field::String("___John___".to_string())],
1✔
224
    );
1✔
225
    assert_eq!(f, Field::String("John___".to_string()));
1✔
226
}
1✔
227

×
228
#[test]
1✔
229
fn test_ttrim_value() {
1✔
230
    let f = run_scalar_fct(
1✔
231
        "SELECT TRIM(TRAILING '_' FROM fn) FROM USERS",
1✔
232
        Schema::empty()
1✔
233
            .field(
1✔
234
                FieldDefinition::new(String::from("fn"), FieldType::String, false),
1✔
235
                false,
1✔
236
            )
1✔
237
            .clone(),
1✔
238
        vec![Field::String("___John___".to_string())],
1✔
239
    );
1✔
240
    assert_eq!(f, Field::String("___John".to_string()));
1✔
241
}
1✔
242

×
243
#[test]
1✔
244
fn test_like() {
1✔
245
    let row = Record::new(None, vec![], None);
1✔
246

1✔
247
    let value = Box::new(Literal(Field::String("Hello, World!".to_owned())));
1✔
248
    let pattern = Box::new(Literal(Field::String("Hello%".to_owned())));
1✔
249

1✔
250
    assert_eq!(
1✔
251
        evaluate_like(&Schema::empty(), &value, &pattern, None, &row).unwrap(),
1✔
252
        Field::Boolean(true)
1✔
253
    );
1✔
254

×
255
    let value = Box::new(Literal(Field::String("Hello, World!".to_owned())));
1✔
256
    let pattern = Box::new(Literal(Field::String("Hello, _orld!".to_owned())));
1✔
257

1✔
258
    assert_eq!(
1✔
259
        evaluate_like(&Schema::empty(), &value, &pattern, None, &row).unwrap(),
1✔
260
        Field::Boolean(true)
1✔
261
    );
1✔
262

×
263
    let value = Box::new(Literal(Field::String("Bye, World!".to_owned())));
1✔
264
    let pattern = Box::new(Literal(Field::String("Hello%".to_owned())));
1✔
265

1✔
266
    assert_eq!(
1✔
267
        evaluate_like(&Schema::empty(), &value, &pattern, None, &row).unwrap(),
1✔
268
        Field::Boolean(false)
1✔
269
    );
1✔
270

×
271
    let value = Box::new(Literal(Field::String("Hello, World!".to_owned())));
1✔
272
    let pattern = Box::new(Literal(Field::String("Hello, _!".to_owned())));
1✔
273

1✔
274
    assert_eq!(
1✔
275
        evaluate_like(&Schema::empty(), &value, &pattern, None, &row).unwrap(),
1✔
276
        Field::Boolean(false)
1✔
277
    );
1✔
278

×
279
    let value = Box::new(Literal(Field::String("Hello, $%".to_owned())));
1✔
280
    let pattern = Box::new(Literal(Field::String("Hello, %".to_owned())));
1✔
281
    let escape = Some('$');
1✔
282

1✔
283
    assert_eq!(
1✔
284
        evaluate_like(&Schema::empty(), &value, &pattern, escape, &row).unwrap(),
1✔
285
        Field::Boolean(true)
1✔
286
    );
1✔
287
}
1✔
288

×
289
#[test]
1✔
290
fn test_like_value() {
1✔
291
    let f = run_scalar_fct(
1✔
292
        "SELECT first_name FROM users WHERE first_name LIKE 'J%'",
1✔
293
        Schema::empty()
1✔
294
            .field(
1✔
295
                FieldDefinition::new(String::from("first_name"), FieldType::String, false),
1✔
296
                false,
1✔
297
            )
1✔
298
            .clone(),
1✔
299
        vec![Field::String("John".to_string())],
1✔
300
    );
1✔
301
    assert_eq!(f, Field::String("John".to_string()));
1✔
302
}
1✔
303

×
304
#[test]
1✔
305
fn test_not_like_value() {
1✔
306
    let f = run_scalar_fct(
1✔
307
        "SELECT first_name FROM users WHERE first_name NOT LIKE 'A%'",
1✔
308
        Schema::empty()
1✔
309
            .field(
1✔
310
                FieldDefinition::new(String::from("first_name"), FieldType::String, false),
1✔
311
                false,
1✔
312
            )
1✔
313
            .clone(),
1✔
314
        vec![Field::String("John".to_string())],
1✔
315
    );
1✔
316
    assert_eq!(f, Field::String("John".to_string()));
1✔
317
}
1✔
318

319
#[test]
1✔
320
fn test_like_escape() {
1✔
321
    let f = run_scalar_fct(
1✔
322
        "SELECT first_name FROM users WHERE first_name LIKE 'J$%'",
1✔
323
        Schema::empty()
1✔
324
            .field(
1✔
325
                FieldDefinition::new(String::from("first_name"), FieldType::String, false),
1✔
326
                false,
1✔
327
            )
1✔
328
            .clone(),
1✔
329
        vec![Field::String("J%".to_string())],
1✔
330
    );
1✔
331
    assert_eq!(f, Field::String("J%".to_string()));
1✔
332
}
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

© 2026 Coveralls, Inc