-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathTests.ecl
596 lines (532 loc) · 30.2 KB
/
Tests.ecl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
IMPORT $ AS DataPatterns;
IMPORT Std;
/**
* This self-test module can be executed with the following code:
*
* IMPORT DataPatterns;
* EVALUATE(DataPatterns.Tests);
*
* WARNING: The tests may take a minute or two to complete when running on
* on Thor. Run the tests on hthor or ROXIE for better performance.
*/
EXPORT Tests := MODULE
EXPORT Engine_Test := OUTPUT(Std.System.Job.Platform(), NAMED('Execution_Engine'));
//--------------------------------------------------------------------------
// Useful functions
//--------------------------------------------------------------------------
SHARED ValueForAttr(ds, attrNameStr, f) := FUNCTIONMACRO
RETURN ds(attribute = attrNameStr)[1].f;
ENDMACRO;
//--------------------------------------------------------------------------
// Baseline string test
//--------------------------------------------------------------------------
SHARED Basic_String := DATASET
(
[
'Dan', 'Steve', '', 'Mike', 'Dan', 'Sebastian', 'Dan'
],
{STRING s}
);
SHARED Basic_String_Profile := DataPatterns.Profile(NOFOLD(Basic_String));
EXPORT Test_Basic_String_Profile :=
[
ASSERT(Basic_String_Profile[1].attribute = 's'),
ASSERT(Basic_String_Profile[1].rec_count = 7),
ASSERT(Basic_String_Profile[1].given_attribute_type = 'string'),
ASSERT((DECIMAL9_6)Basic_String_Profile[1].fill_rate = (DECIMAL9_6)85.714286),
ASSERT(Basic_String_Profile[1].fill_count = 6),
ASSERT(Basic_String_Profile[1].cardinality = 4),
ASSERT(Basic_String_Profile[1].best_attribute_type = 'string9'),
ASSERT(COUNT(Basic_String_Profile[1].modes) = 1),
ASSERT(Basic_String_Profile[1].modes[1].value = 'Dan'),
ASSERT(Basic_String_Profile[1].modes[1].rec_count = 3),
ASSERT(Basic_String_Profile[1].min_length = 3),
ASSERT(Basic_String_Profile[1].max_length = 9),
ASSERT(Basic_String_Profile[1].ave_length = 4),
ASSERT(COUNT(Basic_String_Profile[1].popular_patterns) = 4),
ASSERT(Basic_String_Profile[1].popular_patterns[1].data_pattern = 'Aaa'),
ASSERT(Basic_String_Profile[1].popular_patterns[1].rec_count = 3),
ASSERT(Basic_String_Profile[1].popular_patterns[2].data_pattern = 'Aaaa'),
ASSERT(Basic_String_Profile[1].popular_patterns[2].rec_count = 1),
ASSERT(Basic_String_Profile[1].popular_patterns[3].data_pattern = 'Aaaaa'),
ASSERT(Basic_String_Profile[1].popular_patterns[3].rec_count = 1),
ASSERT(Basic_String_Profile[1].popular_patterns[4].data_pattern = 'Aaaaaaaaa'),
ASSERT(Basic_String_Profile[1].popular_patterns[4].rec_count = 1),
ASSERT(COUNT(Basic_String_Profile[1].rare_patterns) = 0),
ASSERT(Basic_String_Profile[1].is_numeric = FALSE),
ASSERT(Basic_String_Profile[1].numeric_min = 0),
ASSERT(Basic_String_Profile[1].numeric_max = 0),
ASSERT(Basic_String_Profile[1].numeric_mean = 0),
ASSERT(Basic_String_Profile[1].numeric_std_dev = 0),
ASSERT(Basic_String_Profile[1].numeric_lower_quartile = 0),
ASSERT(Basic_String_Profile[1].numeric_median = 0),
ASSERT(Basic_String_Profile[1].numeric_upper_quartile = 0),
ASSERT(COUNT(Basic_String_Profile[1].correlations) = 0),
ASSERT(TRUE)
];
//--------------------------------------------------------------------------
// Baseline numeric test
//--------------------------------------------------------------------------
SHARED Basic_Numeric := DATASET
(
[
-1000, 500, -250, 2000, 1500, -2000, 2000
],
{INTEGER n}
);
SHARED Basic_Numeric_Profile := DataPatterns.Profile(NOFOLD(Basic_Numeric));
EXPORT Test_Basic_Numeric_Profile :=
[
ASSERT(Basic_Numeric_Profile[1].attribute = 'n'),
ASSERT(Basic_Numeric_Profile[1].rec_count = 7),
ASSERT(Basic_Numeric_Profile[1].given_attribute_type = 'integer8'),
ASSERT(Basic_Numeric_Profile[1].fill_rate = 100),
ASSERT(Basic_Numeric_Profile[1].fill_count = 7),
ASSERT(Basic_Numeric_Profile[1].cardinality = 6),
ASSERT(Basic_Numeric_Profile[1].best_attribute_type = 'integer8'),
ASSERT(COUNT(Basic_Numeric_Profile[1].modes) = 1),
ASSERT(Basic_Numeric_Profile[1].modes[1].value = '2000'),
ASSERT(Basic_Numeric_Profile[1].modes[1].rec_count = 2),
ASSERT(Basic_Numeric_Profile[1].min_length = 3),
ASSERT(Basic_Numeric_Profile[1].max_length = 5),
ASSERT(Basic_Numeric_Profile[1].ave_length = 4),
ASSERT(COUNT(Basic_Numeric_Profile[1].popular_patterns) = 4),
ASSERT(Basic_Numeric_Profile[1].popular_patterns[1].data_pattern = '9999'),
ASSERT(Basic_Numeric_Profile[1].popular_patterns[1].rec_count = 3),
ASSERT(Basic_Numeric_Profile[1].popular_patterns[2].data_pattern = '-9999'),
ASSERT(Basic_Numeric_Profile[1].popular_patterns[2].rec_count = 2),
ASSERT(Basic_Numeric_Profile[1].popular_patterns[3].data_pattern = '-999'),
ASSERT(Basic_Numeric_Profile[1].popular_patterns[3].rec_count = 1),
ASSERT(Basic_Numeric_Profile[1].popular_patterns[4].data_pattern = '999'),
ASSERT(Basic_Numeric_Profile[1].popular_patterns[4].rec_count = 1),
ASSERT(COUNT(Basic_Numeric_Profile[1].rare_patterns) = 0),
ASSERT(Basic_Numeric_Profile[1].is_numeric = TRUE),
ASSERT(Basic_Numeric_Profile[1].numeric_min = -2000),
ASSERT(Basic_Numeric_Profile[1].numeric_max = 2000),
ASSERT(Basic_Numeric_Profile[1].numeric_mean = 392.8571),
ASSERT(Basic_Numeric_Profile[1].numeric_std_dev = 1438.3593),
ASSERT(Basic_Numeric_Profile[1].numeric_lower_quartile = -1000),
ASSERT(Basic_Numeric_Profile[1].numeric_median = 500),
ASSERT(Basic_Numeric_Profile[1].numeric_upper_quartile = 2000),
ASSERT(COUNT(Basic_Numeric_Profile[1].correlations) = 0),
ASSERT(TRUE)
];
//--------------------------------------------------------------------------
// Empty data detection
//--------------------------------------------------------------------------
// Layout contains every ECL data type that Profile can process (except for
// SET OF datatypes, child records, and child datasets)
SHARED EmptyDataLayout := RECORD
BOOLEAN f_boolean;
INTEGER f_integer;
UNSIGNED f_unsigned;
UNSIGNED INTEGER f_unsigned_integer;
BIG_ENDIAN INTEGER f_big_endian_integer;
BIG_ENDIAN UNSIGNED f_big_endian_unsigned;
BIG_ENDIAN UNSIGNED INTEGER f_big_endian_unsigned_integer;
LITTLE_ENDIAN INTEGER f_little_endian_integer;
LITTLE_ENDIAN UNSIGNED f_little_endian_unsigned;
LITTLE_ENDIAN UNSIGNED INTEGER f_little_endian_unsigned_integer;
REAL f_real;
DECIMAL32 f_decimal32;
DECIMAL32_6 f_decimal32_6;
UDECIMAL32 f_udecimal32;
UDECIMAL32_6 f_udecimal32_6;
UNSIGNED DECIMAL32 f_unsigned_decimal32;
UNSIGNED DECIMAL32_6 f_unsigned_decimal32_6;
STRING f_string;
STRING256 f_string256;
ASCII STRING f_ascii_string;
ASCII STRING256 f_ascii_string256;
EBCDIC STRING f_ebcdic_string;
EBCDIC STRING256 f_ebcdic_string256;
QSTRING f_qstring;
QSTRING256 f_qstring256;
UNICODE f_unicode;
UNICODE_de f_unicode_de;
UNICODE256 f_unicode256;
UNICODE_de256 f_unicode_de256;
UTF8 f_utf8;
UTF8_de f_utf8_de;
DATA f_data;
DATA16 f_data16;
VARSTRING f_varstring;
VARSTRING256 f_varstring256;
VARUNICODE f_varunicode;
VARUNICODE_de f_varunicode_de;
VARUNICODE256 f_varunicode256;
VARUNICODE_de256 f_varunicode_de256;
END;
SHARED Empty_Data := DATASET
(
1,
TRANSFORM
(
EmptyDataLayout,
SELF := []
)
);
SHARED Empty_Data_Profile := DataPatterns.Profile(NOFOLD(Empty_Data), features := 'cardinality,best_ecl_types,lengths,modes,patterns');
// Convenience function for testing the same thing for several attributes
SHARED TestEmptyAttr(STRING attributeName) :=
[
ASSERT(ValueForAttr(Empty_Data_Profile, attributeName, cardinality) = 0),
ASSERT(ValueForAttr(Empty_Data_Profile, attributeName, best_attribute_type) = ValueForAttr(Empty_Data_Profile, attributeName, given_attribute_type)),
ASSERT(ValueForAttr(Empty_Data_Profile, attributeName, min_length) = 0),
ASSERT(ValueForAttr(Empty_Data_Profile, attributeName, max_length) = 0),
ASSERT(ValueForAttr(Empty_Data_Profile, attributeName, ave_length) = 0),
ASSERT(COUNT(ValueForAttr(Empty_Data_Profile, attributeName, popular_patterns)) = 0),
ASSERT(COUNT(ValueForAttr(Empty_Data_Profile, attributeName, rare_patterns)) = 0),
ASSERT(TRUE)
];
EXPORT Test_Empty_Data_Profile :=
[
TestEmptyAttr('f_ascii_string'),
TestEmptyAttr('f_ascii_string16'),
TestEmptyAttr('f_big_endian_integer'),
TestEmptyAttr('f_big_endian_unsigned'),
TestEmptyAttr('f_big_endian_unsigned_integer'),
TestEmptyAttr('f_data'),
TestEmptyAttr('f_decimal32'),
TestEmptyAttr('f_decimal32_6'),
TestEmptyAttr('f_ebcdic_string'),
TestEmptyAttr('f_ebcdic_string16'),
TestEmptyAttr('f_integer'),
TestEmptyAttr('f_little_endian_integer'),
TestEmptyAttr('f_little_endian_unsigned'),
TestEmptyAttr('f_little_endian_unsigned_integer'),
TestEmptyAttr('f_qstring'),
TestEmptyAttr('f_qstring16'),
TestEmptyAttr('f_real'),
TestEmptyAttr('f_string'),
TestEmptyAttr('f_string16'),
TestEmptyAttr('f_udecimal32'),
TestEmptyAttr('f_udecimal32_6'),
TestEmptyAttr('f_unicode'),
TestEmptyAttr('f_unicode16'),
TestEmptyAttr('f_unicode_de'),
TestEmptyAttr('f_unicode_de16'),
TestEmptyAttr('f_unsigned'),
TestEmptyAttr('f_unsigned_decimal32'),
TestEmptyAttr('f_unsigned_decimal32_6'),
TestEmptyAttr('f_unsigned_integer'),
TestEmptyAttr('f_utf8'),
TestEmptyAttr('f_utf8_de'),
TestEmptyAttr('f_varstring'),
TestEmptyAttr('f_varstring16'),
TestEmptyAttr('f_varunicode'),
TestEmptyAttr('f_varunicode16'),
TestEmptyAttr('f_varunicode_de'),
TestEmptyAttr('f_varunicode_de16'),
// Handle BOOLEAN special because it is not truly empty
ASSERT(ValueForAttr(Empty_Data_Profile, 'f_boolean', cardinality) = 1),
ASSERT(ValueForAttr(Empty_Data_Profile, 'f_boolean', best_attribute_type) = ValueForAttr(Empty_Data_Profile, 'f_boolean', given_attribute_type)),
ASSERT(ValueForAttr(Empty_Data_Profile, 'f_boolean', min_length) = 1),
ASSERT(ValueForAttr(Empty_Data_Profile, 'f_boolean', max_length) = 1),
ASSERT(ValueForAttr(Empty_Data_Profile, 'f_boolean', ave_length) = 1),
ASSERT(COUNT(ValueForAttr(Empty_Data_Profile, 'f_boolean', popular_patterns)) = 1),
ASSERT(COUNT(ValueForAttr(Empty_Data_Profile, 'f_boolean', rare_patterns)) = 0),
// Handle fixed-length DATA special because it is not truly empty
ASSERT(ValueForAttr(Empty_Data_Profile, 'f_data16', cardinality) = 1),
ASSERT(ValueForAttr(Empty_Data_Profile, 'f_data16', best_attribute_type) = ValueForAttr(Empty_Data_Profile, 'f_data16', given_attribute_type)),
ASSERT(ValueForAttr(Empty_Data_Profile, 'f_data16', min_length) = 16),
ASSERT(ValueForAttr(Empty_Data_Profile, 'f_data16', max_length) = 16),
ASSERT(ValueForAttr(Empty_Data_Profile, 'f_data16', ave_length) = 16),
ASSERT(COUNT(ValueForAttr(Empty_Data_Profile, 'f_data16', popular_patterns)) = 1),
ASSERT(COUNT(ValueForAttr(Empty_Data_Profile, 'f_data16', rare_patterns)) = 0),
ASSERT(TRUE)
];
//--------------------------------------------------------------------------
// Unicode pattern detection
//--------------------------------------------------------------------------
SHARED Pattern_Unicode := DATASET
(
[
U'abcd\353', U'ABCDË'
],
{UNICODE_de5 s}
);
SHARED Pattern_Unicode_Profile := DataPatterns.Profile(NOFOLD(Pattern_Unicode), features := 'patterns');
EXPORT Test_Pattern_Unicode_Profile :=
[
ASSERT(Pattern_Unicode_Profile[1].given_attribute_type = 'unicode_de5'),
ASSERT(COUNT(Pattern_Unicode_Profile[1].popular_patterns) = 2),
ASSERT(Pattern_Unicode_Profile[1].popular_patterns[1].data_pattern = 'AAAAA'),
ASSERT(Pattern_Unicode_Profile[1].popular_patterns[1].rec_count = 1),
ASSERT(Pattern_Unicode_Profile[1].popular_patterns[2].data_pattern = 'aaaaa'),
ASSERT(Pattern_Unicode_Profile[1].popular_patterns[2].rec_count = 1),
ASSERT(TRUE)
];
//--------------------------------------------------------------------------
// Punctuation pattern test
//--------------------------------------------------------------------------
SHARED Pattern_Punctuation := DATASET
(
[
'This! Is- Not. Helpful?'
],
{STRING s}
);
SHARED Pattern_Punctuation_Profile := DataPatterns.Profile(NOFOLD(Pattern_Punctuation), features := 'patterns');
EXPORT Test_Pattern_Punctuation_Profile :=
[
ASSERT(Pattern_Punctuation_Profile[1].attribute = 's'),
ASSERT(COUNT(Pattern_Punctuation_Profile[1].popular_patterns) = 1),
ASSERT(Pattern_Punctuation_Profile[1].popular_patterns[1].data_pattern = 'Aaaa! Aa- Aaa. Aaaaaaa?'),
ASSERT(Pattern_Punctuation_Profile[1].popular_patterns[1].rec_count = 1),
ASSERT(TRUE)
];
//--------------------------------------------------------------------------
// Finding integers within strings test
//--------------------------------------------------------------------------
SHARED Best_Integer := DATASET
(
[
{'-100', '-100', '-1000', '-10000', '-100000'},
{'100', '100', '1000', '10000', '100000'}
],
{STRING s1, STRING s2, STRING s3, STRING s4, STRING s5}
);
SHARED Best_Integer_Profile := DataPatterns.Profile(NOFOLD(Best_Integer), features := 'best_ecl_types');
EXPORT Test_Best_Integer_Profile :=
[
ASSERT(ValueForAttr(Best_Integer_Profile, 's1', best_attribute_type) = 'integer2'),
ASSERT(ValueForAttr(Best_Integer_Profile, 's2', best_attribute_type) = 'integer2'),
ASSERT(ValueForAttr(Best_Integer_Profile, 's3', best_attribute_type) = 'integer3'),
ASSERT(ValueForAttr(Best_Integer_Profile, 's4', best_attribute_type) = 'integer3'),
ASSERT(ValueForAttr(Best_Integer_Profile, 's5', best_attribute_type) = 'integer4'),
ASSERT(TRUE)
];
//--------------------------------------------------------------------------
// Finding unsigned integers within strings test
//--------------------------------------------------------------------------
SHARED Best_Unsigned := DATASET
(
[
{'100', '100', '1000', '10000', '100000'}
],
{STRING s1, STRING s2, STRING s3, STRING s4, STRING s5}
);
SHARED Best_Unsigned_Profile := DataPatterns.Profile(NOFOLD(Best_Unsigned), features := 'best_ecl_types');
EXPORT Test_Best_Unsigned_Profile :=
[
ASSERT(ValueForAttr(Best_Unsigned_Profile, 's1', best_attribute_type) = 'unsigned2'),
ASSERT(ValueForAttr(Best_Unsigned_Profile, 's2', best_attribute_type) = 'unsigned2'),
ASSERT(ValueForAttr(Best_Unsigned_Profile, 's3', best_attribute_type) = 'unsigned2'),
ASSERT(ValueForAttr(Best_Unsigned_Profile, 's4', best_attribute_type) = 'unsigned3'),
ASSERT(ValueForAttr(Best_Unsigned_Profile, 's5', best_attribute_type) = 'unsigned3'),
ASSERT(TRUE)
];
//--------------------------------------------------------------------------
// Finding reals within strings test
//--------------------------------------------------------------------------
SHARED Best_Real := DATASET
(
[
{'99.99', '-99.99', '9.1234e-10', '.123', '99.0'}
],
{STRING s1, STRING s2, STRING s3, STRING s4, STRING s5}
);
SHARED Best_Real_Profile := DataPatterns.Profile(NOFOLD(Best_Real), features := 'best_ecl_types');
EXPORT Test_Best_Real_Profile :=
[
ASSERT(ValueForAttr(Best_Real_Profile, 's1', best_attribute_type) = 'real4'),
ASSERT(ValueForAttr(Best_Real_Profile, 's2', best_attribute_type) = 'real4'),
ASSERT(ValueForAttr(Best_Real_Profile, 's3', best_attribute_type) = 'real8'),
ASSERT(ValueForAttr(Best_Real_Profile, 's4', best_attribute_type) = 'real4'),
ASSERT(ValueForAttr(Best_Real_Profile, 's5', best_attribute_type) = 'real4'),
ASSERT(TRUE)
];
//--------------------------------------------------------------------------
// Not actually numbers test
//--------------------------------------------------------------------------
SHARED Best_NaN := DATASET
(
[
{'123456789012345678901', '-12345678901234567890', '9.1234e-1000', '99.1234567890123456', '123456789012345678901.0'}
],
{STRING s1, STRING s2, STRING s3, STRING s4, STRING s5}
);
SHARED Best_NaN_Profile := DataPatterns.Profile(NOFOLD(Best_NaN), features := 'best_ecl_types');
EXPORT Test_Best_NaN_Profile :=
[
ASSERT(ValueForAttr(Best_NaN_Profile, 's1', best_attribute_type) = 'string21'),
ASSERT(ValueForAttr(Best_NaN_Profile, 's2', best_attribute_type) = 'string21'),
ASSERT(ValueForAttr(Best_NaN_Profile, 's3', best_attribute_type) = 'string12'),
ASSERT(ValueForAttr(Best_NaN_Profile, 's4', best_attribute_type) = 'string19'),
ASSERT(ValueForAttr(Best_NaN_Profile, 's5', best_attribute_type) = 'string23'),
ASSERT(TRUE)
];
//--------------------------------------------------------------------------
// Embedded child record test
//--------------------------------------------------------------------------
SHARED Embedded_Child1 := DATASET
(
[
{'Dan', {123, 345, 567}},
{'Mike', {987, 765, 543}}
],
{STRING s, {UNSIGNED4 x, UNSIGNED4 y, UNSIGNED4 z} foo}
);
SHARED Embedded_Child1_Profile := DataPatterns.Profile(NOFOLD(Embedded_Child1));
EXPORT Test_Embedded_Child1_Profile :=
[
ASSERT(Embedded_Child1_Profile(attribute = 'foo.x')[1].attribute = 'foo.x'),
ASSERT(Embedded_Child1_Profile(attribute = 'foo.x')[1].rec_count = 2),
ASSERT(Embedded_Child1_Profile(attribute = 'foo.x')[1].given_attribute_type = 'unsigned4'),
ASSERT((DECIMAL9_6)Embedded_Child1_Profile(attribute = 'foo.x')[1].fill_rate = (DECIMAL9_6)100),
ASSERT(Embedded_Child1_Profile(attribute = 'foo.x')[1].fill_count = 2),
ASSERT(Embedded_Child1_Profile(attribute = 'foo.x')[1].cardinality = 2),
ASSERT(Embedded_Child1_Profile(attribute = 'foo.x')[1].best_attribute_type = 'unsigned4'),
ASSERT(Embedded_Child1_Profile(attribute = 'foo.x')[1].min_length = 3),
ASSERT(Embedded_Child1_Profile(attribute = 'foo.x')[1].max_length = 3),
ASSERT(Embedded_Child1_Profile(attribute = 'foo.x')[1].ave_length = 3),
ASSERT(COUNT(Embedded_Child1_Profile(attribute = 'foo.x')[1].popular_patterns) = 1),
ASSERT(COUNT(Embedded_Child1_Profile(attribute = 'foo.x')[1].rare_patterns) = 0),
ASSERT(Embedded_Child1_Profile(attribute = 'foo.x')[1].is_numeric = TRUE),
ASSERT(Embedded_Child1_Profile(attribute = 'foo.x')[1].numeric_min = 123),
ASSERT(Embedded_Child1_Profile(attribute = 'foo.x')[1].numeric_max = 987),
ASSERT(Embedded_Child1_Profile(attribute = 'foo.x')[1].numeric_mean = 555),
ASSERT(Embedded_Child1_Profile(attribute = 'foo.x')[1].numeric_std_dev = 432),
ASSERT(Embedded_Child1_Profile(attribute = 'foo.x')[1].numeric_lower_quartile = 123),
ASSERT(Embedded_Child1_Profile(attribute = 'foo.x')[1].numeric_median = 555),
ASSERT(Embedded_Child1_Profile(attribute = 'foo.x')[1].numeric_upper_quartile = 0),
ASSERT(COUNT(Embedded_Child1_Profile(attribute = 'foo.x')[1].correlations) = 2),
ASSERT(Embedded_Child1_Profile(attribute = 'foo.y')[1].attribute = 'foo.y'),
ASSERT(Embedded_Child1_Profile(attribute = 'foo.y')[1].rec_count = 2),
ASSERT(Embedded_Child1_Profile(attribute = 'foo.y')[1].given_attribute_type = 'unsigned4'),
ASSERT((DECIMAL9_6)Embedded_Child1_Profile(attribute = 'foo.y')[1].fill_rate = (DECIMAL9_6)100),
ASSERT(Embedded_Child1_Profile(attribute = 'foo.y')[1].fill_count = 2),
ASSERT(Embedded_Child1_Profile(attribute = 'foo.y')[1].cardinality = 2),
ASSERT(Embedded_Child1_Profile(attribute = 'foo.y')[1].best_attribute_type = 'unsigned4'),
ASSERT(Embedded_Child1_Profile(attribute = 'foo.y')[1].min_length = 3),
ASSERT(Embedded_Child1_Profile(attribute = 'foo.y')[1].max_length = 3),
ASSERT(Embedded_Child1_Profile(attribute = 'foo.y')[1].ave_length = 3),
ASSERT(COUNT(Embedded_Child1_Profile(attribute = 'foo.y')[1].popular_patterns) = 1),
ASSERT(COUNT(Embedded_Child1_Profile(attribute = 'foo.y')[1].rare_patterns) = 0),
ASSERT(Embedded_Child1_Profile(attribute = 'foo.y')[1].is_numeric = TRUE),
ASSERT(Embedded_Child1_Profile(attribute = 'foo.y')[1].numeric_min = 345),
ASSERT(Embedded_Child1_Profile(attribute = 'foo.y')[1].numeric_max = 765),
ASSERT(Embedded_Child1_Profile(attribute = 'foo.y')[1].numeric_mean = 555),
ASSERT(Embedded_Child1_Profile(attribute = 'foo.y')[1].numeric_std_dev = 210),
ASSERT(Embedded_Child1_Profile(attribute = 'foo.y')[1].numeric_lower_quartile = 345),
ASSERT(Embedded_Child1_Profile(attribute = 'foo.y')[1].numeric_median = 555),
ASSERT(Embedded_Child1_Profile(attribute = 'foo.y')[1].numeric_upper_quartile = 0),
ASSERT(COUNT(Embedded_Child1_Profile(attribute = 'foo.y')[1].correlations) = 2),
ASSERT(Embedded_Child1_Profile(attribute = 'foo.z')[1].attribute = 'foo.z'),
ASSERT(Embedded_Child1_Profile(attribute = 'foo.z')[1].rec_count = 2),
ASSERT(Embedded_Child1_Profile(attribute = 'foo.z')[1].given_attribute_type = 'unsigned4'),
ASSERT((DECIMAL9_6)Embedded_Child1_Profile(attribute = 'foo.z')[1].fill_rate = (DECIMAL9_6)100),
ASSERT(Embedded_Child1_Profile(attribute = 'foo.z')[1].fill_count = 2),
ASSERT(Embedded_Child1_Profile(attribute = 'foo.z')[1].cardinality = 2),
ASSERT(Embedded_Child1_Profile(attribute = 'foo.z')[1].best_attribute_type = 'unsigned4'),
ASSERT(Embedded_Child1_Profile(attribute = 'foo.z')[1].min_length = 3),
ASSERT(Embedded_Child1_Profile(attribute = 'foo.z')[1].max_length = 3),
ASSERT(Embedded_Child1_Profile(attribute = 'foo.z')[1].ave_length = 3),
ASSERT(COUNT(Embedded_Child1_Profile(attribute = 'foo.z')[1].popular_patterns) = 1),
ASSERT(COUNT(Embedded_Child1_Profile(attribute = 'foo.z')[1].rare_patterns) = 0),
ASSERT(Embedded_Child1_Profile(attribute = 'foo.z')[1].is_numeric = TRUE),
ASSERT(Embedded_Child1_Profile(attribute = 'foo.z')[1].numeric_min = 543),
ASSERT(Embedded_Child1_Profile(attribute = 'foo.z')[1].numeric_max = 567),
ASSERT(Embedded_Child1_Profile(attribute = 'foo.z')[1].numeric_mean = 555),
ASSERT(Embedded_Child1_Profile(attribute = 'foo.z')[1].numeric_std_dev = 12),
ASSERT(Embedded_Child1_Profile(attribute = 'foo.z')[1].numeric_lower_quartile = 543),
ASSERT(Embedded_Child1_Profile(attribute = 'foo.z')[1].numeric_median = 555),
ASSERT(Embedded_Child1_Profile(attribute = 'foo.z')[1].numeric_upper_quartile = 0),
ASSERT(COUNT(Embedded_Child1_Profile(attribute = 'foo.z')[1].correlations) = 2),
ASSERT(TRUE)
];
//--------------------------------------------------------------------------
// Test strings fields containing numerics with leading zeros (issue 42)
//--------------------------------------------------------------------------
SHARED Leading_Zeros := DATASET
(
[
{'0100', '1234', '0001', '7809', '-0600'},
{'0020', '0001', '0023', '0001', '600'}
],
{STRING s1, STRING s2, STRING s3, STRING s4, STRING s5}
);
SHARED Leading_Zeros_Profile := DataPatterns.Profile(NOFOLD(Leading_Zeros), features := 'best_ecl_types');
EXPORT Test_Leading_Zeros_Profile :=
[
ASSERT(ValueForAttr(Leading_Zeros_Profile, 's1', best_attribute_type) = 'string4'),
ASSERT(ValueForAttr(Leading_Zeros_Profile, 's2', best_attribute_type) = 'string4'),
ASSERT(ValueForAttr(Leading_Zeros_Profile, 's3', best_attribute_type) = 'string4'),
ASSERT(ValueForAttr(Leading_Zeros_Profile, 's4', best_attribute_type) = 'string4'),
ASSERT(ValueForAttr(Leading_Zeros_Profile, 's5', best_attribute_type) = 'integer3'),
ASSERT(TRUE)
];
//--------------------------------------------------------------------------
// String fields with wildly varying lengths (three orders of magnitude
// difference) should become variable-length 'string' datatypes
//--------------------------------------------------------------------------
SHARED STRING MLS(UNSIGNED4 len) := EMBED(C++)
const char letters[] = "abcdefghijklmnopqrstuvwxyz0123456789";
__lenResult = len;
__result = static_cast<char*>(rtlMalloc(__lenResult));
for (uint32_t x = 0; x < len; x++)
__result[x] = letters[rand() % 36];
ENDEMBED;
SHARED Large_Strings := DATASET
(
[
{'abcd', '1234', '0001', '7', '-0600'},
{'0020', MLS(5000), MLS(500), MLS(1050), '600'}
],
{STRING s1, STRING s2, STRING s3, STRING s4, STRING s5}
);
SHARED Large_Strings_Profile := DataPatterns.Profile(NOFOLD(Large_Strings), features := 'best_ecl_types');
EXPORT Test_Large_Strings_Profile :=
[
ASSERT(ValueForAttr(Large_Strings_Profile, 's1', best_attribute_type) = 'string4'),
ASSERT(ValueForAttr(Large_Strings_Profile, 's2', best_attribute_type) = 'string'),
ASSERT(ValueForAttr(Large_Strings_Profile, 's3', best_attribute_type) = 'string500'),
ASSERT(ValueForAttr(Large_Strings_Profile, 's4', best_attribute_type) = 'string'),
ASSERT(ValueForAttr(Large_Strings_Profile, 's5', best_attribute_type) = 'integer3'),
ASSERT(TRUE)
];
//--------------------------------------------------------------------------
// Test strings fields containing numerics with leading zeros (issue 42)
//--------------------------------------------------------------------------
SHARED SetOf_Types := DATASET
(
[
{1, [1,2,3,4]},
{100, [9,8]},
{200, [4,4,4,4,4,4,4,4,4,4,4]},
{300, []},
{150, [5,6]}
],
{
UNSIGNED2 n,
SET OF UNSIGNED2 my_set
}
);
SHARED SetOf_Types_Profile := DataPatterns.Profile(NOFOLD(SetOf_Types));
EXPORT Test_SetOf_Types_Profile :=
[
ASSERT(SetOf_Types_Profile(attribute = 'my_set')[1].attribute = 'my_set'),
ASSERT(SetOf_Types_Profile(attribute = 'my_set')[1].rec_count = 5),
ASSERT(SetOf_Types_Profile(attribute = 'my_set')[1].given_attribute_type = 'set of unsigned2'),
ASSERT((DECIMAL9_6)SetOf_Types_Profile(attribute = 'my_set')[1].fill_rate = (DECIMAL9_6)80),
ASSERT(SetOf_Types_Profile(attribute = 'my_set')[1].fill_count = 4),
ASSERT(SetOf_Types_Profile(attribute = 'my_set')[1].cardinality = 4),
ASSERT(SetOf_Types_Profile(attribute = 'my_set')[1].best_attribute_type = 'set of unsigned2'),
ASSERT(SetOf_Types_Profile(attribute = 'my_set')[1].min_length = 2),
ASSERT(SetOf_Types_Profile(attribute = 'my_set')[1].max_length = 11),
ASSERT(SetOf_Types_Profile(attribute = 'my_set')[1].ave_length = 4),
ASSERT(COUNT(SetOf_Types_Profile(attribute = 'my_set')[1].popular_patterns) = 3),
ASSERT(COUNT(SetOf_Types_Profile(attribute = 'my_set')[1].rare_patterns) = 0),
ASSERT(SetOf_Types_Profile(attribute = 'my_set')[1].is_numeric = FALSE),
ASSERT(SetOf_Types_Profile(attribute = 'my_set')[1].numeric_min = 0),
ASSERT(SetOf_Types_Profile(attribute = 'my_set')[1].numeric_max = 0),
ASSERT(SetOf_Types_Profile(attribute = 'my_set')[1].numeric_mean = 0),
ASSERT(SetOf_Types_Profile(attribute = 'my_set')[1].numeric_std_dev = 0),
ASSERT(SetOf_Types_Profile(attribute = 'my_set')[1].numeric_lower_quartile = 0),
ASSERT(SetOf_Types_Profile(attribute = 'my_set')[1].numeric_median = 0),
ASSERT(SetOf_Types_Profile(attribute = 'my_set')[1].numeric_upper_quartile = 0),
ASSERT(COUNT(SetOf_Types_Profile(attribute = 'my_set')[1].correlations) = 0),
ASSERT(TRUE)
];
END;