embulk-output-mysql 0.7.7 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +21 -0
  3. data/build.gradle +3 -3
  4. data/classpath/embulk-output-jdbc-0.8.0.jar +0 -0
  5. data/classpath/embulk-output-mysql-0.8.0.jar +0 -0
  6. data/default_jdbc_driver/mysql-connector-java-5.1.44.jar +0 -0
  7. data/src/main/java/org/embulk/output/MySQLOutputPlugin.java +56 -16
  8. data/src/main/java/org/embulk/output/MySQLTimeZoneComparison.java +107 -0
  9. data/src/main/java/org/embulk/output/mysql/MySQLOutputConnection.java +14 -5
  10. data/src/main/java/org/embulk/output/mysql/MySQLOutputConnector.java +3 -8
  11. data/src/test/java/org/embulk/output/mysql/AfterLoadTest.java +136 -0
  12. data/src/test/java/org/embulk/output/mysql/BeforeLoadTest.java +124 -0
  13. data/src/test/java/org/embulk/output/mysql/CreateTableTest.java +79 -0
  14. data/src/test/java/org/embulk/output/mysql/MySQLTests.java +69 -0
  15. data/src/test/resources/org/embulk/output/mysql/test/expect/after_load/setup.sql +8 -0
  16. data/src/test/resources/org/embulk/output/mysql/test/expect/after_load/test1.csv +4 -0
  17. data/src/test/resources/org/embulk/output/mysql/test/expect/after_load/test_expected.diff +2 -0
  18. data/src/test/resources/org/embulk/output/mysql/test/expect/after_load/test_insert_after_load.yml +3 -0
  19. data/src/test/resources/org/embulk/output/mysql/test/expect/after_load/test_insert_after_load_expected.csv +5 -0
  20. data/src/test/resources/org/embulk/output/mysql/test/expect/after_load/test_insert_direct_after_load.yml +3 -0
  21. data/src/test/resources/org/embulk/output/mysql/test/expect/after_load/test_merge_after_load.yml +3 -0
  22. data/src/test/resources/org/embulk/output/mysql/test/expect/after_load/test_merge_after_load_expected.csv +5 -0
  23. data/src/test/resources/org/embulk/output/mysql/test/expect/after_load/test_merge_direct_after_load.yml +3 -0
  24. data/src/test/resources/org/embulk/output/mysql/test/expect/after_load/test_replace_after_load.yml +3 -0
  25. data/src/test/resources/org/embulk/output/mysql/test/expect/after_load/test_replace_after_load_expected.csv +3 -0
  26. data/src/test/resources/org/embulk/output/mysql/test/expect/after_load/test_truncate_insert_after_load.yml +3 -0
  27. data/src/test/resources/org/embulk/output/mysql/test/expect/after_load/test_truncate_insert_after_load_expected.csv +3 -0
  28. data/src/test/resources/org/embulk/output/mysql/test/expect/before_load/setup.sql +8 -0
  29. data/src/test/resources/org/embulk/output/mysql/test/expect/before_load/test1.csv +4 -0
  30. data/src/test/resources/org/embulk/output/mysql/test/expect/before_load/test_expected.diff +2 -0
  31. data/src/test/resources/org/embulk/output/mysql/test/expect/before_load/test_insert_before_load.yml +3 -0
  32. data/src/test/resources/{mysql/data/test1.csv → org/embulk/output/mysql/test/expect/before_load/test_insert_before_load_expected.csv} +1 -0
  33. data/src/test/resources/org/embulk/output/mysql/test/expect/before_load/test_insert_direct_before_load.yml +3 -0
  34. data/src/test/resources/org/embulk/output/mysql/test/expect/before_load/test_merge_before_load.yml +3 -0
  35. data/src/test/resources/org/embulk/output/mysql/test/expect/before_load/test_merge_before_load_expected.csv +4 -0
  36. data/src/test/resources/org/embulk/output/mysql/test/expect/before_load/test_merge_direct_before_load.yml +3 -0
  37. data/src/test/resources/org/embulk/output/mysql/test/expect/before_load/test_truncate_insert_before_load.yml +3 -0
  38. data/src/test/resources/org/embulk/output/mysql/test/expect/before_load/test_truncate_insert_before_load_expected.csv +4 -0
  39. data/src/test/resources/org/embulk/output/mysql/test/expect/create_table/setup.sql +1 -0
  40. data/src/test/resources/org/embulk/output/mysql/test/expect/create_table/test1.csv +4 -0
  41. data/src/test/resources/org/embulk/output/mysql/test/expect/create_table/test_table_constraint.yml +5 -0
  42. data/src/test/resources/org/embulk/output/mysql/test/expect/create_table/test_table_constraint_expected.csv +3 -0
  43. data/src/test/resources/org/embulk/output/mysql/test/expect/create_table/test_table_option.yml +5 -0
  44. data/src/test/resources/org/embulk/output/mysql/test/expect/create_table/test_table_option_expected.csv +3 -0
  45. metadata +40 -18
  46. data/classpath/embulk-output-jdbc-0.7.7.jar +0 -0
  47. data/classpath/embulk-output-mysql-0.7.7.jar +0 -0
  48. data/classpath/mysql-connector-java-5.1.34.jar +0 -0
  49. data/src/test/java/org/embulk/output/mysql/MySQLOutputPluginTest.java +0 -569
  50. data/src/test/resources/mysql/yml/test-insert-after-load.yml +0 -22
  51. data/src/test/resources/mysql/yml/test-insert-before-load.yml +0 -22
  52. data/src/test/resources/mysql/yml/test-insert-direct-after-load.yml +0 -22
  53. data/src/test/resources/mysql/yml/test-insert-direct-before-load.yml +0 -22
  54. data/src/test/resources/mysql/yml/test-merge-after-load.yml +0 -22
  55. data/src/test/resources/mysql/yml/test-merge-before-load.yml +0 -22
  56. data/src/test/resources/mysql/yml/test-merge-direct-after-load.yml +0 -22
  57. data/src/test/resources/mysql/yml/test-merge-direct-before-load.yml +0 -22
  58. data/src/test/resources/mysql/yml/test-replace-after-load.yml +0 -22
  59. data/src/test/resources/mysql/yml/test-truncate-insert-after-load.yml +0 -22
  60. data/src/test/resources/mysql/yml/test-truncate-insert-before-load.yml +0 -22
@@ -1,569 +0,0 @@
1
- package org.embulk.output.mysql;
2
-
3
- import static java.util.Locale.ENGLISH;
4
- import static org.junit.Assert.assertEquals;
5
-
6
- import java.sql.Connection;
7
- import java.sql.DriverManager;
8
- import java.sql.SQLException;
9
- import java.util.Iterator;
10
- import java.util.List;
11
-
12
- import org.embulk.output.AbstractJdbcOutputPluginTest;
13
- import org.embulk.output.MySQLOutputPlugin;
14
- import org.embulk.spi.OutputPlugin;
15
- import org.junit.Test;
16
-
17
-
18
- public class MySQLOutputPluginTest extends AbstractJdbcOutputPluginTest
19
- {
20
- @Override
21
- protected void prepare() throws SQLException
22
- {
23
- tester.addPlugin(OutputPlugin.class, "mysql", MySQLOutputPlugin.class);
24
-
25
- try {
26
- connect();
27
- } catch (SQLException e) {
28
- System.err.println(e);
29
- System.err.println(String.format(ENGLISH, "Warning: prepare a schema on MySQL (server = %s, port = %d, database = %s, user = %s, password = %s).",
30
- getHost(), getPort(), getDatabase(), getUser(), getPassword()));
31
- return;
32
- }
33
-
34
- enabled = true;
35
- }
36
-
37
- @Test
38
- public void testInsertDirectBeforeLoad() throws Exception
39
- {
40
- if (!enabled) {
41
- return;
42
- }
43
-
44
- String table = "test1";
45
-
46
- dropTable(table);
47
- createTable(table);
48
- executeSQL(String.format("INSERT INTO %s VALUES('B001', 0, 'z')", table));
49
- executeSQL(String.format("INSERT INTO %s VALUES('B002', 9, 'z')", table));
50
-
51
- test("/mysql/yml/test-insert-direct-before-load.yml");
52
-
53
- List<List<Object>> rows = select(table);
54
- assertEquals(4, rows.size());
55
- Iterator<List<Object>> i1 = rows.iterator();
56
- {
57
- Iterator<Object> i2 = i1.next().iterator();
58
- assertEquals("A001", i2.next());
59
- assertEquals(9, i2.next());
60
- assertEquals("a", i2.next());
61
- }
62
- {
63
- Iterator<Object> i2 = i1.next().iterator();
64
- assertEquals("A002", i2.next());
65
- assertEquals(0, i2.next());
66
- assertEquals("b", i2.next());
67
- }
68
- {
69
- Iterator<Object> i2 = i1.next().iterator();
70
- assertEquals("A003", i2.next());
71
- assertEquals(9, i2.next());
72
- assertEquals("c", i2.next());
73
- }
74
- {
75
- Iterator<Object> i2 = i1.next().iterator();
76
- assertEquals("B001", i2.next());
77
- assertEquals(0, i2.next());
78
- assertEquals("z", i2.next());
79
- }
80
- }
81
-
82
- @Test
83
- public void testInsertBeforeLoad() throws Exception
84
- {
85
- if (!enabled) {
86
- return;
87
- }
88
-
89
- String table = "test1";
90
-
91
- dropTable(table);
92
- createTable(table);
93
- executeSQL(String.format("INSERT INTO %s VALUES('B001', 0, 'z')", table));
94
- executeSQL(String.format("INSERT INTO %s VALUES('B002', 9, 'z')", table));
95
-
96
- test("/mysql/yml/test-insert-before-load.yml");
97
-
98
- List<List<Object>> rows = select(table);
99
- assertEquals(4, rows.size());
100
- Iterator<List<Object>> i1 = rows.iterator();
101
- {
102
- Iterator<Object> i2 = i1.next().iterator();
103
- assertEquals("A001", i2.next());
104
- assertEquals(9, i2.next());
105
- assertEquals("a", i2.next());
106
- }
107
- {
108
- Iterator<Object> i2 = i1.next().iterator();
109
- assertEquals("A002", i2.next());
110
- assertEquals(0, i2.next());
111
- assertEquals("b", i2.next());
112
- }
113
- {
114
- Iterator<Object> i2 = i1.next().iterator();
115
- assertEquals("A003", i2.next());
116
- assertEquals(9, i2.next());
117
- assertEquals("c", i2.next());
118
- }
119
- {
120
- Iterator<Object> i2 = i1.next().iterator();
121
- assertEquals("B001", i2.next());
122
- assertEquals(0, i2.next());
123
- assertEquals("z", i2.next());
124
- }
125
- }
126
-
127
- @Test
128
- public void testTruncateInsertBeforeLoad() throws Exception
129
- {
130
- if (!enabled) {
131
- return;
132
- }
133
-
134
- String table = "test1";
135
-
136
- dropTable(table);
137
- createTable(table);
138
- executeSQL(String.format("INSERT INTO %s VALUES('B001', 0, 'z')", table));
139
- executeSQL(String.format("INSERT INTO %s VALUES('B002', 9, 'z')", table));
140
-
141
- test("/mysql/yml/test-truncate-insert-before-load.yml");
142
-
143
- List<List<Object>> rows = select(table);
144
- assertEquals(4, rows.size());
145
- Iterator<List<Object>> i1 = rows.iterator();
146
- {
147
- Iterator<Object> i2 = i1.next().iterator();
148
- assertEquals("A001", i2.next());
149
- assertEquals(9, i2.next());
150
- assertEquals("a", i2.next());
151
- }
152
- {
153
- Iterator<Object> i2 = i1.next().iterator();
154
- assertEquals("A002", i2.next());
155
- assertEquals(0, i2.next());
156
- assertEquals("b", i2.next());
157
- }
158
- {
159
- Iterator<Object> i2 = i1.next().iterator();
160
- assertEquals("A003", i2.next());
161
- assertEquals(9, i2.next());
162
- assertEquals("c", i2.next());
163
- }
164
- {
165
- Iterator<Object> i2 = i1.next().iterator();
166
- assertEquals("C001", i2.next());
167
- assertEquals(0, i2.next());
168
- assertEquals("x", i2.next());
169
- }
170
- }
171
-
172
- @Test
173
- public void testMergeDirectBeforeLoad() throws Exception
174
- {
175
- if (!enabled) {
176
- return;
177
- }
178
-
179
- String table = "test1";
180
-
181
- dropTable(table);
182
- createTable(table);
183
- executeSQL(String.format("INSERT INTO %s VALUES('A002', 1, 'y')", table));
184
- executeSQL(String.format("INSERT INTO %s VALUES('A003', 1, 'y')", table));
185
- executeSQL(String.format("INSERT INTO %s VALUES('B001', 0, 'z')", table));
186
- executeSQL(String.format("INSERT INTO %s VALUES('B002', 9, 'z')", table));
187
-
188
- test("/mysql/yml/test-merge-direct-before-load.yml");
189
-
190
- List<List<Object>> rows = select(table);
191
- assertEquals(4, rows.size());
192
- Iterator<List<Object>> i1 = rows.iterator();
193
- {
194
- Iterator<Object> i2 = i1.next().iterator();
195
- assertEquals("A001", i2.next());
196
- assertEquals(9, i2.next());
197
- assertEquals("a", i2.next());
198
- }
199
- {
200
- Iterator<Object> i2 = i1.next().iterator();
201
- assertEquals("A002", i2.next());
202
- assertEquals(0, i2.next());
203
- assertEquals("b", i2.next());
204
- }
205
- {
206
- Iterator<Object> i2 = i1.next().iterator();
207
- assertEquals("A003", i2.next());
208
- assertEquals(9, i2.next());
209
- assertEquals("c", i2.next());
210
- }
211
- {
212
- Iterator<Object> i2 = i1.next().iterator();
213
- assertEquals("B001", i2.next());
214
- assertEquals(0, i2.next());
215
- assertEquals("z", i2.next());
216
- }
217
- }
218
-
219
- @Test
220
- public void testMergeBeforeLoad() throws Exception
221
- {
222
- if (!enabled) {
223
- return;
224
- }
225
-
226
- String table = "test1";
227
-
228
- dropTable(table);
229
- createTable(table);
230
- executeSQL(String.format("INSERT INTO %s VALUES('A002', 1, 'y')", table));
231
- executeSQL(String.format("INSERT INTO %s VALUES('A003', 1, 'y')", table));
232
- executeSQL(String.format("INSERT INTO %s VALUES('B001', 0, 'z')", table));
233
- executeSQL(String.format("INSERT INTO %s VALUES('B002', 9, 'z')", table));
234
-
235
- test("/mysql/yml/test-merge-before-load.yml");
236
-
237
- List<List<Object>> rows = select(table);
238
- assertEquals(4, rows.size());
239
- Iterator<List<Object>> i1 = rows.iterator();
240
- {
241
- Iterator<Object> i2 = i1.next().iterator();
242
- assertEquals("A001", i2.next());
243
- assertEquals(9, i2.next());
244
- assertEquals("a", i2.next());
245
- }
246
- {
247
- Iterator<Object> i2 = i1.next().iterator();
248
- assertEquals("A002", i2.next());
249
- assertEquals(0, i2.next());
250
- assertEquals("b", i2.next());
251
- }
252
- {
253
- Iterator<Object> i2 = i1.next().iterator();
254
- assertEquals("A003", i2.next());
255
- assertEquals(9, i2.next());
256
- assertEquals("c", i2.next());
257
- }
258
- {
259
- Iterator<Object> i2 = i1.next().iterator();
260
- assertEquals("B001", i2.next());
261
- assertEquals(0, i2.next());
262
- assertEquals("z", i2.next());
263
- }
264
- }
265
-
266
- @Test
267
- public void testInsertDirectAfterLoad() throws Exception
268
- {
269
- if (!enabled) {
270
- return;
271
- }
272
-
273
- String table = "test1";
274
-
275
- dropTable(table);
276
- createTable(table);
277
- executeSQL(String.format("INSERT INTO %s VALUES('B001', 0, 'z')", table));
278
- executeSQL(String.format("INSERT INTO %s VALUES('B002', 9, 'z')", table));
279
-
280
- test("/mysql/yml/test-insert-direct-after-load.yml");
281
-
282
- List<List<Object>> rows = select(table);
283
- assertEquals(5, rows.size());
284
- Iterator<List<Object>> i1 = rows.iterator();
285
- {
286
- Iterator<Object> i2 = i1.next().iterator();
287
- assertEquals("A001", i2.next());
288
- assertEquals(9, i2.next());
289
- assertEquals("x", i2.next());
290
- }
291
- {
292
- Iterator<Object> i2 = i1.next().iterator();
293
- assertEquals("A002", i2.next());
294
- assertEquals(0, i2.next());
295
- assertEquals("b", i2.next());
296
- }
297
- {
298
- Iterator<Object> i2 = i1.next().iterator();
299
- assertEquals("A003", i2.next());
300
- assertEquals(9, i2.next());
301
- assertEquals("x", i2.next());
302
- }
303
- {
304
- Iterator<Object> i2 = i1.next().iterator();
305
- assertEquals("B001", i2.next());
306
- assertEquals(0, i2.next());
307
- assertEquals("z", i2.next());
308
- }
309
- {
310
- Iterator<Object> i2 = i1.next().iterator();
311
- assertEquals("B002", i2.next());
312
- assertEquals(9, i2.next());
313
- assertEquals("x", i2.next());
314
- }
315
- }
316
-
317
- @Test
318
- public void testInsertAfterLoad() throws Exception
319
- {
320
- if (!enabled) {
321
- return;
322
- }
323
-
324
- String table = "test1";
325
-
326
- dropTable(table);
327
- createTable(table);
328
- executeSQL(String.format("INSERT INTO %s VALUES('B001', 0, 'z')", table));
329
- executeSQL(String.format("INSERT INTO %s VALUES('B002', 9, 'z')", table));
330
-
331
- test("/mysql/yml/test-insert-after-load.yml");
332
-
333
- List<List<Object>> rows = select(table);
334
- assertEquals(5, rows.size());
335
- Iterator<List<Object>> i1 = rows.iterator();
336
- {
337
- Iterator<Object> i2 = i1.next().iterator();
338
- assertEquals("A001", i2.next());
339
- assertEquals(9, i2.next());
340
- assertEquals("x", i2.next());
341
- }
342
- {
343
- Iterator<Object> i2 = i1.next().iterator();
344
- assertEquals("A002", i2.next());
345
- assertEquals(0, i2.next());
346
- assertEquals("b", i2.next());
347
- }
348
- {
349
- Iterator<Object> i2 = i1.next().iterator();
350
- assertEquals("A003", i2.next());
351
- assertEquals(9, i2.next());
352
- assertEquals("x", i2.next());
353
- }
354
- {
355
- Iterator<Object> i2 = i1.next().iterator();
356
- assertEquals("B001", i2.next());
357
- assertEquals(0, i2.next());
358
- assertEquals("z", i2.next());
359
- }
360
- {
361
- Iterator<Object> i2 = i1.next().iterator();
362
- assertEquals("B002", i2.next());
363
- assertEquals(9, i2.next());
364
- assertEquals("x", i2.next());
365
- }
366
- }
367
-
368
- @Test
369
- public void testTruncateInsertAfterLoad() throws Exception
370
- {
371
- if (!enabled) {
372
- return;
373
- }
374
-
375
- String table = "test1";
376
-
377
- dropTable(table);
378
- createTable(table);
379
- executeSQL(String.format("INSERT INTO %s VALUES('B001', 0, 'z')", table));
380
- executeSQL(String.format("INSERT INTO %s VALUES('B002', 9, 'z')", table));
381
-
382
- test("/mysql/yml/test-truncate-insert-after-load.yml");
383
-
384
- List<List<Object>> rows = select(table);
385
- assertEquals(3, rows.size());
386
- Iterator<List<Object>> i1 = rows.iterator();
387
- {
388
- Iterator<Object> i2 = i1.next().iterator();
389
- assertEquals("A001", i2.next());
390
- assertEquals(9, i2.next());
391
- assertEquals("x", i2.next());
392
- }
393
- {
394
- Iterator<Object> i2 = i1.next().iterator();
395
- assertEquals("A002", i2.next());
396
- assertEquals(0, i2.next());
397
- assertEquals("b", i2.next());
398
- }
399
- {
400
- Iterator<Object> i2 = i1.next().iterator();
401
- assertEquals("A003", i2.next());
402
- assertEquals(9, i2.next());
403
- assertEquals("x", i2.next());
404
- }
405
- }
406
-
407
- @Test
408
- public void testReplaceAfterLoad() throws Exception
409
- {
410
- if (!enabled) {
411
- return;
412
- }
413
-
414
- String table = "test1";
415
-
416
- dropTable(table);
417
- createTable(table);
418
- executeSQL(String.format("INSERT INTO %s VALUES('B001', 0, 'z')", table));
419
- executeSQL(String.format("INSERT INTO %s VALUES('B002', 9, 'z')", table));
420
-
421
- test("/mysql/yml/test-replace-after-load.yml");
422
-
423
- List<List<Object>> rows = select(table);
424
- assertEquals(3, rows.size());
425
- Iterator<List<Object>> i1 = rows.iterator();
426
- {
427
- Iterator<Object> i2 = i1.next().iterator();
428
- assertEquals("A001", i2.next());
429
- assertEquals(9L, i2.next());
430
- assertEquals("x", i2.next());
431
- }
432
- {
433
- Iterator<Object> i2 = i1.next().iterator();
434
- assertEquals("A002", i2.next());
435
- assertEquals(0L, i2.next());
436
- assertEquals("b", i2.next());
437
- }
438
- {
439
- Iterator<Object> i2 = i1.next().iterator();
440
- assertEquals("A003", i2.next());
441
- assertEquals(9L, i2.next());
442
- assertEquals("x", i2.next());
443
- }
444
- }
445
-
446
- @Test
447
- public void testMergeDirectAfterLoad() throws Exception
448
- {
449
- if (!enabled) {
450
- return;
451
- }
452
-
453
- String table = "test1";
454
-
455
- dropTable(table);
456
- createTable(table);
457
- executeSQL(String.format("INSERT INTO %s VALUES('A002', 1, 'y')", table));
458
- executeSQL(String.format("INSERT INTO %s VALUES('A003', 1, 'y')", table));
459
- executeSQL(String.format("INSERT INTO %s VALUES('B001', 0, 'z')", table));
460
- executeSQL(String.format("INSERT INTO %s VALUES('B002', 9, 'z')", table));
461
-
462
- test("/mysql/yml/test-merge-direct-after-load.yml");
463
-
464
- List<List<Object>> rows = select(table);
465
- assertEquals(5, rows.size());
466
- Iterator<List<Object>> i1 = rows.iterator();
467
- {
468
- Iterator<Object> i2 = i1.next().iterator();
469
- assertEquals("A001", i2.next());
470
- assertEquals(9, i2.next());
471
- assertEquals("x", i2.next());
472
- }
473
- {
474
- Iterator<Object> i2 = i1.next().iterator();
475
- assertEquals("A002", i2.next());
476
- assertEquals(0, i2.next());
477
- assertEquals("b", i2.next());
478
- }
479
- {
480
- Iterator<Object> i2 = i1.next().iterator();
481
- assertEquals("A003", i2.next());
482
- assertEquals(9, i2.next());
483
- assertEquals("x", i2.next());
484
- }
485
- {
486
- Iterator<Object> i2 = i1.next().iterator();
487
- assertEquals("B001", i2.next());
488
- assertEquals(0, i2.next());
489
- assertEquals("z", i2.next());
490
- }
491
- {
492
- Iterator<Object> i2 = i1.next().iterator();
493
- assertEquals("B002", i2.next());
494
- assertEquals(9, i2.next());
495
- assertEquals("x", i2.next());
496
- }
497
- }
498
-
499
- @Test
500
- public void testMergeAfterLoad() throws Exception
501
- {
502
- if (!enabled) {
503
- return;
504
- }
505
-
506
- String table = "test1";
507
-
508
- dropTable(table);
509
- createTable(table);
510
- executeSQL(String.format("INSERT INTO %s VALUES('A002', 1, 'y')", table));
511
- executeSQL(String.format("INSERT INTO %s VALUES('A003', 1, 'y')", table));
512
- executeSQL(String.format("INSERT INTO %s VALUES('B001', 0, 'z')", table));
513
- executeSQL(String.format("INSERT INTO %s VALUES('B002', 9, 'z')", table));
514
-
515
- test("/mysql/yml/test-merge-after-load.yml");
516
-
517
- List<List<Object>> rows = select(table);
518
- assertEquals(5, rows.size());
519
- Iterator<List<Object>> i1 = rows.iterator();
520
- {
521
- Iterator<Object> i2 = i1.next().iterator();
522
- assertEquals("A001", i2.next());
523
- assertEquals(9, i2.next());
524
- assertEquals("x", i2.next());
525
- }
526
- {
527
- Iterator<Object> i2 = i1.next().iterator();
528
- assertEquals("A002", i2.next());
529
- assertEquals(0, i2.next());
530
- assertEquals("b", i2.next());
531
- }
532
- {
533
- Iterator<Object> i2 = i1.next().iterator();
534
- assertEquals("A003", i2.next());
535
- assertEquals(9, i2.next());
536
- assertEquals("x", i2.next());
537
- }
538
- {
539
- Iterator<Object> i2 = i1.next().iterator();
540
- assertEquals("B001", i2.next());
541
- assertEquals(0, i2.next());
542
- assertEquals("z", i2.next());
543
- }
544
- {
545
- Iterator<Object> i2 = i1.next().iterator();
546
- assertEquals("B002", i2.next());
547
- assertEquals(9, i2.next());
548
- assertEquals("x", i2.next());
549
- }
550
- }
551
-
552
- private void createTable(String table) throws SQLException
553
- {
554
- String sql = String.format("create table %s ("
555
- + "id char(4),"
556
- + "int_item int,"
557
- + "varchar_item varchar(8),"
558
- + "primary key (id))", table);
559
- executeSQL(sql);
560
- }
561
-
562
- @Override
563
- protected Connection connect() throws SQLException
564
- {
565
- return DriverManager.getConnection(String.format(ENGLISH, "jdbc:mysql://%s:%d/%s", getHost(), getPort(), getDatabase()),
566
- getUser(), getPassword());
567
- }
568
-
569
- }
@@ -1,22 +0,0 @@
1
- in:
2
- type: file
3
- path_prefix: '/mysql/data/test1.csv'
4
- parser:
5
- charset: UTF-8
6
- newline: CRLF
7
- type: csv
8
- delimiter: ','
9
- quote: ''
10
- columns:
11
- - {name: id, type: string}
12
- - {name: int_item, type: long}
13
- - {name: varchar_item, type: string}
14
- out:
15
- type: mysql
16
- host: #host#
17
- database: #database#
18
- user: #user#
19
- password: #password#
20
- table: test1
21
- mode: insert
22
- after_load: "update test1 set varchar_item = 'x' where int_item = 9"
@@ -1,22 +0,0 @@
1
- in:
2
- type: file
3
- path_prefix: '/mysql/data/test1.csv'
4
- parser:
5
- charset: UTF-8
6
- newline: CRLF
7
- type: csv
8
- delimiter: ','
9
- quote: ''
10
- columns:
11
- - {name: id, type: string}
12
- - {name: int_item, type: long}
13
- - {name: varchar_item, type: string}
14
- out:
15
- type: mysql
16
- host: #host#
17
- database: #database#
18
- user: #user#
19
- password: #password#
20
- table: test1
21
- mode: insert
22
- before_load: "delete from test1 where int_item = 9"
@@ -1,22 +0,0 @@
1
- in:
2
- type: file
3
- path_prefix: '/mysql/data/test1.csv'
4
- parser:
5
- charset: UTF-8
6
- newline: CRLF
7
- type: csv
8
- delimiter: ','
9
- quote: ''
10
- columns:
11
- - {name: id, type: string}
12
- - {name: int_item, type: long}
13
- - {name: varchar_item, type: string}
14
- out:
15
- type: mysql
16
- host: #host#
17
- database: #database#
18
- user: #user#
19
- password: #password#
20
- table: test1
21
- mode: insert_direct
22
- after_load: "update test1 set varchar_item = 'x' where int_item = 9"
@@ -1,22 +0,0 @@
1
- in:
2
- type: file
3
- path_prefix: '/mysql/data/test1.csv'
4
- parser:
5
- charset: UTF-8
6
- newline: CRLF
7
- type: csv
8
- delimiter: ','
9
- quote: ''
10
- columns:
11
- - {name: id, type: string}
12
- - {name: int_item, type: long}
13
- - {name: varchar_item, type: string}
14
- out:
15
- type: mysql
16
- host: #host#
17
- database: #database#
18
- user: #user#
19
- password: #password#
20
- table: test1
21
- mode: insert_direct
22
- before_load: "delete from test1 where int_item = 9"
@@ -1,22 +0,0 @@
1
- in:
2
- type: file
3
- path_prefix: '/mysql/data/test1.csv'
4
- parser:
5
- charset: UTF-8
6
- newline: CRLF
7
- type: csv
8
- delimiter: ','
9
- quote: ''
10
- columns:
11
- - {name: id, type: string}
12
- - {name: int_item, type: long}
13
- - {name: varchar_item, type: string}
14
- out:
15
- type: mysql
16
- host: #host#
17
- database: #database#
18
- user: #user#
19
- password: #password#
20
- table: test1
21
- mode: merge
22
- after_load: "update test1 set varchar_item = 'x' where int_item = 9"
@@ -1,22 +0,0 @@
1
- in:
2
- type: file
3
- path_prefix: '/mysql/data/test1.csv'
4
- parser:
5
- charset: UTF-8
6
- newline: CRLF
7
- type: csv
8
- delimiter: ','
9
- quote: ''
10
- columns:
11
- - {name: id, type: string}
12
- - {name: int_item, type: long}
13
- - {name: varchar_item, type: string}
14
- out:
15
- type: mysql
16
- host: #host#
17
- database: #database#
18
- user: #user#
19
- password: #password#
20
- table: test1
21
- mode: merge
22
- before_load: "delete from test1 where int_item = 9"