embulk-output-oracle 0.6.3 → 0.6.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +43 -0
- data/build.gradle +2 -2
- data/classpath/{embulk-output-jdbc-0.6.3.jar → embulk-output-jdbc-0.6.4.jar} +0 -0
- data/classpath/embulk-output-oracle-0.6.4.jar +0 -0
- data/lib/embulk/native/x86_64-linux/libembulk-output-oracle-oci.so +0 -0
- data/lib/embulk/native/x86_64-windows/embulk-output-oracle-oci.dll +0 -0
- data/src/main/cpp/common/embulk-output-oracle-oci.cpp +27 -0
- data/src/main/cpp/linux/build.sh +15 -0
- data/src/main/cpp/windows/build.bat +26 -0
- data/src/main/cpp/windows/dllmain.cpp +25 -0
- data/src/main/cpp/windows/embulk-output-oracle-oci.sln +20 -0
- data/src/main/cpp/windows/embulk-output-oracle-oci.vcxproj +171 -0
- data/src/main/java/org/embulk/output/oracle/DirectBatchInsert.java +5 -39
- data/src/main/java/org/embulk/output/oracle/oci/BulkOCI.java +15 -0
- data/src/main/java/org/embulk/output/oracle/oci/OCI.java +1 -0
- data/src/main/java/org/embulk/output/oracle/oci/OCIManager.java +3 -2
- data/src/main/java/org/embulk/output/oracle/oci/OCIWrapper.java +103 -37
- data/src/main/java/org/embulk/output/oracle/oci/PrimitiveBulkOCI.java +47 -0
- data/src/main/java/org/embulk/output/oracle/oci/RowBuffer.java +50 -46
- data/src/main/java/org/embulk/output/oracle/oci/TableDefinition.java +9 -0
- data/src/test/java/org/embulk/output/oracle/OracleOutputPluginTest.java +622 -133
- data/src/test/resources/oracle/data/test3/test3.csv +9999 -0
- data/src/test/resources/oracle/yml/test-insert-direct-oci-method-large.yml +29 -0
- metadata +19 -8
- data/classpath/embulk-output-oracle-0.6.3.jar +0 -0
- data/src/test/java/org/embulk/output/oracle/OracleOutputPluginTestImpl.java +0 -620
@@ -0,0 +1,29 @@
|
|
1
|
+
in:
|
2
|
+
type: file
|
3
|
+
path_prefix: '/oracle/data/test3/test3.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: VARCHAR2_ITEM, type: string}
|
13
|
+
- {name: NVARCHAR2_ITEM, type: string}
|
14
|
+
- {name: INTEGER_ITEM, type: long}
|
15
|
+
- {name: NUMBER_ITEM, type: string}
|
16
|
+
- {name: DATE_ITEM, type: timestamp, format: '%Y/%m/%d'}
|
17
|
+
- {name: TIMESTAMP_ITEM, type: timestamp, format: '%Y/%m/%d %H:%M:%S'}
|
18
|
+
out:
|
19
|
+
type: oracle
|
20
|
+
host: localhost
|
21
|
+
database: TESTDB
|
22
|
+
user: TEST_USER
|
23
|
+
password: test_pw
|
24
|
+
table: TEST1
|
25
|
+
mode: insert_direct
|
26
|
+
insert_method: oci
|
27
|
+
column_options:
|
28
|
+
INTEGER_ITEM: {value_type: pass}
|
29
|
+
#driver_path: driver/ojdbc7.jar
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: embulk-output-oracle
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sadayuki Furuhashi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-09-30 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Inserts or updates records to a table.
|
14
14
|
email:
|
@@ -19,27 +19,40 @@ extra_rdoc_files: []
|
|
19
19
|
files:
|
20
20
|
- README.md
|
21
21
|
- build.gradle
|
22
|
+
- classpath/embulk-output-jdbc-0.6.4.jar
|
23
|
+
- classpath/embulk-output-oracle-0.6.4.jar
|
24
|
+
- lib/embulk/native/x86_64-linux/libembulk-output-oracle-oci.so
|
25
|
+
- lib/embulk/native/x86_64-windows/embulk-output-oracle-oci.dll
|
22
26
|
- lib/embulk/output/oracle.rb
|
27
|
+
- src/main/cpp/common/embulk-output-oracle-oci.cpp
|
28
|
+
- src/main/cpp/linux/build.sh
|
29
|
+
- src/main/cpp/windows/build.bat
|
30
|
+
- src/main/cpp/windows/dllmain.cpp
|
31
|
+
- src/main/cpp/windows/embulk-output-oracle-oci.sln
|
32
|
+
- src/main/cpp/windows/embulk-output-oracle-oci.vcxproj
|
23
33
|
- src/main/java/org/embulk/output/OracleOutputPlugin.java
|
24
34
|
- src/main/java/org/embulk/output/oracle/DirectBatchInsert.java
|
25
35
|
- src/main/java/org/embulk/output/oracle/InsertMethod.java
|
26
36
|
- src/main/java/org/embulk/output/oracle/OracleCharset.java
|
27
37
|
- src/main/java/org/embulk/output/oracle/OracleOutputConnection.java
|
28
38
|
- src/main/java/org/embulk/output/oracle/OracleOutputConnector.java
|
39
|
+
- src/main/java/org/embulk/output/oracle/oci/BulkOCI.java
|
29
40
|
- src/main/java/org/embulk/output/oracle/oci/ColumnDefinition.java
|
30
41
|
- src/main/java/org/embulk/output/oracle/oci/OCI.java
|
31
42
|
- src/main/java/org/embulk/output/oracle/oci/OCIManager.java
|
32
43
|
- src/main/java/org/embulk/output/oracle/oci/OCIWrapper.java
|
44
|
+
- src/main/java/org/embulk/output/oracle/oci/PrimitiveBulkOCI.java
|
33
45
|
- src/main/java/org/embulk/output/oracle/oci/RowBuffer.java
|
34
46
|
- src/main/java/org/embulk/output/oracle/oci/TableDefinition.java
|
35
47
|
- src/test/java/org/embulk/input/filesplit/LocalFileSplitInputPlugin.java
|
36
48
|
- src/test/java/org/embulk/input/filesplit/PartialFile.java
|
37
49
|
- src/test/java/org/embulk/input/filesplit/PartialFileInputStream.java
|
38
50
|
- src/test/java/org/embulk/output/oracle/OracleOutputPluginTest.java
|
39
|
-
- src/test/java/org/embulk/output/oracle/OracleOutputPluginTestImpl.java
|
40
51
|
- src/test/resources/oracle/data/test1/test1.csv
|
52
|
+
- src/test/resources/oracle/data/test3/test3.csv
|
41
53
|
- src/test/resources/oracle/yml/test-insert-direct-direct-method.yml
|
42
54
|
- src/test/resources/oracle/yml/test-insert-direct-empty.yml
|
55
|
+
- src/test/resources/oracle/yml/test-insert-direct-oci-method-large.yml
|
43
56
|
- src/test/resources/oracle/yml/test-insert-direct-oci-method-multibyte.yml
|
44
57
|
- src/test/resources/oracle/yml/test-insert-direct-oci-method-split.yml
|
45
58
|
- src/test/resources/oracle/yml/test-insert-direct-oci-method.yml
|
@@ -58,8 +71,6 @@ files:
|
|
58
71
|
- src/test/resources/oracle/yml/test-truncate-insert-oci-method.yml
|
59
72
|
- src/test/resources/oracle/yml/test-truncate-insert.yml
|
60
73
|
- src/test/resources/oracle/yml/test-url.yml
|
61
|
-
- classpath/embulk-output-jdbc-0.6.3.jar
|
62
|
-
- classpath/embulk-output-oracle-0.6.3.jar
|
63
74
|
homepage: https://github.com/embulk/embulk-output-jdbc
|
64
75
|
licenses:
|
65
76
|
- Apache 2.0
|
@@ -70,17 +81,17 @@ require_paths:
|
|
70
81
|
- lib
|
71
82
|
required_ruby_version: !ruby/object:Gem::Requirement
|
72
83
|
requirements:
|
73
|
-
- -
|
84
|
+
- - ">="
|
74
85
|
- !ruby/object:Gem::Version
|
75
86
|
version: '0'
|
76
87
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
77
88
|
requirements:
|
78
|
-
- -
|
89
|
+
- - ">="
|
79
90
|
- !ruby/object:Gem::Version
|
80
91
|
version: '0'
|
81
92
|
requirements: []
|
82
93
|
rubyforge_project:
|
83
|
-
rubygems_version: 2.
|
94
|
+
rubygems_version: 2.4.8
|
84
95
|
signing_key:
|
85
96
|
specification_version: 4
|
86
97
|
summary: JDBC output plugin for Embulk
|
Binary file
|
@@ -1,620 +0,0 @@
|
|
1
|
-
package org.embulk.output.oracle;
|
2
|
-
|
3
|
-
import static org.junit.Assert.assertEquals;
|
4
|
-
import static org.junit.Assert.fail;
|
5
|
-
|
6
|
-
import java.io.File;
|
7
|
-
import java.lang.reflect.Constructor;
|
8
|
-
import java.math.BigDecimal;
|
9
|
-
import java.sql.Connection;
|
10
|
-
import java.sql.DriverManager;
|
11
|
-
import java.sql.ResultSet;
|
12
|
-
import java.sql.SQLException;
|
13
|
-
import java.sql.Timestamp;
|
14
|
-
import java.text.DateFormat;
|
15
|
-
import java.text.ParseException;
|
16
|
-
import java.text.SimpleDateFormat;
|
17
|
-
import java.util.Date;
|
18
|
-
import java.util.Iterator;
|
19
|
-
import java.util.List;
|
20
|
-
import java.util.TimeZone;
|
21
|
-
|
22
|
-
import org.embulk.output.AbstractJdbcOutputPluginTest;
|
23
|
-
import org.embulk.output.tester.EmbulkPluginTester;
|
24
|
-
|
25
|
-
|
26
|
-
public class OracleOutputPluginTestImpl extends AbstractJdbcOutputPluginTest
|
27
|
-
{
|
28
|
-
private EmbulkPluginTester tester;
|
29
|
-
private String pluginName;
|
30
|
-
|
31
|
-
public void setTester(EmbulkPluginTester tester) {
|
32
|
-
this.tester = tester;
|
33
|
-
}
|
34
|
-
|
35
|
-
public void setPluginName(String pluginName) {
|
36
|
-
this.pluginName = pluginName;
|
37
|
-
}
|
38
|
-
|
39
|
-
public String beforeClass()
|
40
|
-
{
|
41
|
-
try {
|
42
|
-
Class.forName("oracle.jdbc.OracleDriver");
|
43
|
-
|
44
|
-
try (Connection connection = connect()) {
|
45
|
-
String version = connection.getMetaData().getDriverVersion();
|
46
|
-
System.out.println("Driver version = " + version);
|
47
|
-
return version;
|
48
|
-
}
|
49
|
-
|
50
|
-
} catch (ClassNotFoundException | NoClassDefFoundError e) {
|
51
|
-
//throw new RuntimeException("You should put Oracle JDBC driver on 'driver' directory.");
|
52
|
-
System.err.println("Warning: put Oracle JDBC driver on 'driver' directory in order to test embulk-output-oracle plugin.");
|
53
|
-
|
54
|
-
} catch (SQLException e) {
|
55
|
-
System.err.println(e);
|
56
|
-
//throw new RuntimeException("You should prepare a schema on Oracle 12c (database = 'TESTDB', user = 'TEST_USER', password = 'test_pw', charset = UTF-8).");
|
57
|
-
System.err.println("Warning: prepare a schema on Oracle 12c (database = 'TESTDB', user = 'TEST_USER', password = 'test_pw', charset = UTF-8).");
|
58
|
-
// for example
|
59
|
-
// CREATE USER EMBULK_USER IDENTIFIED BY "embulk_pw";
|
60
|
-
// GRANT DBA TO EMBULK_USER;
|
61
|
-
}
|
62
|
-
|
63
|
-
return null;
|
64
|
-
}
|
65
|
-
|
66
|
-
public void testInsert() throws Exception
|
67
|
-
{
|
68
|
-
String table = "TEST1";
|
69
|
-
|
70
|
-
dropTable(table);
|
71
|
-
createTable(table);
|
72
|
-
|
73
|
-
run("/oracle/yml/test-insert.yml");
|
74
|
-
|
75
|
-
assertTable(table);
|
76
|
-
}
|
77
|
-
|
78
|
-
public void testInsertCreate() throws Exception
|
79
|
-
{
|
80
|
-
String table = "TEST1";
|
81
|
-
|
82
|
-
dropTable(table);
|
83
|
-
|
84
|
-
run("/oracle/yml/test-insert.yml");
|
85
|
-
|
86
|
-
assertGeneratedTable1(table);
|
87
|
-
}
|
88
|
-
|
89
|
-
public void testInsertEmpty() throws Exception
|
90
|
-
{
|
91
|
-
String table = "TEST1";
|
92
|
-
|
93
|
-
dropTable(table);
|
94
|
-
createTable(table);
|
95
|
-
|
96
|
-
new File(convertPath("/oracle/data/"), "test2").mkdir();
|
97
|
-
run("/oracle/yml/test-insert-empty.yml");
|
98
|
-
|
99
|
-
assertTableEmpty(table);
|
100
|
-
}
|
101
|
-
|
102
|
-
public void testTruncateInsert() throws Exception
|
103
|
-
{
|
104
|
-
String table = "TEST1";
|
105
|
-
|
106
|
-
dropTable(table);
|
107
|
-
createTable(table);
|
108
|
-
insertRecord(table);
|
109
|
-
|
110
|
-
run("/oracle/yml/test-truncate-insert.yml");
|
111
|
-
|
112
|
-
assertTable(table);
|
113
|
-
}
|
114
|
-
|
115
|
-
public void testTruncateInsertOCIMethod() throws Exception
|
116
|
-
{
|
117
|
-
String table = "TEST1";
|
118
|
-
|
119
|
-
dropTable(table);
|
120
|
-
createTable(table);
|
121
|
-
insertRecord(table);
|
122
|
-
|
123
|
-
run("/oracle/yml/test-truncate-insert-oci-method.yml");
|
124
|
-
|
125
|
-
assertTable(table);
|
126
|
-
}
|
127
|
-
|
128
|
-
public void testTruncateInsertCreate() throws Exception
|
129
|
-
{
|
130
|
-
String table = "TEST1";
|
131
|
-
|
132
|
-
dropTable(table);
|
133
|
-
|
134
|
-
run("/oracle/yml/test-truncate-insert.yml");
|
135
|
-
|
136
|
-
assertGeneratedTable1(table);
|
137
|
-
}
|
138
|
-
|
139
|
-
public void testInsertDirect() throws Exception
|
140
|
-
{
|
141
|
-
String table = "TEST1";
|
142
|
-
|
143
|
-
dropTable(table);
|
144
|
-
createTable(table);
|
145
|
-
|
146
|
-
run("/oracle/yml/test-insert-direct.yml");
|
147
|
-
|
148
|
-
assertTable(table);
|
149
|
-
}
|
150
|
-
|
151
|
-
public void testInsertDirectDuplicate() throws Exception
|
152
|
-
{
|
153
|
-
String table = "TEST1";
|
154
|
-
|
155
|
-
dropTable(table);
|
156
|
-
createTable(table);
|
157
|
-
insertRecord(table, "A002");
|
158
|
-
|
159
|
-
try {
|
160
|
-
run("/oracle/yml/test-insert-direct.yml");
|
161
|
-
fail("Exception expected.");
|
162
|
-
} catch (Exception e) {
|
163
|
-
System.out.println(e);
|
164
|
-
}
|
165
|
-
}
|
166
|
-
|
167
|
-
public void testInsertDirectEmpty() throws Exception
|
168
|
-
{
|
169
|
-
String table = "TEST1";
|
170
|
-
|
171
|
-
dropTable(table);
|
172
|
-
createTable(table);
|
173
|
-
|
174
|
-
new File(convertPath("/oracle/data/"), "test2").mkdir();
|
175
|
-
run("/oracle/yml/test-insert-direct-empty.yml");
|
176
|
-
|
177
|
-
assertTableEmpty(table);
|
178
|
-
}
|
179
|
-
|
180
|
-
public void testInsertDirectCreate() throws Exception
|
181
|
-
{
|
182
|
-
String table = "TEST1";
|
183
|
-
|
184
|
-
dropTable(table);
|
185
|
-
|
186
|
-
run("/oracle/yml/test-insert-direct.yml");
|
187
|
-
|
188
|
-
assertGeneratedTable1(table);
|
189
|
-
}
|
190
|
-
|
191
|
-
public void testInsertDirectDirectMethod() throws Exception
|
192
|
-
{
|
193
|
-
String table = "TEST1";
|
194
|
-
|
195
|
-
dropTable(table);
|
196
|
-
createTable(table);
|
197
|
-
|
198
|
-
run("/oracle/yml/test-insert-direct-direct-method.yml");
|
199
|
-
|
200
|
-
assertTable(table);
|
201
|
-
}
|
202
|
-
|
203
|
-
public void testInsertDirectOCIMethod() throws Exception
|
204
|
-
{
|
205
|
-
String table = "TEST1";
|
206
|
-
|
207
|
-
dropTable(table);
|
208
|
-
createTable(table);
|
209
|
-
|
210
|
-
run("/oracle/yml/test-insert-direct-oci-method.yml");
|
211
|
-
|
212
|
-
assertTable(table);
|
213
|
-
}
|
214
|
-
|
215
|
-
public void testInsertDirectOCIMethodDuplicate() throws Exception
|
216
|
-
{
|
217
|
-
String table = "TEST1";
|
218
|
-
|
219
|
-
dropTable(table);
|
220
|
-
createTable(table);
|
221
|
-
insertRecord(table, "A002");
|
222
|
-
|
223
|
-
try {
|
224
|
-
run("/oracle/yml/test-insert-direct-oci-method.yml");
|
225
|
-
fail("Exception expected.");
|
226
|
-
} catch (Exception e) {
|
227
|
-
System.out.println(e);
|
228
|
-
}
|
229
|
-
}
|
230
|
-
|
231
|
-
public void testInsertDirectOCIMethodMultibyte() throws Exception
|
232
|
-
{
|
233
|
-
String table = "TEST1";
|
234
|
-
|
235
|
-
dropTable(table);
|
236
|
-
createTable(table);
|
237
|
-
|
238
|
-
run("/oracle/yml/test-insert-direct-oci-method-multibyte.yml");
|
239
|
-
|
240
|
-
assertTable(table);
|
241
|
-
}
|
242
|
-
|
243
|
-
public void testInsertDirectOCIMethodMultibyteDuplicate() throws Exception
|
244
|
-
{
|
245
|
-
String table = "TEST1";
|
246
|
-
|
247
|
-
dropTable(table);
|
248
|
-
createTable(table);
|
249
|
-
insertRecord(table, "A002");
|
250
|
-
|
251
|
-
try {
|
252
|
-
run("/oracle/yml/test-insert-direct-oci-method-multibyte.yml");
|
253
|
-
fail("Exception expected.");
|
254
|
-
} catch (Exception e) {
|
255
|
-
System.out.println(e);
|
256
|
-
}
|
257
|
-
}
|
258
|
-
|
259
|
-
public void testInsertDirectOCIMethodSplit() throws Exception
|
260
|
-
{
|
261
|
-
String table = "TEST1";
|
262
|
-
|
263
|
-
dropTable(table);
|
264
|
-
createTable(table);
|
265
|
-
|
266
|
-
run("/oracle/yml/test-insert-direct-oci-method-split.yml");
|
267
|
-
|
268
|
-
assertTable(table);
|
269
|
-
}
|
270
|
-
|
271
|
-
public void testUrl() throws Exception
|
272
|
-
{
|
273
|
-
String table = "TEST1";
|
274
|
-
|
275
|
-
dropTable(table);
|
276
|
-
createTable(table);
|
277
|
-
|
278
|
-
run("/oracle/yml/test-url.yml");
|
279
|
-
|
280
|
-
assertTable(table);
|
281
|
-
}
|
282
|
-
|
283
|
-
public void testLowerTable() throws Exception
|
284
|
-
{
|
285
|
-
String table = "TEST1";
|
286
|
-
|
287
|
-
dropTable(table);
|
288
|
-
createTable(table);
|
289
|
-
|
290
|
-
run("/oracle/yml/test-lower-table.yml");
|
291
|
-
|
292
|
-
assertTable(table);
|
293
|
-
}
|
294
|
-
|
295
|
-
public void testLowerColumn() throws Exception
|
296
|
-
{
|
297
|
-
String table = "TEST1";
|
298
|
-
|
299
|
-
dropTable(table);
|
300
|
-
createTable(table);
|
301
|
-
|
302
|
-
run("/oracle/yml/test-lower-column.yml");
|
303
|
-
|
304
|
-
assertTable(table);
|
305
|
-
}
|
306
|
-
|
307
|
-
public void testLowerColumnOptions() throws Exception
|
308
|
-
{
|
309
|
-
String table = "TEST1";
|
310
|
-
|
311
|
-
dropTable(table);
|
312
|
-
createTable(table);
|
313
|
-
|
314
|
-
run("/oracle/yml/test-lower-column-options.yml");
|
315
|
-
|
316
|
-
assertTable(table);
|
317
|
-
}
|
318
|
-
|
319
|
-
public void testReplace() throws Exception
|
320
|
-
{
|
321
|
-
String table = "TEST1";
|
322
|
-
|
323
|
-
dropTable(table);
|
324
|
-
createTable(table);
|
325
|
-
|
326
|
-
run("/oracle/yml/test-replace.yml");
|
327
|
-
|
328
|
-
assertGeneratedTable2(table);
|
329
|
-
}
|
330
|
-
|
331
|
-
public void testReplaceOCIMethod() throws Exception
|
332
|
-
{
|
333
|
-
String table = "TEST1";
|
334
|
-
|
335
|
-
dropTable(table);
|
336
|
-
createTable(table);
|
337
|
-
|
338
|
-
run("/oracle/yml/test-replace-oci-method.yml");
|
339
|
-
|
340
|
-
assertGeneratedTable2(table);
|
341
|
-
}
|
342
|
-
|
343
|
-
public void testReplaceEmpty() throws Exception
|
344
|
-
{
|
345
|
-
String table = "TEST1";
|
346
|
-
|
347
|
-
dropTable(table);
|
348
|
-
createTable(table);
|
349
|
-
|
350
|
-
run("/oracle/yml/test-replace-empty.yml");
|
351
|
-
|
352
|
-
assertTableEmpty(table);
|
353
|
-
}
|
354
|
-
|
355
|
-
public void testReplaceCreate() throws Exception
|
356
|
-
{
|
357
|
-
String table = "TEST1";
|
358
|
-
|
359
|
-
dropTable(table);
|
360
|
-
|
361
|
-
run("/oracle/yml/test-replace.yml");
|
362
|
-
|
363
|
-
assertGeneratedTable2(table);
|
364
|
-
}
|
365
|
-
|
366
|
-
|
367
|
-
public void testReplaceLongName() throws Exception
|
368
|
-
{
|
369
|
-
String table = "TEST12345678901234567890123456";
|
370
|
-
|
371
|
-
dropTable(table);
|
372
|
-
createTable(table);
|
373
|
-
|
374
|
-
run("/oracle/yml/test-replace-long-name.yml");
|
375
|
-
|
376
|
-
assertGeneratedTable2(table);
|
377
|
-
}
|
378
|
-
|
379
|
-
public void testReplaceLongNameMultibyte() throws Exception
|
380
|
-
{
|
381
|
-
String table = "TEST123456789012345678";
|
382
|
-
|
383
|
-
run("/oracle/yml/test-replace-long-name-multibyte.yml");
|
384
|
-
|
385
|
-
assertGeneratedTable2(table);
|
386
|
-
}
|
387
|
-
|
388
|
-
public void testStringTimestamp() throws Exception
|
389
|
-
{
|
390
|
-
String table = "TEST1";
|
391
|
-
|
392
|
-
dropTable(table);
|
393
|
-
createTable(table);
|
394
|
-
|
395
|
-
run("/oracle/yml/test-string-timestamp.yml");
|
396
|
-
|
397
|
-
assertTable(table);
|
398
|
-
}
|
399
|
-
|
400
|
-
private void createTable(String table) throws SQLException
|
401
|
-
{
|
402
|
-
String sql = String.format("CREATE TABLE %s ("
|
403
|
-
+ "ID CHAR(4),"
|
404
|
-
+ "VARCHAR2_ITEM VARCHAR2(6),"
|
405
|
-
+ "NVARCHAR2_ITEM NVARCHAR2(6),"
|
406
|
-
+ "INTEGER_ITEM NUMBER(4,0),"
|
407
|
-
+ "NUMBER_ITEM NUMBER(10,2),"
|
408
|
-
+ "DATE_ITEM DATE,"
|
409
|
-
+ "TIMESTAMP_ITEM TIMESTAMP,"
|
410
|
-
+ "PRIMARY KEY (ID))", table);
|
411
|
-
executeSQL(sql);
|
412
|
-
}
|
413
|
-
|
414
|
-
private void insertRecord(String table) throws SQLException
|
415
|
-
{
|
416
|
-
insertRecord(table, "9999");
|
417
|
-
}
|
418
|
-
|
419
|
-
private void insertRecord(String table, String id) throws SQLException
|
420
|
-
{
|
421
|
-
executeSQL(String.format("INSERT INTO %s VALUES('%s', NULL, NULL, NULL, NULL, NULL, NULL)", table, id));
|
422
|
-
}
|
423
|
-
|
424
|
-
private void assertTable(String table) throws Exception
|
425
|
-
{
|
426
|
-
// datetime of UTC will be inserted by embulk.
|
427
|
-
// datetime of default timezone will be selected by JDBC.
|
428
|
-
TimeZone timeZone = TimeZone.getDefault();
|
429
|
-
List<List<Object>> rows = select(table);
|
430
|
-
|
431
|
-
/*
|
432
|
-
A001,ABCDE,abcde,,0,123.45,2015/03/05,2015/03/05 12:34:56
|
433
|
-
A002,AB,abcdef,-9999,-99999999.99,2015/03/06,2015/03/06 23:59:59
|
434
|
-
A003,,,,,,
|
435
|
-
*/
|
436
|
-
|
437
|
-
assertEquals(3, rows.size());
|
438
|
-
Iterator<List<Object>> i1 = rows.iterator();
|
439
|
-
{
|
440
|
-
Iterator<Object> i2 = i1.next().iterator();
|
441
|
-
assertEquals("A001", i2.next());
|
442
|
-
assertEquals("ABCDE", i2.next());
|
443
|
-
assertEquals("abcde", i2.next());
|
444
|
-
assertEquals(new BigDecimal("0"), i2.next());
|
445
|
-
assertEquals(new BigDecimal("123.45"), i2.next());
|
446
|
-
assertEquals(toTimestamp("2015/03/05 00:00:00", timeZone), i2.next());
|
447
|
-
assertEquals(toOracleTimestamp("2015/03/05 12:34:56", timeZone), i2.next());
|
448
|
-
}
|
449
|
-
{
|
450
|
-
Iterator<Object> i2 = i1.next().iterator();
|
451
|
-
assertEquals("A002", i2.next());
|
452
|
-
assertEquals("AB", i2.next());
|
453
|
-
assertEquals("abcdef", i2.next());
|
454
|
-
assertEquals(new BigDecimal("-9999"), i2.next());
|
455
|
-
assertEquals(new BigDecimal("-99999999.99"), i2.next());
|
456
|
-
assertEquals(toTimestamp("2015/03/06 00:00:00", timeZone), i2.next());
|
457
|
-
assertEquals(toOracleTimestamp("2015/03/06 23:59:59", timeZone), i2.next());
|
458
|
-
}
|
459
|
-
{
|
460
|
-
Iterator<Object> i2 = i1.next().iterator();
|
461
|
-
assertEquals("A003", i2.next());
|
462
|
-
assertEquals(null, i2.next());
|
463
|
-
assertEquals(null, i2.next());
|
464
|
-
assertEquals(null, i2.next());
|
465
|
-
assertEquals(null, i2.next());
|
466
|
-
assertEquals(null, i2.next());
|
467
|
-
assertEquals(null, i2.next());
|
468
|
-
}
|
469
|
-
}
|
470
|
-
|
471
|
-
private void assertTableEmpty(String table) throws Exception
|
472
|
-
{
|
473
|
-
List<List<Object>> rows = select(table);
|
474
|
-
assertEquals(0, rows.size());
|
475
|
-
}
|
476
|
-
|
477
|
-
private void assertGeneratedTable1(String table) throws Exception
|
478
|
-
{
|
479
|
-
// datetime of UTC will be inserted by embulk.
|
480
|
-
// datetime of default timezone will be selected by JDBC.
|
481
|
-
TimeZone timeZone = TimeZone.getDefault();
|
482
|
-
List<List<Object>> rows = select(table);
|
483
|
-
|
484
|
-
/*
|
485
|
-
A001,ABCDE,abcde,0,123.45,2015/03/05,2015/03/05 12:34:56
|
486
|
-
A002,AB,abcdef,-9999,-99999999.99,2015/03/06,2015/03/06 23:59:59
|
487
|
-
A003,,,,,,
|
488
|
-
*/
|
489
|
-
|
490
|
-
assertEquals(3, rows.size());
|
491
|
-
Iterator<List<Object>> i1 = rows.iterator();
|
492
|
-
{
|
493
|
-
Iterator<Object> i2 = i1.next().iterator();
|
494
|
-
assertEquals("A001", i2.next());
|
495
|
-
assertEquals("ABCDE", i2.next());
|
496
|
-
assertEquals("abcde", i2.next());
|
497
|
-
assertEquals(new BigDecimal("0"), i2.next());
|
498
|
-
assertEquals("123.45", i2.next());
|
499
|
-
assertEquals(toOracleTimestamp("2015/03/05 00:00:00", timeZone), i2.next());
|
500
|
-
assertEquals(toOracleTimestamp("2015/03/05 12:34:56", timeZone), i2.next());
|
501
|
-
}
|
502
|
-
{
|
503
|
-
Iterator<Object> i2 = i1.next().iterator();
|
504
|
-
assertEquals("A002", i2.next());
|
505
|
-
assertEquals("AB", i2.next());
|
506
|
-
assertEquals("abcdef", i2.next());
|
507
|
-
assertEquals(new BigDecimal("-9999"), i2.next());
|
508
|
-
assertEquals("-99999999.99", i2.next());
|
509
|
-
assertEquals(toOracleTimestamp("2015/03/06 00:00:00", timeZone), i2.next());
|
510
|
-
assertEquals(toOracleTimestamp("2015/03/06 23:59:59", timeZone), i2.next());
|
511
|
-
}
|
512
|
-
{
|
513
|
-
Iterator<Object> i2 = i1.next().iterator();
|
514
|
-
assertEquals("A003", i2.next());
|
515
|
-
assertEquals(null, i2.next());
|
516
|
-
assertEquals(null, i2.next());
|
517
|
-
assertEquals(null, i2.next());
|
518
|
-
assertEquals(null, i2.next());
|
519
|
-
assertEquals(null, i2.next());
|
520
|
-
assertEquals(null, i2.next());
|
521
|
-
}
|
522
|
-
}
|
523
|
-
|
524
|
-
private void assertGeneratedTable2(String table) throws Exception
|
525
|
-
{
|
526
|
-
// datetime of UTC will be inserted by embulk.
|
527
|
-
// datetime of default timezone will be selected by JDBC.
|
528
|
-
TimeZone timeZone = TimeZone.getDefault();
|
529
|
-
List<List<Object>> rows = select(table);
|
530
|
-
|
531
|
-
/*
|
532
|
-
A001,ABCDE,abcde,0,123.45,2015/03/05,2015/03/05 12:34:56
|
533
|
-
A002,AB,abcdef,-9999,-99999999.99,2015/03/06,2015/03/06 23:59:59
|
534
|
-
A003,,,,,,
|
535
|
-
*/
|
536
|
-
|
537
|
-
assertEquals(3, rows.size());
|
538
|
-
Iterator<List<Object>> i1 = rows.iterator();
|
539
|
-
{
|
540
|
-
Iterator<Object> i2 = i1.next().iterator();
|
541
|
-
assertEquals("A001", i2.next());
|
542
|
-
assertEquals("ABCDE", i2.next());
|
543
|
-
assertEquals("abcde", i2.next());
|
544
|
-
assertEquals(new BigDecimal("0"), i2.next());
|
545
|
-
assertEquals(new BigDecimal("123.45"), i2.next());
|
546
|
-
assertEquals(toTimestamp("2015/03/05 00:00:00", timeZone), i2.next());
|
547
|
-
assertEquals(toOracleTimestamp("2015/03/05 12:34:56", timeZone), i2.next());
|
548
|
-
}
|
549
|
-
{
|
550
|
-
Iterator<Object> i2 = i1.next().iterator();
|
551
|
-
assertEquals("A002", i2.next());
|
552
|
-
assertEquals("AB", i2.next());
|
553
|
-
assertEquals("abcdef", i2.next());
|
554
|
-
assertEquals(new BigDecimal("-9999"), i2.next());
|
555
|
-
assertEquals(new BigDecimal("-99999999.99"), i2.next());
|
556
|
-
assertEquals(toTimestamp("2015/03/06 00:00:00", timeZone), i2.next());
|
557
|
-
assertEquals(toOracleTimestamp("2015/03/06 23:59:59", timeZone), i2.next());
|
558
|
-
}
|
559
|
-
{
|
560
|
-
Iterator<Object> i2 = i1.next().iterator();
|
561
|
-
assertEquals("A003", i2.next());
|
562
|
-
assertEquals(null, i2.next());
|
563
|
-
assertEquals(null, i2.next());
|
564
|
-
assertEquals(null, i2.next());
|
565
|
-
assertEquals(null, i2.next());
|
566
|
-
assertEquals(null, i2.next());
|
567
|
-
assertEquals(null, i2.next());
|
568
|
-
}
|
569
|
-
}
|
570
|
-
|
571
|
-
@Override
|
572
|
-
protected Object getValue(ResultSet resultSet, int index) throws SQLException
|
573
|
-
{
|
574
|
-
if (resultSet.getMetaData().getColumnTypeName(index).equals("CLOB")) {
|
575
|
-
return resultSet.getString(index);
|
576
|
-
}
|
577
|
-
return super.getValue(resultSet, index);
|
578
|
-
}
|
579
|
-
|
580
|
-
|
581
|
-
private Timestamp toTimestamp(String s, TimeZone timeZone)
|
582
|
-
{
|
583
|
-
for (String formatString : new String[]{"yyyy/MM/dd HH:mm:ss", "yyyy/MM/dd"}) {
|
584
|
-
DateFormat dateFormat = new SimpleDateFormat(formatString);
|
585
|
-
dateFormat.setTimeZone(timeZone);
|
586
|
-
try {
|
587
|
-
Date date = dateFormat.parse(s);
|
588
|
-
return new Timestamp(date.getTime());
|
589
|
-
} catch (ParseException e) {
|
590
|
-
// NOP
|
591
|
-
}
|
592
|
-
}
|
593
|
-
throw new IllegalArgumentException(s);
|
594
|
-
}
|
595
|
-
|
596
|
-
private Object toOracleTimestamp(String s, TimeZone timeZone) throws Exception
|
597
|
-
{
|
598
|
-
Class<?> timestampClass = Class.forName("oracle.sql.TIMESTAMP");
|
599
|
-
Constructor<?> constructor = timestampClass.getConstructor(Timestamp.class);
|
600
|
-
return constructor.newInstance(toTimestamp(s, timeZone));
|
601
|
-
}
|
602
|
-
|
603
|
-
@Override
|
604
|
-
protected Connection connect() throws SQLException
|
605
|
-
{
|
606
|
-
return DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:TESTDB", "TEST_USER", "test_pw");
|
607
|
-
}
|
608
|
-
|
609
|
-
private void run(String ymlName) throws Exception
|
610
|
-
{
|
611
|
-
tester.run(convertYml(ymlName));
|
612
|
-
}
|
613
|
-
|
614
|
-
@Override
|
615
|
-
protected String convertYmlLine(String line)
|
616
|
-
{
|
617
|
-
return line.replaceAll("type: oracle", "type: " + pluginName);
|
618
|
-
}
|
619
|
-
|
620
|
-
}
|