embulk-filter-timestamp_hs 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,662 @@
1
+ package org.embulk.filter.timestamp_hs;
2
+
3
+ import com.google.common.base.Joiner;
4
+ import org.embulk.EmbulkTestRuntime;
5
+ import org.embulk.config.ConfigException;
6
+ import org.embulk.config.ConfigLoader;
7
+ import org.embulk.config.ConfigSource;
8
+ import org.embulk.config.TaskSource;
9
+ import org.embulk.spi.*;
10
+ import org.embulk.spi.time.Timestamp;
11
+ import org.embulk.spi.type.Types;
12
+ import org.joda.time.DateTime;
13
+ import org.joda.time.DateTimeZone;
14
+ import org.junit.Rule;
15
+ import org.junit.Test;
16
+ import org.junit.rules.ExpectedException;
17
+ import org.msgpack.value.ValueFactory;
18
+
19
+ import java.util.List;
20
+
21
+ import static org.hamcrest.CoreMatchers.*;
22
+ import static org.junit.Assert.*;
23
+
24
+
25
+ public class TestTimestampHsFilterPlugin {
26
+
27
+ @Rule
28
+ public EmbulkTestRuntime runtime = new EmbulkTestRuntime();
29
+
30
+ @Rule
31
+ public ExpectedException exception = ExpectedException.none();
32
+
33
+ private ConfigSource newConfigSourceFromYaml(String yaml) {
34
+ ConfigLoader loader = new ConfigLoader(Exec.getModelManager());
35
+ return loader.fromYamlString(yaml);
36
+ }
37
+
38
+ @Test
39
+ public void testThrowExceptionAbsentColumnOptions() {
40
+ exception.expect(ConfigException.class);
41
+
42
+ Exec.newConfigSource().loadConfig(
43
+ TimestampHsFilterPlugin.PluginTask.class);
44
+ }
45
+
46
+ @Test
47
+ public void testDefaultConfigs() {
48
+ String configYaml = Joiner.on("\n").join(
49
+ "column_options:",
50
+ " dummy: {}"
51
+ );
52
+ ConfigSource source = newConfigSourceFromYaml(configYaml);
53
+
54
+ TimestampHsFilterPlugin.PluginTask task = source.loadConfig(
55
+ TimestampHsFilterPlugin.PluginTask.class);
56
+
57
+ assertThat(task.getDefaultTimezone(), is(DateTimeZone.UTC));
58
+ assertThat(task.getDefaultTimestampFormat(), is("yyyy-MM-dd hh:mm:ss"));
59
+ }
60
+
61
+ @Test
62
+ public void testDefaultConfigsWhenNullColumnOptions() {
63
+ String configYaml = Joiner.on("\n").join(
64
+ "column_options:",
65
+ " dummy:"
66
+ );
67
+ ConfigSource source = newConfigSourceFromYaml(configYaml);
68
+
69
+ TimestampHsFilterPlugin.PluginTask task = source.loadConfig(
70
+ TimestampHsFilterPlugin.PluginTask.class);
71
+
72
+ assertThat(task.getDefaultTimezone(), is(DateTimeZone.UTC));
73
+ assertThat(task.getDefaultTimestampFormat(), is("yyyy-MM-dd hh:mm:ss"));
74
+ }
75
+
76
+ @Test
77
+ public void testThrowExceptionWhenColumnNameIsNotFound() {
78
+ String configYaml = Joiner.on("\n").join(
79
+ "column_options:",
80
+ " illegal_column_name:"
81
+ );
82
+ ConfigSource config = newConfigSourceFromYaml(configYaml);
83
+
84
+ final Schema inputSchema = Schema.builder()
85
+ .add("string_column", Types.STRING)
86
+ .build();
87
+
88
+ TimestampHsFilterPlugin plugin = new TimestampHsFilterPlugin();
89
+
90
+ exception.expect(SchemaConfigException.class);
91
+
92
+ plugin.transaction(config, inputSchema, new FilterPlugin.Control() {
93
+ @Override
94
+ public void run(TaskSource taskSource, Schema outputSchema) {
95
+ }
96
+ });
97
+ }
98
+
99
+ @Test
100
+ public void testConvertColumnType() {
101
+ String configYaml = Joiner.on("\n").join(
102
+ "column_options:",
103
+ " string_column:"
104
+ );
105
+ ConfigSource config = newConfigSourceFromYaml(configYaml);
106
+
107
+ final Schema inputSchema = Schema.builder()
108
+ .add("string_column", Types.STRING)
109
+ .build();
110
+
111
+ TimestampHsFilterPlugin plugin = new TimestampHsFilterPlugin();
112
+
113
+ plugin.transaction(config, inputSchema, new FilterPlugin.Control() {
114
+ @Override
115
+ public void run(TaskSource taskSource, Schema outputSchema) {
116
+ Column outputColumn = outputSchema.getColumn(0);
117
+ assertEquals(Types.TIMESTAMP, outputColumn.getType());
118
+ }
119
+ });
120
+ }
121
+
122
+ @Test
123
+ public void testNotConvertColumnTypeWhenItIsNotString() {
124
+ String configYaml = Joiner.on("\n").join(
125
+ "column_options:",
126
+ " long_column:"
127
+ );
128
+ ConfigSource config = newConfigSourceFromYaml(configYaml);
129
+
130
+ final Schema inputSchema = Schema.builder()
131
+ .add("long_column", Types.LONG)
132
+ .build();
133
+
134
+ TimestampHsFilterPlugin plugin = new TimestampHsFilterPlugin();
135
+
136
+ plugin.transaction(config, inputSchema, new FilterPlugin.Control() {
137
+ @Override
138
+ public void run(TaskSource taskSource, Schema outputSchema) {
139
+ Column outputColumn = outputSchema.getColumn(0);
140
+ assertEquals(Types.LONG, outputColumn.getType());
141
+ }
142
+ });
143
+ }
144
+
145
+ @Test
146
+ public void testNotConvertColumnTypeWhenNotSpecified() {
147
+ String configYaml = Joiner.on("\n").join(
148
+ "column_options:",
149
+ " string_column1:"
150
+ );
151
+ ConfigSource config = newConfigSourceFromYaml(configYaml);
152
+
153
+ final Schema inputSchema = Schema.builder()
154
+ .add("string_column1", Types.STRING)
155
+ .add("string_column2", Types.STRING)
156
+ .build();
157
+
158
+ TimestampHsFilterPlugin plugin = new TimestampHsFilterPlugin();
159
+
160
+ plugin.transaction(config, inputSchema, new FilterPlugin.Control() {
161
+ @Override
162
+ public void run(TaskSource taskSource, Schema outputSchema) {
163
+ Column outputColumn = outputSchema.getColumn(1);
164
+ assertEquals(Types.STRING, outputColumn.getType());
165
+ }
166
+ });
167
+ }
168
+
169
+ @Test
170
+ public void testSetNullWhenInputColumnIsNull() {
171
+ // TODO: later
172
+ }
173
+
174
+ @Test
175
+ public void testSetOriginalWhenInputTypeIsIllegal() {
176
+ String configYaml = Joiner.on("\n").join(
177
+ "column_options:",
178
+ " long_column:"
179
+ );
180
+ ConfigSource config = newConfigSourceFromYaml(configYaml);
181
+
182
+ final Schema inputSchema = Schema.builder()
183
+ .add("long_column", Types.LONG)
184
+ .build();
185
+
186
+ final TimestampHsFilterPlugin plugin = new TimestampHsFilterPlugin();
187
+
188
+ plugin.transaction(config, inputSchema, new FilterPlugin.Control() {
189
+ @Override
190
+ public void run(TaskSource taskSource, Schema outputSchema) {
191
+ TestPageBuilderReader.MockPageOutput mockPageOutput
192
+ = new TestPageBuilderReader.MockPageOutput();
193
+
194
+ PageOutput pageOutput = plugin.open(
195
+ taskSource,
196
+ inputSchema,
197
+ outputSchema,
198
+ mockPageOutput);
199
+
200
+ List<Page> pages = PageTestUtils.buildPage(
201
+ runtime.getBufferAllocator(),
202
+ inputSchema,
203
+ 12345L);
204
+
205
+ for (Page page : pages) {
206
+ pageOutput.add(page);
207
+ }
208
+ pageOutput.finish();
209
+
210
+ PageReader pageReader = new PageReader(outputSchema);
211
+ pageReader.setPage(mockPageOutput.pages.get(0));
212
+ assertThat(
213
+ pageReader.getLong(outputSchema.getColumn(0)),
214
+ is(12345L));
215
+ }
216
+ });
217
+ }
218
+
219
+ @Test
220
+ public void testSetOriginalString() {
221
+ String configYaml = Joiner.on("\n").join(
222
+ "column_options:",
223
+ " timestamp:"
224
+ );
225
+ ConfigSource config = newConfigSourceFromYaml(configYaml);
226
+
227
+ final Schema inputSchema = Schema.builder()
228
+ .add("string_column", Types.STRING)
229
+ .add("timestamp", Types.STRING)
230
+ .build();
231
+
232
+ final TimestampHsFilterPlugin plugin = new TimestampHsFilterPlugin();
233
+
234
+ plugin.transaction(config, inputSchema, new FilterPlugin.Control() {
235
+ @Override
236
+ public void run(TaskSource taskSource, Schema outputSchema) {
237
+ TestPageBuilderReader.MockPageOutput mockPageOutput
238
+ = new TestPageBuilderReader.MockPageOutput();
239
+
240
+ PageOutput pageOutput = plugin.open(
241
+ taskSource,
242
+ inputSchema,
243
+ outputSchema,
244
+ mockPageOutput);
245
+
246
+ List<Page> pages = PageTestUtils.buildPage(
247
+ runtime.getBufferAllocator(),
248
+ inputSchema,
249
+ "test text",
250
+ "2000-01-01 00:00:00");
251
+
252
+ for (Page page : pages) {
253
+ pageOutput.add(page);
254
+ }
255
+ pageOutput.finish();
256
+
257
+ PageReader pageReader = new PageReader(outputSchema);
258
+ pageReader.setPage(mockPageOutput.pages.get(0));
259
+ assertThat(
260
+ pageReader.getString(outputSchema.getColumn(0)),
261
+ is("test text"));
262
+ }
263
+ });
264
+ }
265
+
266
+ @Test
267
+ public void testSetOriginalBoolean() {
268
+ String configYaml = Joiner.on("\n").join(
269
+ "column_options:",
270
+ " timestamp:"
271
+ );
272
+ ConfigSource config = newConfigSourceFromYaml(configYaml);
273
+
274
+ final Schema inputSchema = Schema.builder()
275
+ .add("boolean_column", Types.BOOLEAN)
276
+ .add("timestamp", Types.STRING)
277
+ .build();
278
+
279
+ final TimestampHsFilterPlugin plugin = new TimestampHsFilterPlugin();
280
+
281
+ plugin.transaction(config, inputSchema, new FilterPlugin.Control() {
282
+ @Override
283
+ public void run(TaskSource taskSource, Schema outputSchema) {
284
+ TestPageBuilderReader.MockPageOutput mockPageOutput
285
+ = new TestPageBuilderReader.MockPageOutput();
286
+
287
+ PageOutput pageOutput = plugin.open(
288
+ taskSource,
289
+ inputSchema,
290
+ outputSchema,
291
+ mockPageOutput);
292
+
293
+ List<Page> pages = PageTestUtils.buildPage(
294
+ runtime.getBufferAllocator(),
295
+ inputSchema,
296
+ true,
297
+ "2000-01-01 00:00:00");
298
+
299
+ for (Page page : pages) {
300
+ pageOutput.add(page);
301
+ }
302
+ pageOutput.finish();
303
+
304
+ PageReader pageReader = new PageReader(outputSchema);
305
+ pageReader.setPage(mockPageOutput.pages.get(0));
306
+ assertThat(
307
+ pageReader.getBoolean(outputSchema.getColumn(0)),
308
+ is(true));
309
+ }
310
+ });
311
+ }
312
+
313
+ @Test
314
+ public void testSetOriginalDouble() {
315
+ String configYaml = Joiner.on("\n").join(
316
+ "column_options:",
317
+ " timestamp:"
318
+ );
319
+ ConfigSource config = newConfigSourceFromYaml(configYaml);
320
+
321
+ final Schema inputSchema = Schema.builder()
322
+ .add("double_column", Types.DOUBLE)
323
+ .add("timestamp", Types.STRING)
324
+ .build();
325
+
326
+ final TimestampHsFilterPlugin plugin = new TimestampHsFilterPlugin();
327
+
328
+ plugin.transaction(config, inputSchema, new FilterPlugin.Control() {
329
+ @Override
330
+ public void run(TaskSource taskSource, Schema outputSchema) {
331
+ TestPageBuilderReader.MockPageOutput mockPageOutput
332
+ = new TestPageBuilderReader.MockPageOutput();
333
+
334
+ PageOutput pageOutput = plugin.open(
335
+ taskSource,
336
+ inputSchema,
337
+ outputSchema,
338
+ mockPageOutput);
339
+
340
+ List<Page> pages = PageTestUtils.buildPage(
341
+ runtime.getBufferAllocator(),
342
+ inputSchema,
343
+ 123.456,
344
+ "2000-01-01 00:00:00");
345
+
346
+ for (Page page : pages) {
347
+ pageOutput.add(page);
348
+ }
349
+ pageOutput.finish();
350
+
351
+ PageReader pageReader = new PageReader(outputSchema);
352
+ pageReader.setPage(mockPageOutput.pages.get(0));
353
+ assertThat(
354
+ pageReader.getDouble(outputSchema.getColumn(0)),
355
+ is(123.456));
356
+ }
357
+ });
358
+ }
359
+
360
+ @Test
361
+ public void testSetOriginalLong() {
362
+ String configYaml = Joiner.on("\n").join(
363
+ "column_options:",
364
+ " timestamp:"
365
+ );
366
+ ConfigSource config = newConfigSourceFromYaml(configYaml);
367
+
368
+ final Schema inputSchema = Schema.builder()
369
+ .add("long_column", Types.LONG)
370
+ .add("timestamp", Types.STRING)
371
+ .build();
372
+
373
+ final TimestampHsFilterPlugin plugin = new TimestampHsFilterPlugin();
374
+
375
+ plugin.transaction(config, inputSchema, new FilterPlugin.Control() {
376
+ @Override
377
+ public void run(TaskSource taskSource, Schema outputSchema) {
378
+ TestPageBuilderReader.MockPageOutput mockPageOutput
379
+ = new TestPageBuilderReader.MockPageOutput();
380
+
381
+ PageOutput pageOutput = plugin.open(
382
+ taskSource,
383
+ inputSchema,
384
+ outputSchema,
385
+ mockPageOutput);
386
+
387
+ List<Page> pages = PageTestUtils.buildPage(
388
+ runtime.getBufferAllocator(),
389
+ inputSchema,
390
+ 12345L,
391
+ "2000-01-01 00:00:00");
392
+
393
+ for (Page page : pages) {
394
+ pageOutput.add(page);
395
+ }
396
+ pageOutput.finish();
397
+
398
+ PageReader pageReader = new PageReader(outputSchema);
399
+ pageReader.setPage(mockPageOutput.pages.get(0));
400
+ assertThat(
401
+ pageReader.getLong(outputSchema.getColumn(0)),
402
+ is(12345L));
403
+ }
404
+ });
405
+ }
406
+
407
+ @Test
408
+ public void testSetOriginalTimestamp() {
409
+ String configYaml = Joiner.on("\n").join(
410
+ "column_options:",
411
+ " timestamp:"
412
+ );
413
+ ConfigSource config = newConfigSourceFromYaml(configYaml);
414
+
415
+ final Schema inputSchema = Schema.builder()
416
+ .add("timestamp_column", Types.TIMESTAMP)
417
+ .add("timestamp", Types.STRING)
418
+ .build();
419
+
420
+ final TimestampHsFilterPlugin plugin = new TimestampHsFilterPlugin();
421
+
422
+ plugin.transaction(config, inputSchema, new FilterPlugin.Control() {
423
+ @Override
424
+ public void run(TaskSource taskSource, Schema outputSchema) {
425
+ TestPageBuilderReader.MockPageOutput mockPageOutput
426
+ = new TestPageBuilderReader.MockPageOutput();
427
+
428
+ PageOutput pageOutput = plugin.open(
429
+ taskSource,
430
+ inputSchema,
431
+ outputSchema,
432
+ mockPageOutput);
433
+
434
+ List<Page> pages = PageTestUtils.buildPage(
435
+ runtime.getBufferAllocator(),
436
+ inputSchema,
437
+ Timestamp.ofEpochMilli(123456789),
438
+ "2000-01-01 00:00:00");
439
+
440
+ for (Page page : pages) {
441
+ pageOutput.add(page);
442
+ }
443
+ pageOutput.finish();
444
+
445
+ PageReader pageReader = new PageReader(outputSchema);
446
+ pageReader.setPage(mockPageOutput.pages.get(0));
447
+ assertThat(
448
+ pageReader.getTimestamp(outputSchema.getColumn(0)),
449
+ is(Timestamp.ofEpochMilli(123456789)));
450
+ }
451
+ });
452
+ }
453
+
454
+ @Test
455
+ public void testSetOriginalJson() {
456
+ String configYaml = Joiner.on("\n").join(
457
+ "column_options:",
458
+ " timestamp:"
459
+ );
460
+ ConfigSource config = newConfigSourceFromYaml(configYaml);
461
+
462
+ final Schema inputSchema = Schema.builder()
463
+ .add("json_column", Types.JSON)
464
+ .add("timestamp", Types.STRING)
465
+ .build();
466
+
467
+ final TimestampHsFilterPlugin plugin = new TimestampHsFilterPlugin();
468
+
469
+ plugin.transaction(config, inputSchema, new FilterPlugin.Control() {
470
+ @Override
471
+ public void run(TaskSource taskSource, Schema outputSchema) {
472
+ TestPageBuilderReader.MockPageOutput mockPageOutput
473
+ = new TestPageBuilderReader.MockPageOutput();
474
+
475
+ PageOutput pageOutput = plugin.open(
476
+ taskSource,
477
+ inputSchema,
478
+ outputSchema,
479
+ mockPageOutput);
480
+
481
+ List<Page> pages = PageTestUtils.buildPage(
482
+ runtime.getBufferAllocator(),
483
+ inputSchema,
484
+ ValueFactory.newInteger(12345).asIntegerValue(),
485
+ "2000-01-01 00:00:00");
486
+
487
+ for (Page page : pages) {
488
+ pageOutput.add(page);
489
+ }
490
+ pageOutput.finish();
491
+
492
+ PageReader pageReader = new PageReader(outputSchema);
493
+ pageReader.setPage(mockPageOutput.pages.get(0));
494
+ assertThat(
495
+ pageReader.getJson(outputSchema.getColumn(0)).immutableValue(),
496
+ is(ValueFactory.newInteger(12345).immutableValue()));
497
+ }
498
+ });
499
+ }
500
+
501
+ @Test
502
+ public void testSetConvertedTimestamp() {
503
+ String configYaml = Joiner.on("\n").join(
504
+ "column_options:",
505
+ " column1: { format: 'yyyy-MM-dd hh:mm:ss.SSS', timezone: 'UTC' }",
506
+ " column2: { format: 'yyyy-MM-dd hh:mm:ss', timezone: 'Asia/Tokyo' }"
507
+ );
508
+ ConfigSource config = newConfigSourceFromYaml(configYaml);
509
+
510
+ final Schema inputSchema = Schema.builder()
511
+ .add("column1", Types.STRING)
512
+ .add("column2", Types.STRING)
513
+ .build();
514
+
515
+ final TimestampHsFilterPlugin plugin = new TimestampHsFilterPlugin();
516
+
517
+ plugin.transaction(config, inputSchema, new FilterPlugin.Control() {
518
+ @Override
519
+ public void run(TaskSource taskSource, Schema outputSchema) {
520
+ TestPageBuilderReader.MockPageOutput mockPageOutput
521
+ = new TestPageBuilderReader.MockPageOutput();
522
+
523
+ PageOutput pageOutput = plugin.open(
524
+ taskSource,
525
+ inputSchema,
526
+ outputSchema,
527
+ mockPageOutput);
528
+
529
+ List<Page> pages = PageTestUtils.buildPage(
530
+ runtime.getBufferAllocator(),
531
+ inputSchema,
532
+ "2000-01-02 10:11:12.123",
533
+ "2010-11-12 20:21:22");
534
+
535
+ for (Page page : pages) {
536
+ pageOutput.add(page);
537
+ }
538
+ pageOutput.finish();
539
+
540
+ PageReader pageReader = new PageReader(outputSchema);
541
+ pageReader.setPage(mockPageOutput.pages.get(0));
542
+
543
+ DateTime expected1 = new DateTime(
544
+ 2000, 1, 2, 10, 11, 12, 123, DateTimeZone.forOffsetHours(0));
545
+ assertThat(
546
+ pageReader.getTimestamp(outputSchema.getColumn(0)),
547
+ is(Timestamp.ofEpochMilli(expected1.getMillis())));
548
+
549
+ DateTime expected2 = new DateTime(
550
+ 2010, 11, 12, 20, 21, 22, DateTimeZone.forOffsetHours(9));
551
+ assertThat(
552
+ pageReader.getTimestamp(outputSchema.getColumn(1)),
553
+ is(Timestamp.ofEpochMilli(expected2.getMillis())));
554
+ }
555
+ });
556
+ }
557
+
558
+ @Test
559
+ public void testSetConvertedTimestampWithDefaultSettings() {
560
+ String configYaml = Joiner.on("\n").join(
561
+ "default_timezone: 'Asia/Tokyo'",
562
+ "default_timestamp_format: 'hh:mm:ss yyyy/MM/dd'",
563
+ "column_options:",
564
+ " column1:",
565
+ " column2: { format: 'yyyy-MM-dd hh:mm:ss', timezone: 'UTC' }"
566
+ );
567
+ ConfigSource config = newConfigSourceFromYaml(configYaml);
568
+
569
+ final Schema inputSchema = Schema.builder()
570
+ .add("column1", Types.STRING)
571
+ .add("column2", Types.STRING)
572
+ .build();
573
+
574
+ final TimestampHsFilterPlugin plugin = new TimestampHsFilterPlugin();
575
+
576
+ plugin.transaction(config, inputSchema, new FilterPlugin.Control() {
577
+ @Override
578
+ public void run(TaskSource taskSource, Schema outputSchema) {
579
+ TestPageBuilderReader.MockPageOutput mockPageOutput
580
+ = new TestPageBuilderReader.MockPageOutput();
581
+
582
+ PageOutput pageOutput = plugin.open(
583
+ taskSource,
584
+ inputSchema,
585
+ outputSchema,
586
+ mockPageOutput);
587
+
588
+ List<Page> pages = PageTestUtils.buildPage(
589
+ runtime.getBufferAllocator(),
590
+ inputSchema,
591
+ "10:11:12 2000/01/02",
592
+ "2010-11-12 20:21:22");
593
+
594
+ for (Page page : pages) {
595
+ pageOutput.add(page);
596
+ }
597
+ pageOutput.finish();
598
+
599
+ PageReader pageReader = new PageReader(outputSchema);
600
+ pageReader.setPage(mockPageOutput.pages.get(0));
601
+
602
+ DateTime expected1 = new DateTime(
603
+ 2000, 1, 2, 10, 11, 12, DateTimeZone.forOffsetHours(9));
604
+ assertThat(
605
+ pageReader.getTimestamp(outputSchema.getColumn(0)),
606
+ is(Timestamp.ofEpochMilli(expected1.getMillis())));
607
+
608
+ DateTime expected2 = new DateTime(
609
+ 2010, 11, 12, 20, 21, 22, DateTimeZone.forOffsetHours(0));
610
+ assertThat(
611
+ pageReader.getTimestamp(outputSchema.getColumn(1)),
612
+ is(Timestamp.ofEpochMilli(expected2.getMillis())));
613
+ }
614
+ });
615
+ }
616
+
617
+ @Test
618
+ public void testThrowExceptionWhenIllegalFormat() {
619
+ String configYaml = Joiner.on("\n").join(
620
+ "column_options:",
621
+ " column: { format: 'yyyy-MM-dd hh:mm:ss' }"
622
+ );
623
+ ConfigSource config = newConfigSourceFromYaml(configYaml);
624
+
625
+ final Schema inputSchema = Schema.builder()
626
+ .add("column", Types.STRING)
627
+ .build();
628
+
629
+ final TimestampHsFilterPlugin plugin = new TimestampHsFilterPlugin();
630
+
631
+ plugin.transaction(config, inputSchema, new FilterPlugin.Control() {
632
+ @Override
633
+ public void run(TaskSource taskSource, Schema outputSchema) {
634
+ TestPageBuilderReader.MockPageOutput mockPageOutput
635
+ = new TestPageBuilderReader.MockPageOutput();
636
+
637
+ PageOutput pageOutput = plugin.open(
638
+ taskSource,
639
+ inputSchema,
640
+ outputSchema,
641
+ mockPageOutput);
642
+
643
+ List<Page> pages = PageTestUtils.buildPage(
644
+ runtime.getBufferAllocator(),
645
+ inputSchema,
646
+ "timestamp");
647
+
648
+ for (Page page : pages) {
649
+ pageOutput.add(page);
650
+ }
651
+ pageOutput.finish();
652
+
653
+ PageReader pageReader = new PageReader(outputSchema);
654
+ pageReader.setPage(mockPageOutput.pages.get(0));
655
+ assertThat(
656
+ pageReader.getTimestamp(outputSchema.getColumn(0)),
657
+ is(Timestamp.ofEpochMilli(0)));
658
+ }
659
+ });
660
+ }
661
+
662
+ }