embulk-output-oracle 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +7 -2
- data/classpath/embulk-output-jdbc-0.4.0.jar +0 -0
- data/classpath/embulk-output-oracle-0.4.0.jar +0 -0
- data/src/main/java/org/embulk/output/oracle/DirectBatchInsert.java +16 -15
- data/src/main/java/org/embulk/output/oracle/OracleOutputConnection.java +2 -2
- data/src/main/java/org/embulk/output/oracle/oci/RowBuffer.java +7 -1
- data/src/test/java/org/embulk/output/oracle/OracleOutputPluginTestImpl.java +57 -18
- data/src/test/resources/yml/test-insert-direct.yml +1 -1
- data/src/test/resources/yml/test-insert-oci-split.yml +3 -1
- data/src/test/resources/yml/test-insert-oci.yml +3 -1
- data/src/test/resources/yml/test-insert.yml +1 -1
- data/src/test/resources/yml/test-replace-long-name-multibyte.yml +6 -0
- data/src/test/resources/yml/test-replace-long-name.yml +6 -0
- data/src/test/resources/yml/test-replace.yml +6 -0
- data/src/test/resources/yml/test-string-timestamp.yml +4 -1
- data/src/test/resources/yml/test-url.yml +1 -1
- metadata +4 -4
- data/classpath/embulk-output-jdbc-0.3.0.jar +0 -0
- data/classpath/embulk-output-oracle-0.3.0.jar +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 885c9eec0bf737ff77ed157431bbe16f2db54fbf
|
4
|
+
data.tar.gz: d2044b92a9fcd9148aaf40e3fdb2d2609db6e88e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fa3ca6314c186a4d2d682cc9d6d4db42c68fe4bbb9baae74404c43339d0d222a44a9d62e3a6de56bb1c7a2e18114b048a4cd1f9ba796d88f240a8753f3642c2a
|
7
|
+
data.tar.gz: 07b1d530ca63c91edc7904a1dd6089b131a684ff9525c44acb127150a3785b212f22d8a19185140e815d2b87bd48961ad215fcac97e6d0cfe2cc53683f9438da
|
data/README.md
CHANGED
@@ -22,12 +22,12 @@ Oracle output plugins for Embulk loads records to Oracle.
|
|
22
22
|
- **mode**: "insert", "insert_direct", "truncate_insert", or "replace". See bellow. (string, required)
|
23
23
|
- **insert_method**: see below
|
24
24
|
- **batch_size**: size of a single batch insert (integer, default: 16777216)
|
25
|
-
- **default_timezone**: If input column type (embulk type) is timestamp
|
25
|
+
- **default_timezone**: If input column type (embulk type) is timestamp, this plugin needs to format the timestamp into a SQL string. This default_timezone option is used to control the timezone. You can overwrite timezone for each columns using column_options option. (string, default: `UTC`)
|
26
26
|
- **column_options**: advanced: a key-value pairs where key is a column name and value is options for the column.
|
27
27
|
- **type**: type of a column when this plugin creates new tables (e.g. `VARCHAR(255)`, `INTEGER NOT NULL UNIQUE`). This used when this plugin creates intermediate tables (insert, truncate_insert and merge modes), when it creates the target table (insert_direct and replace modes), and when it creates nonexistent target table automatically. (string, default: depends on input column type. `BIGINT` if input column type is long, `BOOLEAN` if boolean, `DOUBLE PRECISION` if double, `CLOB` if string, `TIMESTAMP` if timestamp)
|
28
28
|
- **value_type**: This plugin converts input column type (embulk type) into a database type to build a INSERT statement. This value_type option controls the type of the value in a INSERT statement. (string, default: depends on input column type. Available values options are: `byte`, `short`, `int`, `long`, `double`, `float`, `boolean`, `string`, `nstring`, `date`, `time`, `timestamp`, `decimal`, `null`, `pass`)
|
29
29
|
- **timestamp_format**: If input column type (embulk type) is timestamp and value_type is `string` or `nstring`, this plugin needs to format the timestamp value into a string. This timestamp_format option is used to control the format of the timestamp. (string, default: `%Y-%m-%d %H:%M:%S.%6N`)
|
30
|
-
- **timezone**: If input column type (embulk type) is timestamp
|
30
|
+
- **timezone**: If input column type (embulk type) is timestamp, this plugin needs to format the timestamp value into a SQL string. In this cases, this timezone option is used to control the timezone. (string, value of default_timezone option is used by default)
|
31
31
|
|
32
32
|
### Modes
|
33
33
|
|
@@ -153,3 +153,8 @@ For Linux (x64) (only Ubuntu Server 14.04 is tested)
|
|
153
153
|
* OCI_PATH (the directory of Oracle Instant Client Basic and the parent of the "sdk" directory)
|
154
154
|
|
155
155
|
(6) Execute src/main/cpp/linux/build.sh .
|
156
|
+
|
157
|
+
***
|
158
|
+
<img src="https://www.yourkit.com/images/yklogo.png" alt="YourKit"/> is used to improve performance of embulk-output-oracle.
|
159
|
+
YourKit supports open source projects with its full-featured Java Profiler.
|
160
|
+
YourKit, LLC is the creator of <a href="https://www.yourkit.com/java/profiler/index.jsp">YourKit Java Profiler</a> and <a href="https://www.yourkit.com/.net/profiler/index.jsp">YourKit .NET Profiler</a>, innovative and intelligent tools for profiling Java and .NET applications.
|
Binary file
|
Binary file
|
@@ -2,17 +2,14 @@ package org.embulk.output.oracle;
|
|
2
2
|
|
3
3
|
import java.io.IOException;
|
4
4
|
import java.math.BigDecimal;
|
5
|
-
import java.sql.Date;
|
6
5
|
import java.sql.SQLException;
|
7
|
-
import java.sql.Time;
|
8
|
-
import java.sql.Timestamp;
|
9
6
|
import java.sql.Types;
|
10
7
|
import java.text.DateFormat;
|
11
8
|
import java.text.SimpleDateFormat;
|
12
9
|
import java.util.ArrayList;
|
13
10
|
import java.util.Arrays;
|
14
11
|
import java.util.List;
|
15
|
-
|
12
|
+
import java.util.Calendar;
|
16
13
|
import org.embulk.output.jdbc.BatchInsert;
|
17
14
|
import org.embulk.output.jdbc.JdbcColumn;
|
18
15
|
import org.embulk.output.jdbc.JdbcSchema;
|
@@ -21,6 +18,7 @@ import org.embulk.output.oracle.oci.OCIManager;
|
|
21
18
|
import org.embulk.output.oracle.oci.OCIWrapper;
|
22
19
|
import org.embulk.output.oracle.oci.RowBuffer;
|
23
20
|
import org.embulk.output.oracle.oci.TableDefinition;
|
21
|
+
import org.embulk.spi.time.Timestamp;
|
24
22
|
import org.embulk.spi.Exec;
|
25
23
|
import org.slf4j.Logger;
|
26
24
|
|
@@ -67,10 +65,10 @@ public class DirectBatchInsert implements BatchInsert
|
|
67
65
|
* boolean -> unused
|
68
66
|
* byte -> unused
|
69
67
|
* short -> unused
|
70
|
-
* int ->
|
71
|
-
* long ->
|
72
|
-
* BigDecimal ->
|
73
|
-
* String -> CHAR,VARCHAR,LONGVARCHAR,CLOB,
|
68
|
+
* int -> NUMBER
|
69
|
+
* long -> NUMBER
|
70
|
+
* BigDecimal -> NUMBER
|
71
|
+
* String -> CHAR,VARCHAR,LONGVARCHAR,CLOB,NCHAR,NVARCHAR,NCLOB,NUMBER
|
74
72
|
* NString -> unused
|
75
73
|
* bytes -> unused
|
76
74
|
* SqlDate -> unused
|
@@ -81,7 +79,7 @@ public class DirectBatchInsert implements BatchInsert
|
|
81
79
|
|
82
80
|
formats = new DateFormat[insertSchema.getCount()];
|
83
81
|
List<ColumnDefinition> columns = new ArrayList<ColumnDefinition>();
|
84
|
-
Timestamp dummy = new Timestamp(System.currentTimeMillis());
|
82
|
+
java.sql.Timestamp dummy = new java.sql.Timestamp(System.currentTimeMillis());
|
85
83
|
for (int i = 0; i < insertSchema.getCount(); i++) {
|
86
84
|
JdbcColumn insertColumn = insertSchema.getColumn(i);
|
87
85
|
switch (insertColumn.getSqlType()) {
|
@@ -247,7 +245,7 @@ public class DirectBatchInsert implements BatchInsert
|
|
247
245
|
@Override
|
248
246
|
public void setBigDecimal(BigDecimal v) throws IOException, SQLException
|
249
247
|
{
|
250
|
-
|
248
|
+
buffer.addValue(v);
|
251
249
|
}
|
252
250
|
|
253
251
|
@Override
|
@@ -269,21 +267,24 @@ public class DirectBatchInsert implements BatchInsert
|
|
269
267
|
}
|
270
268
|
|
271
269
|
@Override
|
272
|
-
public void setSqlDate(
|
270
|
+
public void setSqlDate(Timestamp v, Calendar calendar) throws IOException, SQLException
|
273
271
|
{
|
274
272
|
throw new SQLException("Unsupported");
|
275
273
|
}
|
276
274
|
|
277
275
|
@Override
|
278
|
-
public void setSqlTime(
|
276
|
+
public void setSqlTime(Timestamp v, Calendar calendar) throws IOException, SQLException
|
279
277
|
{
|
280
278
|
throw new SQLException("Unsupported");
|
281
279
|
}
|
282
280
|
|
283
281
|
@Override
|
284
|
-
public void setSqlTimestamp(Timestamp v,
|
282
|
+
public void setSqlTimestamp(Timestamp v, Calendar calendar) throws IOException, SQLException
|
285
283
|
{
|
286
|
-
|
284
|
+
java.sql.Timestamp t = new java.sql.Timestamp(v.toEpochMilli());
|
285
|
+
t.setNanos(v.getNano());
|
286
|
+
DateFormat format = formats[buffer.getCurrentColumn()];
|
287
|
+
format.setTimeZone(calendar.getTimeZone());
|
288
|
+
buffer.addValue(format.format(t));
|
287
289
|
}
|
288
|
-
|
289
290
|
}
|
@@ -18,8 +18,8 @@ public class OracleOutputConnection
|
|
18
18
|
{
|
19
19
|
private static final Map<String, String> CHARSET_NAMES = new HashMap<String, String>();
|
20
20
|
static {
|
21
|
-
CHARSET_NAMES.put("JA16SJIS", "
|
22
|
-
CHARSET_NAMES.put("JA16SJISTILDE", "
|
21
|
+
CHARSET_NAMES.put("JA16SJIS", "MS932");
|
22
|
+
CHARSET_NAMES.put("JA16SJISTILDE", "MS932");
|
23
23
|
CHARSET_NAMES.put("JA16EUC", "EUC-JP");
|
24
24
|
CHARSET_NAMES.put("JA16EUCTILDE", "EUC-JP");
|
25
25
|
CHARSET_NAMES.put("AL32UTF8", "UTF-8");
|
@@ -1,8 +1,10 @@
|
|
1
1
|
package org.embulk.output.oracle.oci;
|
2
2
|
|
3
|
+
import java.math.BigDecimal;
|
3
4
|
import java.nio.ByteBuffer;
|
4
5
|
import java.nio.charset.Charset;
|
5
6
|
|
7
|
+
|
6
8
|
public class RowBuffer
|
7
9
|
{
|
8
10
|
private final TableDefinition table;
|
@@ -13,7 +15,6 @@ public class RowBuffer
|
|
13
15
|
private int currentPosition = 0;
|
14
16
|
private final Charset charset;
|
15
17
|
|
16
|
-
|
17
18
|
public RowBuffer(TableDefinition table, int rowCount, Charset charset)
|
18
19
|
{
|
19
20
|
this.table = table;
|
@@ -59,6 +60,11 @@ public class RowBuffer
|
|
59
60
|
next();
|
60
61
|
}
|
61
62
|
|
63
|
+
public void addValue(BigDecimal value)
|
64
|
+
{
|
65
|
+
addValue(value.toPlainString());
|
66
|
+
}
|
67
|
+
|
62
68
|
private void next()
|
63
69
|
{
|
64
70
|
currentPosition += table.columns[currentColumn].columnSize;
|
@@ -89,7 +89,7 @@ public class OracleOutputPluginTestImpl
|
|
89
89
|
|
90
90
|
run("/yml/test-insert.yml");
|
91
91
|
|
92
|
-
|
92
|
+
assertGeneratedTable1(table);
|
93
93
|
}
|
94
94
|
|
95
95
|
public void testInsertDirect() throws Exception
|
@@ -151,7 +151,7 @@ public class OracleOutputPluginTestImpl
|
|
151
151
|
|
152
152
|
run("/yml/test-replace.yml");
|
153
153
|
|
154
|
-
|
154
|
+
assertGeneratedTable2(table);
|
155
155
|
}
|
156
156
|
|
157
157
|
public void testReplaceCreate() throws Exception
|
@@ -162,7 +162,7 @@ public class OracleOutputPluginTestImpl
|
|
162
162
|
|
163
163
|
run("/yml/test-replace.yml");
|
164
164
|
|
165
|
-
|
165
|
+
assertGeneratedTable2(table);
|
166
166
|
}
|
167
167
|
|
168
168
|
|
@@ -175,7 +175,7 @@ public class OracleOutputPluginTestImpl
|
|
175
175
|
|
176
176
|
run("/yml/test-replace-long-name.yml");
|
177
177
|
|
178
|
-
|
178
|
+
assertGeneratedTable2(table);
|
179
179
|
}
|
180
180
|
|
181
181
|
public void testReplaceLongNameMultibyte() throws Exception
|
@@ -184,7 +184,7 @@ public class OracleOutputPluginTestImpl
|
|
184
184
|
|
185
185
|
run("/yml/test-replace-long-name-multibyte.yml");
|
186
186
|
|
187
|
-
|
187
|
+
assertGeneratedTable2(table);
|
188
188
|
}
|
189
189
|
|
190
190
|
public void testStringTimestamp() throws Exception
|
@@ -196,7 +196,7 @@ public class OracleOutputPluginTestImpl
|
|
196
196
|
|
197
197
|
run("/yml/test-string-timestamp.yml");
|
198
198
|
|
199
|
-
assertTable(table
|
199
|
+
assertTable(table);
|
200
200
|
}
|
201
201
|
|
202
202
|
private void dropTable(String table) throws SQLException
|
@@ -220,12 +220,9 @@ public class OracleOutputPluginTestImpl
|
|
220
220
|
|
221
221
|
private void assertTable(String table) throws Exception
|
222
222
|
{
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
private void assertTable(String table, TimeZone timeZone) throws Exception
|
228
|
-
{
|
223
|
+
// datetime of UTC will be inserted by embulk.
|
224
|
+
// datetime of default timezone will be selected by JDBC.
|
225
|
+
TimeZone timeZone = TimeZone.getDefault();
|
229
226
|
List<List<Object>> rows = select(table);
|
230
227
|
|
231
228
|
/*
|
@@ -265,13 +262,11 @@ public class OracleOutputPluginTestImpl
|
|
265
262
|
}
|
266
263
|
}
|
267
264
|
|
268
|
-
private void
|
269
|
-
{
|
270
|
-
assertGeneratedTable(table, TimeZone.getTimeZone("GMT"));
|
271
|
-
}
|
272
|
-
|
273
|
-
private void assertGeneratedTable(String table, TimeZone timeZone) throws Exception
|
265
|
+
private void assertGeneratedTable1(String table) throws Exception
|
274
266
|
{
|
267
|
+
// datetime of UTC will be inserted by embulk.
|
268
|
+
// datetime of default timezone will be selected by JDBC.
|
269
|
+
TimeZone timeZone = TimeZone.getDefault();
|
275
270
|
List<List<Object>> rows = select(table);
|
276
271
|
|
277
272
|
/*
|
@@ -311,6 +306,50 @@ public class OracleOutputPluginTestImpl
|
|
311
306
|
}
|
312
307
|
}
|
313
308
|
|
309
|
+
private void assertGeneratedTable2(String table) throws Exception
|
310
|
+
{
|
311
|
+
// datetime of UTC will be inserted by embulk.
|
312
|
+
// datetime of default timezone will be selected by JDBC.
|
313
|
+
TimeZone timeZone = TimeZone.getDefault();
|
314
|
+
List<List<Object>> rows = select(table);
|
315
|
+
|
316
|
+
/*
|
317
|
+
A001,ABCDE,0,123.45,2015/03/05,2015/03/05 12:34:56
|
318
|
+
A002,あいうえお,-9999,-99999999.99,2015/03/06,2015/03/06 23:59:59
|
319
|
+
A003,,,,,
|
320
|
+
*/
|
321
|
+
|
322
|
+
assertEquals(3, rows.size());
|
323
|
+
Iterator<List<Object>> i1 = rows.iterator();
|
324
|
+
{
|
325
|
+
Iterator<Object> i2 = i1.next().iterator();
|
326
|
+
assertEquals("A001", i2.next());
|
327
|
+
assertEquals("ABCDE", i2.next());
|
328
|
+
assertEquals(new BigDecimal("0"), i2.next());
|
329
|
+
assertEquals(new BigDecimal("123.45"), i2.next());
|
330
|
+
assertEquals(toTimestamp("2015/03/05 00:00:00", timeZone), i2.next());
|
331
|
+
assertEquals(toOracleTimestamp("2015/03/05 12:34:56", timeZone), i2.next());
|
332
|
+
}
|
333
|
+
{
|
334
|
+
Iterator<Object> i2 = i1.next().iterator();
|
335
|
+
assertEquals("A002", i2.next());
|
336
|
+
assertEquals("あいうえお", i2.next());
|
337
|
+
assertEquals(new BigDecimal("-9999"), i2.next());
|
338
|
+
assertEquals(new BigDecimal("-99999999.99"), i2.next());
|
339
|
+
assertEquals(toTimestamp("2015/03/06 00:00:00", timeZone), i2.next());
|
340
|
+
assertEquals(toOracleTimestamp("2015/03/06 23:59:59", timeZone), i2.next());
|
341
|
+
}
|
342
|
+
{
|
343
|
+
Iterator<Object> i2 = i1.next().iterator();
|
344
|
+
assertEquals("A003", i2.next());
|
345
|
+
assertEquals(null, i2.next());
|
346
|
+
assertEquals(null, i2.next());
|
347
|
+
assertEquals(null, i2.next());
|
348
|
+
assertEquals(null, i2.next());
|
349
|
+
assertEquals(null, i2.next());
|
350
|
+
}
|
351
|
+
}
|
352
|
+
|
314
353
|
|
315
354
|
private Timestamp toTimestamp(String s, TimeZone timeZone)
|
316
355
|
{
|
@@ -22,4 +22,10 @@ out:
|
|
22
22
|
password: test_pw
|
23
23
|
table: TEST12345678901234567890
|
24
24
|
mode: replace
|
25
|
+
column_options:
|
26
|
+
VARCHAR2_ITEM: {type: 'VARCHAR2(40)'}
|
27
|
+
INTEGER_ITEM: {type: 'NUMBER(4,0)'}
|
28
|
+
NUMBER_ITEM: {type: 'NUMBER(10,2)'}
|
29
|
+
DATE_ITEM: {type: 'DATE'}
|
30
|
+
TIMESTAMP_ITEM: {type: 'TIMESTAMP'}
|
25
31
|
#driver_path: driver/ojdbc7.jar
|
@@ -22,4 +22,10 @@ out:
|
|
22
22
|
password: test_pw
|
23
23
|
table: TEST12345678901234567890123456
|
24
24
|
mode: replace
|
25
|
+
column_options:
|
26
|
+
VARCHAR2_ITEM: {type: 'VARCHAR2(40)'}
|
27
|
+
INTEGER_ITEM: {type: 'NUMBER(4,0)'}
|
28
|
+
NUMBER_ITEM: {type: 'NUMBER(10,2)'}
|
29
|
+
DATE_ITEM: {type: 'DATE'}
|
30
|
+
TIMESTAMP_ITEM: {type: 'TIMESTAMP'}
|
25
31
|
#driver_path: driver/ojdbc7.jar
|
@@ -22,4 +22,10 @@ out:
|
|
22
22
|
password: test_pw
|
23
23
|
table: TEST1
|
24
24
|
mode: replace
|
25
|
+
column_options:
|
26
|
+
VARCHAR2_ITEM: {type: 'VARCHAR2(40)'}
|
27
|
+
INTEGER_ITEM: {type: 'NUMBER(4,0)'}
|
28
|
+
NUMBER_ITEM: {type: 'NUMBER(10,2)'}
|
29
|
+
DATE_ITEM: {type: 'DATE'}
|
30
|
+
TIMESTAMP_ITEM: {type: 'TIMESTAMP'}
|
25
31
|
#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.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sadayuki Furuhashi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-06-11 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Inserts or updates records to a table.
|
14
14
|
email:
|
@@ -67,8 +67,8 @@ files:
|
|
67
67
|
- src/test/resources/yml/test-replace.yml
|
68
68
|
- src/test/resources/yml/test-string-timestamp.yml
|
69
69
|
- src/test/resources/yml/test-url.yml
|
70
|
-
- classpath/embulk-output-jdbc-0.
|
71
|
-
- classpath/embulk-output-oracle-0.
|
70
|
+
- classpath/embulk-output-jdbc-0.4.0.jar
|
71
|
+
- classpath/embulk-output-oracle-0.4.0.jar
|
72
72
|
homepage: https://github.com/embulk/embulk-output-jdbc
|
73
73
|
licenses:
|
74
74
|
- Apache 2.0
|
Binary file
|
Binary file
|