embulk-output-oracle 0.4.3 → 0.4.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/classpath/{embulk-output-jdbc-0.4.3.jar → embulk-output-jdbc-0.4.4.jar} +0 -0
- data/classpath/embulk-output-oracle-0.4.4.jar +0 -0
- data/lib/embulk/linux_x64/libembulk-output-oracle.so +0 -0
- data/lib/embulk/win_x64/embulk-output-oracle.dll +0 -0
- data/src/main/cpp/common/dir-path-load.cpp +9 -8
- data/src/main/cpp/common/dir-path-load.h +2 -1
- data/src/main/cpp/common/embulk-output-oracle.cpp +3 -4
- data/src/main/java/org/embulk/output/OracleOutputPlugin.java +6 -4
- data/src/main/java/org/embulk/output/oracle/DirectBatchInsert.java +25 -13
- data/src/main/java/org/embulk/output/oracle/OracleOutputConnection.java +36 -20
- data/src/main/java/org/embulk/output/oracle/oci/ColumnDefinition.java +5 -3
- data/src/main/java/org/embulk/output/oracle/oci/RowBuffer.java +26 -6
- data/src/main/java/org/embulk/output/oracle/oci/TableDefinition.java +3 -5
- data/src/test/cpp/common/embulk-output-oracle-test.cpp +16 -16
- data/src/test/java/org/embulk/output/oracle/OracleOutputPluginTest.java +32 -16
- data/src/test/java/org/embulk/output/oracle/OracleOutputPluginTestImpl.java +52 -17
- data/src/test/resources/data/test1/test1.csv +3 -3
- data/src/test/resources/yml/test-insert-direct-direct-method.yml +1 -0
- data/src/test/resources/yml/test-insert-direct-empty.yml +1 -0
- data/src/test/resources/yml/test-insert-direct-oci-method-split.yml +1 -0
- data/src/test/resources/yml/test-insert-direct-oci-method.yml +1 -0
- data/src/test/resources/yml/test-insert-direct.yml +1 -0
- data/src/test/resources/yml/test-insert-empty.yml +1 -0
- data/src/test/resources/yml/test-insert.yml +1 -0
- data/src/test/resources/yml/test-replace-empty.yml +3 -1
- data/src/test/resources/yml/test-replace-long-name-multibyte.yml +3 -1
- data/src/test/resources/yml/test-replace-long-name.yml +3 -1
- data/src/test/resources/yml/test-replace-oci-method.yml +34 -0
- data/src/test/resources/yml/test-replace.yml +3 -1
- data/src/test/resources/yml/test-string-timestamp.yml +1 -0
- data/src/test/resources/yml/test-truncate-insert-oci-method.yml +27 -0
- data/src/test/resources/yml/test-truncate-insert.yml +1 -0
- data/src/test/resources/yml/test-url.yml +1 -0
- metadata +7 -4
- data/classpath/embulk-output-oracle-0.4.3.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: aa5b04399c3ef5c8d91fbeae867f7ce998de9714
|
|
4
|
+
data.tar.gz: 5fa9f26c1e0207984c7c10beec13a70dbbf47bdc
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d1d8a0476e7d93df373da20b8031180271513808226763ed0dcc6de141ab117bee4d9f8938f0f44d248117e8c26c609c47483830c6c6856c42848dd99a411f1b
|
|
7
|
+
data.tar.gz: de40bade7f6474acb7456cc016fe1ae4bd514c9d8700171cf9907e9fd119fe66b032b9cf35990a8d59574a4ce6e76de8e81e291112e03fab11c6c0394f4f7dd1
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -116,18 +116,12 @@ static int isValid(EMBULK_OUTPUT_ORACLE_OCI_COL_DEF &colDef) {
|
|
|
116
116
|
return colDef.type != 0;
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
-
int embulk_output_oracle_prepareDirPathStream(EMBULK_OUTPUT_ORACLE_OCI_CONTEXT *context, const char *tableName,
|
|
119
|
+
int embulk_output_oracle_prepareDirPathStream(EMBULK_OUTPUT_ORACLE_OCI_CONTEXT *context, const char *tableName, EMBULK_OUTPUT_ORACLE_OCI_COL_DEF *colDefs) {
|
|
120
120
|
// load table name
|
|
121
121
|
if (check(context, "OCIAttrSet(OCI_ATTR_NAME)", OCIAttrSet(context->dp, OCI_HTYPE_DIRPATH_CTX, (void*)tableName, (ub4)strlen(tableName), OCI_ATTR_NAME, context->err))) {
|
|
122
122
|
return OCI_ERROR;
|
|
123
123
|
}
|
|
124
124
|
|
|
125
|
-
// need to set charset explicitly because database charset is not set by default.
|
|
126
|
-
ub2 tempCharsetId = charsetId;
|
|
127
|
-
if (check(context, "OCIAttrSet(OCI_ATTR_CHARSET_ID)", OCIAttrSet(context->dp, OCI_HTYPE_DIRPATH_CTX, (void*)&tempCharsetId, sizeof(ub2), OCI_ATTR_CHARSET_ID, context->err))) {
|
|
128
|
-
return OCI_ERROR;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
125
|
ub2 cols;
|
|
132
126
|
for (cols = 0; isValid(colDefs[cols]); cols++) ;
|
|
133
127
|
if (check(context, "OCIAttrSet(OCI_ATTR_NUM_COLS)", OCIAttrSet(context->dp, OCI_HTYPE_DIRPATH_CTX, &cols, sizeof(ub2), OCI_ATTR_NUM_COLS, context->err))) {
|
|
@@ -154,6 +148,10 @@ int embulk_output_oracle_prepareDirPathStream(EMBULK_OUTPUT_ORACLE_OCI_CONTEXT *
|
|
|
154
148
|
if (check(context, "OCIAttrSet(OCI_ATTR_DATA_SIZE)", OCIAttrSet(column, OCI_DTYPE_PARAM, &colDef.size, sizeof(ub4), OCI_ATTR_DATA_SIZE, context->err))) {
|
|
155
149
|
return OCI_ERROR;
|
|
156
150
|
}
|
|
151
|
+
// need to set charset explicitly because database charset is not set by default.
|
|
152
|
+
if (check(context, "OCIAttrSet(OCI_ATTR_CHARSET_ID)", OCIAttrSet(column, OCI_DTYPE_PARAM, &colDef.charsetId, sizeof(ub2), OCI_ATTR_CHARSET_ID, context->err))) {
|
|
153
|
+
return OCI_ERROR;
|
|
154
|
+
}
|
|
157
155
|
/*
|
|
158
156
|
if (check(context, "OCIAttrSet(OCI_ATTR_PRECISION)", OCIAttrSet(column, OCI_DTYPE_PARAM, &colDefs[i].precision, sizeof(ub4), OCI_ATTR_PRECISION, context->err))) {
|
|
159
157
|
return OCI_ERROR;
|
|
@@ -273,7 +271,10 @@ int embulk_output_oracle_loadBuffer(EMBULK_OUTPUT_ORACLE_OCI_CONTEXT *context, E
|
|
|
273
271
|
for (int col = 0; isValid(colDefs[col]); col++) {
|
|
274
272
|
ub4 size = colDefs[col].size;
|
|
275
273
|
if (colDefs[col].type == SQLT_CHR) {
|
|
276
|
-
|
|
274
|
+
// cannot use strnlen for calulating length of string because UTF-16 string may contain '\0'.
|
|
275
|
+
unsigned char size1 = *current++;
|
|
276
|
+
unsigned char size2 = *current++;
|
|
277
|
+
size = size1 + size2 * 256;
|
|
277
278
|
}
|
|
278
279
|
|
|
279
280
|
if (check(context, "OCIDirPathColArrayEntrySet", OCIDirPathColArrayEntrySet(context->dpca, context->err, colArrayRowCount, col, (ub1*)current, size, OCI_DIRPATH_COL_COMPLETE))) {
|
|
@@ -17,13 +17,14 @@ typedef struct _EMBULK_OUTPUT_ORACLE_OCI_COL_DEF {
|
|
|
17
17
|
const char *name;
|
|
18
18
|
ub4 type;
|
|
19
19
|
ub4 size;
|
|
20
|
+
ub2 charsetId;
|
|
20
21
|
const char *dateFormat;
|
|
21
22
|
} EMBULK_OUTPUT_ORACLE_OCI_COL_DEF;
|
|
22
23
|
|
|
23
24
|
|
|
24
25
|
int embulk_output_oracle_prepareDirPathCtx(EMBULK_OUTPUT_ORACLE_OCI_CONTEXT *context, const char *dbName, const char *userName, const char *password);
|
|
25
26
|
|
|
26
|
-
int embulk_output_oracle_prepareDirPathStream(EMBULK_OUTPUT_ORACLE_OCI_CONTEXT *context, const char *tableName,
|
|
27
|
+
int embulk_output_oracle_prepareDirPathStream(EMBULK_OUTPUT_ORACLE_OCI_CONTEXT *context, const char *tableName, EMBULK_OUTPUT_ORACLE_OCI_COL_DEF *colDefs);
|
|
27
28
|
|
|
28
29
|
int embulk_output_oracle_loadBuffer(EMBULK_OUTPUT_ORACLE_OCI_CONTEXT *context, EMBULK_OUTPUT_ORACLE_OCI_COL_DEF *colDefs, const char *buffer, int rowCount);
|
|
29
30
|
|
|
@@ -69,9 +69,6 @@ JNIEXPORT jboolean JNICALL Java_org_embulk_output_oracle_oci_OCI_prepareLoad
|
|
|
69
69
|
jstring tableNameString = (jstring)env->GetObjectField(table, tableNameFieldID);
|
|
70
70
|
const char *tableName = env->GetStringUTFChars(tableNameString, NULL);
|
|
71
71
|
|
|
72
|
-
jfieldID charsetIdFieldID = env->GetFieldID(tableClass, "charsetId", "S");
|
|
73
|
-
short charsetId = env->GetShortField(table, charsetIdFieldID);
|
|
74
|
-
|
|
75
72
|
jfieldID columnsFieldID = env->GetFieldID(tableClass, "columns", "[Lorg/embulk/output/oracle/oci/ColumnDefinition;");
|
|
76
73
|
jobjectArray columnArray = (jobjectArray)env->GetObjectField(table, columnsFieldID);
|
|
77
74
|
int columnCount = env->GetArrayLength(columnArray);
|
|
@@ -80,6 +77,7 @@ JNIEXPORT jboolean JNICALL Java_org_embulk_output_oracle_oci_OCI_prepareLoad
|
|
|
80
77
|
jfieldID columnNameFieldID = env->GetFieldID(columnClass, "columnName", "Ljava/lang/String;");
|
|
81
78
|
jfieldID columnTypeFieldID = env->GetFieldID(columnClass, "columnType", "I");
|
|
82
79
|
jfieldID columnSizeFieldID = env->GetFieldID(columnClass, "columnSize", "I");
|
|
80
|
+
jfieldID charsetIdFieldID = env->GetFieldID(columnClass, "charsetId", "S");
|
|
83
81
|
jfieldID columnDateFormatID = env->GetFieldID(columnClass, "columnDateFormat", "Ljava/lang/String;");
|
|
84
82
|
|
|
85
83
|
EMBULK_OUTPUT_ORACLE_OCI_COL_DEF *colDefs = new EMBULK_OUTPUT_ORACLE_OCI_COL_DEF[columnCount + 1];
|
|
@@ -91,6 +89,7 @@ JNIEXPORT jboolean JNICALL Java_org_embulk_output_oracle_oci_OCI_prepareLoad
|
|
|
91
89
|
colDefs[i].name = env->GetStringUTFChars(columnName, NULL);
|
|
92
90
|
colDefs[i].type = env->GetIntField(column, columnTypeFieldID);
|
|
93
91
|
colDefs[i].size = env->GetIntField(column, columnSizeFieldID);
|
|
92
|
+
colDefs[i].charsetId = env->GetShortField(column, charsetIdFieldID);
|
|
94
93
|
|
|
95
94
|
jstring columnDateFormat = (jstring)env->GetObjectField(column, columnDateFormatID);
|
|
96
95
|
if (columnDateFormat != NULL) {
|
|
@@ -106,7 +105,7 @@ JNIEXPORT jboolean JNICALL Java_org_embulk_output_oracle_oci_OCI_prepareLoad
|
|
|
106
105
|
colDefs[columnCount].size = 0;
|
|
107
106
|
colDefs[columnCount].dateFormat = NULL;
|
|
108
107
|
|
|
109
|
-
int result = embulk_output_oracle_prepareDirPathStream(context, tableName,
|
|
108
|
+
int result = embulk_output_oracle_prepareDirPathStream(context, tableName, colDefs);
|
|
110
109
|
|
|
111
110
|
for (int i = 0; i < columnCount; i++) {
|
|
112
111
|
EMBULK_OUTPUT_ORACLE_OCI_COL_DEF &colDef = colDefs[i];
|
|
@@ -10,7 +10,6 @@ import org.embulk.config.Config;
|
|
|
10
10
|
import org.embulk.config.ConfigDefault;
|
|
11
11
|
import org.embulk.output.jdbc.AbstractJdbcOutputPlugin;
|
|
12
12
|
import org.embulk.output.jdbc.BatchInsert;
|
|
13
|
-
import org.embulk.output.jdbc.JdbcOutputConnection;
|
|
14
13
|
import org.embulk.output.jdbc.JdbcOutputConnector;
|
|
15
14
|
import org.embulk.output.jdbc.StandardBatchInsert;
|
|
16
15
|
import org.embulk.output.oracle.DirectBatchInsert;
|
|
@@ -132,9 +131,11 @@ public class OracleOutputPlugin
|
|
|
132
131
|
JdbcOutputConnector connector = getConnector(task, true);
|
|
133
132
|
|
|
134
133
|
if (oracleTask.getInsertMethod() == InsertMethod.oci) {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
134
|
+
OracleCharset charset;
|
|
135
|
+
OracleCharset nationalCharset;
|
|
136
|
+
try (OracleOutputConnection connection = (OracleOutputConnection)connector.connect(true)) {
|
|
137
|
+
charset = connection.getOracleCharset();
|
|
138
|
+
nationalCharset = connection.getOracleNationalCharset();
|
|
138
139
|
}
|
|
139
140
|
|
|
140
141
|
return new DirectBatchInsert(
|
|
@@ -143,6 +144,7 @@ public class OracleOutputPlugin
|
|
|
143
144
|
oracleTask.getPassword(),
|
|
144
145
|
oracleTask.getTable(),
|
|
145
146
|
charset,
|
|
147
|
+
nationalCharset,
|
|
146
148
|
oracleTask.getBatchSize());
|
|
147
149
|
}
|
|
148
150
|
|
|
@@ -28,12 +28,12 @@ public class DirectBatchInsert implements BatchInsert
|
|
|
28
28
|
|
|
29
29
|
private final Logger logger = Exec.getLogger(DirectBatchInsert.class);
|
|
30
30
|
|
|
31
|
-
private
|
|
31
|
+
private List<String> ociKey;
|
|
32
32
|
private final String database;
|
|
33
33
|
private final String user;
|
|
34
34
|
private final String password;
|
|
35
|
-
private final String table;
|
|
36
35
|
private final OracleCharset charset;
|
|
36
|
+
private final OracleCharset nationalCharset;
|
|
37
37
|
private final int batchSize;
|
|
38
38
|
private RowBuffer buffer;
|
|
39
39
|
private long totalRows;
|
|
@@ -43,16 +43,15 @@ public class DirectBatchInsert implements BatchInsert
|
|
|
43
43
|
private DateFormat[] formats;
|
|
44
44
|
|
|
45
45
|
|
|
46
|
-
public DirectBatchInsert(String database, String user, String password, String table,
|
|
46
|
+
public DirectBatchInsert(String database, String user, String password, String table,
|
|
47
|
+
OracleCharset charset, OracleCharset nationalCharset, int batchSize)
|
|
47
48
|
{
|
|
48
49
|
this.database = database;
|
|
49
50
|
this.user = user;
|
|
50
51
|
this.password = password;
|
|
51
|
-
this.table = table;
|
|
52
52
|
this.charset = charset;
|
|
53
|
+
this.nationalCharset = nationalCharset;
|
|
53
54
|
this.batchSize = batchSize;
|
|
54
|
-
|
|
55
|
-
ociKey = Arrays.asList(database, user, table);
|
|
56
55
|
}
|
|
57
56
|
|
|
58
57
|
@Override
|
|
@@ -68,8 +67,8 @@ public class DirectBatchInsert implements BatchInsert
|
|
|
68
67
|
* int -> NUMBER
|
|
69
68
|
* long -> NUMBER
|
|
70
69
|
* BigDecimal -> NUMBER
|
|
71
|
-
* String -> CHAR,VARCHAR,LONGVARCHAR,CLOB,
|
|
72
|
-
* NString ->
|
|
70
|
+
* String -> CHAR,VARCHAR,LONGVARCHAR,CLOB,NUMBER
|
|
71
|
+
* NString -> NCHAR,NVARCHAR,LONGNVARCHAR,NCLOB
|
|
73
72
|
* bytes -> unused
|
|
74
73
|
* SqlDate -> unused
|
|
75
74
|
* SqlTime -> unused
|
|
@@ -87,10 +86,20 @@ public class DirectBatchInsert implements BatchInsert
|
|
|
87
86
|
case Types.VARCHAR:
|
|
88
87
|
case Types.LONGVARCHAR:
|
|
89
88
|
case Types.CLOB:
|
|
90
|
-
// TODO: CHAR(n CHAR)
|
|
91
89
|
columns.add(new ColumnDefinition(insertColumn.getName(),
|
|
92
90
|
ColumnDefinition.SQLT_CHR,
|
|
93
|
-
insertColumn.
|
|
91
|
+
insertColumn.getDataLength(),
|
|
92
|
+
charset.getId()));
|
|
93
|
+
break;
|
|
94
|
+
|
|
95
|
+
case Types.NCHAR:
|
|
96
|
+
case Types.NVARCHAR:
|
|
97
|
+
case Types.LONGNVARCHAR:
|
|
98
|
+
case Types.NCLOB:
|
|
99
|
+
columns.add(new ColumnDefinition(insertColumn.getName(),
|
|
100
|
+
ColumnDefinition.SQLT_CHR,
|
|
101
|
+
insertColumn.getDataLength(),
|
|
102
|
+
nationalCharset.getId()));
|
|
94
103
|
break;
|
|
95
104
|
|
|
96
105
|
case Types.DECIMAL:
|
|
@@ -102,7 +111,8 @@ public class DirectBatchInsert implements BatchInsert
|
|
|
102
111
|
}
|
|
103
112
|
columns.add(new ColumnDefinition(insertColumn.getName(),
|
|
104
113
|
ColumnDefinition.SQLT_CHR,
|
|
105
|
-
size
|
|
114
|
+
size,
|
|
115
|
+
charset.getId()));
|
|
106
116
|
break;
|
|
107
117
|
|
|
108
118
|
case Types.DATE:
|
|
@@ -122,6 +132,7 @@ public class DirectBatchInsert implements BatchInsert
|
|
|
122
132
|
columns.add(new ColumnDefinition(insertColumn.getName(),
|
|
123
133
|
ColumnDefinition.SQLT_CHR,
|
|
124
134
|
javaFormat.format(dummy).length(),
|
|
135
|
+
charset.getId(),
|
|
125
136
|
oracleFormat));
|
|
126
137
|
break;
|
|
127
138
|
|
|
@@ -136,7 +147,8 @@ public class DirectBatchInsert implements BatchInsert
|
|
|
136
147
|
rowSize += column.columnSize;
|
|
137
148
|
}
|
|
138
149
|
|
|
139
|
-
TableDefinition tableDefinition = new TableDefinition(
|
|
150
|
+
TableDefinition tableDefinition = new TableDefinition("\"" + loadTable + "\"", columns);
|
|
151
|
+
ociKey = Arrays.asList(database, user, loadTable);
|
|
140
152
|
ociManager.open(ociKey, database, user, password, tableDefinition);
|
|
141
153
|
|
|
142
154
|
buffer = new RowBuffer(tableDefinition, Math.max(batchSize / rowSize, 8), charset.getJavaCharset());
|
|
@@ -257,7 +269,7 @@ public class DirectBatchInsert implements BatchInsert
|
|
|
257
269
|
@Override
|
|
258
270
|
public void setNString(String v) throws IOException, SQLException
|
|
259
271
|
{
|
|
260
|
-
|
|
272
|
+
buffer.addValue(v, nationalCharset.getJavaCharset());
|
|
261
273
|
}
|
|
262
274
|
|
|
263
275
|
@Override
|
|
@@ -25,11 +25,12 @@ public class OracleOutputConnection
|
|
|
25
25
|
CHARSET_NAMES.put("JA16EUCTILDE", "EUC-JP");
|
|
26
26
|
CHARSET_NAMES.put("AL32UTF8", "UTF-8");
|
|
27
27
|
CHARSET_NAMES.put("UTF8", "UTF-8");
|
|
28
|
-
CHARSET_NAMES.put("AL16UTF16", "UTF-
|
|
28
|
+
CHARSET_NAMES.put("AL16UTF16", "UTF-16BE");
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
private final boolean direct;
|
|
32
32
|
private OracleCharset charset;
|
|
33
|
+
private OracleCharset nationalCharset;
|
|
33
34
|
|
|
34
35
|
public OracleOutputConnection(Connection connection, boolean autoCommit, boolean direct)
|
|
35
36
|
throws SQLException
|
|
@@ -136,34 +137,49 @@ public class OracleOutputConnection
|
|
|
136
137
|
public synchronized OracleCharset getOracleCharset() throws SQLException
|
|
137
138
|
{
|
|
138
139
|
if (charset == null) {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
140
|
+
charset = getOracleCharset("NLS_CHARACTERSET", "UTF8");
|
|
141
|
+
}
|
|
142
|
+
return charset;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
public synchronized OracleCharset getOracleNationalCharset() throws SQLException
|
|
146
|
+
{
|
|
147
|
+
if (nationalCharset == null) {
|
|
148
|
+
nationalCharset = getOracleCharset("NLS_NCHAR_CHARACTERSET", "AL16UTF16");
|
|
149
|
+
}
|
|
150
|
+
return nationalCharset;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
private OracleCharset getOracleCharset(String parameterName, String defaultCharsetName) throws SQLException
|
|
154
|
+
{
|
|
155
|
+
String charsetName = defaultCharsetName;
|
|
156
|
+
try (PreparedStatement statement = connection.prepareStatement("SELECT VALUE FROM NLS_DATABASE_PARAMETERS WHERE PARAMETER=?")) {
|
|
157
|
+
statement.setString(1, parameterName);
|
|
158
|
+
try (ResultSet resultSet = statement.executeQuery()) {
|
|
159
|
+
if (resultSet.next()) {
|
|
160
|
+
String nlsCharacterSet = resultSet.getString(1);
|
|
161
|
+
if (CHARSET_NAMES.containsKey(nlsCharacterSet)) {
|
|
162
|
+
charsetName = nlsCharacterSet;
|
|
147
163
|
}
|
|
148
164
|
}
|
|
149
165
|
}
|
|
166
|
+
}
|
|
150
167
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
charset = new OracleCharset(charsetName,
|
|
159
|
-
resultSet.getShort(1),
|
|
160
|
-
Charset.forName(CHARSET_NAMES.get(charsetName)));
|
|
168
|
+
try (PreparedStatement statement = connection.prepareStatement("SELECT NLS_CHARSET_ID(?) FROM DUAL")) {
|
|
169
|
+
statement.setString(1, charsetName);
|
|
170
|
+
try (ResultSet resultSet = statement.executeQuery()) {
|
|
171
|
+
if (!resultSet.next()) {
|
|
172
|
+
throw new SQLException("Unknown " + parameterName + " : " + charsetName);
|
|
161
173
|
}
|
|
174
|
+
|
|
175
|
+
return new OracleCharset(charsetName,
|
|
176
|
+
resultSet.getShort(1),
|
|
177
|
+
Charset.forName(CHARSET_NAMES.get(charsetName)));
|
|
162
178
|
}
|
|
163
179
|
}
|
|
164
|
-
return charset;
|
|
165
180
|
}
|
|
166
181
|
|
|
182
|
+
|
|
167
183
|
private static final String[] STANDARD_SIZE_TYPE_NAMES = {
|
|
168
184
|
"VARCHAR2", "NVARCHAR2",
|
|
169
185
|
};
|
|
@@ -8,19 +8,21 @@ public class ColumnDefinition
|
|
|
8
8
|
public final String columnName;
|
|
9
9
|
public final int columnType;
|
|
10
10
|
public final int columnSize;
|
|
11
|
+
public final short charsetId;
|
|
11
12
|
public final String columnDateFormat;
|
|
12
13
|
|
|
13
14
|
|
|
14
|
-
public ColumnDefinition(String columnName, int columnType, int columnSize, String columnDateFormat)
|
|
15
|
+
public ColumnDefinition(String columnName, int columnType, int columnSize, short charsetId, String columnDateFormat)
|
|
15
16
|
{
|
|
16
17
|
this.columnName = columnName;
|
|
17
18
|
this.columnType = columnType;
|
|
18
19
|
this.columnSize = columnSize;
|
|
20
|
+
this.charsetId = charsetId;
|
|
19
21
|
this.columnDateFormat = columnDateFormat;
|
|
20
22
|
}
|
|
21
23
|
|
|
22
|
-
public ColumnDefinition(String columnName, int columnType, int columnSize)
|
|
24
|
+
public ColumnDefinition(String columnName, int columnType, int columnSize, short charsetId)
|
|
23
25
|
{
|
|
24
|
-
this(columnName, columnType, columnSize, null);
|
|
26
|
+
this(columnName, columnType, columnSize, charsetId, null);
|
|
25
27
|
}
|
|
26
28
|
}
|
|
@@ -3,6 +3,7 @@ package org.embulk.output.oracle.oci;
|
|
|
3
3
|
import java.math.BigDecimal;
|
|
4
4
|
import java.nio.ByteBuffer;
|
|
5
5
|
import java.nio.charset.Charset;
|
|
6
|
+
import java.sql.SQLException;
|
|
6
7
|
|
|
7
8
|
|
|
8
9
|
public class RowBuffer
|
|
@@ -23,6 +24,10 @@ public class RowBuffer
|
|
|
23
24
|
|
|
24
25
|
int rowSize = 0;
|
|
25
26
|
for (ColumnDefinition column : table.columns) {
|
|
27
|
+
if (column.columnType == ColumnDefinition.SQLT_CHR) {
|
|
28
|
+
// for length of string
|
|
29
|
+
rowSize += 2;
|
|
30
|
+
}
|
|
26
31
|
rowSize += column.columnSize;
|
|
27
32
|
}
|
|
28
33
|
|
|
@@ -43,7 +48,12 @@ public class RowBuffer
|
|
|
43
48
|
next();
|
|
44
49
|
}
|
|
45
50
|
|
|
46
|
-
public void addValue(String value)
|
|
51
|
+
public void addValue(String value) throws SQLException
|
|
52
|
+
{
|
|
53
|
+
addValue(value, charset);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
public void addValue(String value, Charset charset) throws SQLException
|
|
47
57
|
{
|
|
48
58
|
if (isFull()) {
|
|
49
59
|
throw new IllegalStateException();
|
|
@@ -51,23 +61,33 @@ public class RowBuffer
|
|
|
51
61
|
|
|
52
62
|
ByteBuffer bytes = charset.encode(value);
|
|
53
63
|
int length = bytes.remaining();
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
64
|
+
if (length > 65535) {
|
|
65
|
+
throw new SQLException(String.format("byte count of string is too large (max : 65535, actual : %d).", length));
|
|
66
|
+
}
|
|
67
|
+
if (length > table.columns[currentColumn].columnSize) {
|
|
68
|
+
throw new SQLException(String.format("byte count of string is too large for column \"%s\" (max : %d, actual : %d).",
|
|
69
|
+
table.columns[currentColumn].columnName, table.columns[currentColumn].columnSize, length));
|
|
58
70
|
}
|
|
59
71
|
|
|
72
|
+
buffer[currentPosition] = (byte)length;
|
|
73
|
+
buffer[currentPosition + 1] = (byte)(length >> 8);
|
|
74
|
+
bytes.get(buffer, currentPosition + 2, length);
|
|
75
|
+
|
|
60
76
|
next();
|
|
61
77
|
}
|
|
62
78
|
|
|
63
|
-
public void addValue(BigDecimal value)
|
|
79
|
+
public void addValue(BigDecimal value) throws SQLException
|
|
64
80
|
{
|
|
65
81
|
addValue(value.toPlainString());
|
|
66
82
|
}
|
|
67
83
|
|
|
68
84
|
private void next()
|
|
69
85
|
{
|
|
86
|
+
if (table.columns[currentColumn].columnType == ColumnDefinition.SQLT_CHR) {
|
|
87
|
+
currentPosition += 2;
|
|
88
|
+
}
|
|
70
89
|
currentPosition += table.columns[currentColumn].columnSize;
|
|
90
|
+
|
|
71
91
|
currentColumn++;
|
|
72
92
|
if (currentColumn == table.columns.length) {
|
|
73
93
|
currentColumn = 0;
|
|
@@ -6,19 +6,17 @@ public class TableDefinition
|
|
|
6
6
|
{
|
|
7
7
|
|
|
8
8
|
public final String tableName;
|
|
9
|
-
public final short charsetId;
|
|
10
9
|
public final ColumnDefinition[] columns;
|
|
11
10
|
|
|
12
11
|
|
|
13
|
-
public TableDefinition(String tableName,
|
|
12
|
+
public TableDefinition(String tableName, ColumnDefinition... columns)
|
|
14
13
|
{
|
|
15
14
|
this.tableName = tableName;
|
|
16
|
-
this.charsetId = charsetId;
|
|
17
15
|
this.columns = columns;
|
|
18
16
|
}
|
|
19
17
|
|
|
20
|
-
public TableDefinition(String tableName,
|
|
18
|
+
public TableDefinition(String tableName, List<ColumnDefinition> columns)
|
|
21
19
|
{
|
|
22
|
-
this(tableName,
|
|
20
|
+
this(tableName, columns.toArray(new ColumnDefinition[columns.size()]));
|
|
23
21
|
}
|
|
24
22
|
}
|
|
@@ -10,23 +10,23 @@ static int test(EMBULK_OUTPUT_ORACLE_OCI_CONTEXT *context, const char *db, const
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
EMBULK_OUTPUT_ORACLE_OCI_COL_DEF colDefs[] = {
|
|
13
|
-
{"ID", SQLT_INT, 4},
|
|
14
|
-
//{"ID", SQLT_CHR, 8},
|
|
15
|
-
{"NUM", SQLT_INT, 4},
|
|
16
|
-
//{"NUM", SQLT_CHR, 12},
|
|
17
|
-
{"VALUE1", SQLT_CHR, 60},
|
|
18
|
-
{"VALUE2", SQLT_CHR, 60},
|
|
19
|
-
{"VALUE3", SQLT_CHR, 60},
|
|
20
|
-
{"VALUE4", SQLT_CHR, 60},
|
|
21
|
-
{"VALUE5", SQLT_CHR, 60},
|
|
22
|
-
{"VALUE6", SQLT_CHR, 60},
|
|
23
|
-
{"VALUE7", SQLT_CHR, 60},
|
|
24
|
-
{"VALUE8", SQLT_CHR, 60},
|
|
25
|
-
{"VALUE9", SQLT_CHR, 60},
|
|
26
|
-
{"VALUE10", SQLT_CHR, 60},
|
|
27
|
-
{NULL, 0, 0}
|
|
13
|
+
{"ID", SQLT_INT, 4, 832},
|
|
14
|
+
//{"ID", SQLT_CHR, 8, 832},
|
|
15
|
+
{"NUM", SQLT_INT, 4, 832},
|
|
16
|
+
//{"NUM", SQLT_CHR, 12, 832},
|
|
17
|
+
{"VALUE1", SQLT_CHR, 60, 832},
|
|
18
|
+
{"VALUE2", SQLT_CHR, 60, 832},
|
|
19
|
+
{"VALUE3", SQLT_CHR, 60, 832},
|
|
20
|
+
{"VALUE4", SQLT_CHR, 60, 832},
|
|
21
|
+
{"VALUE5", SQLT_CHR, 60, 832},
|
|
22
|
+
{"VALUE6", SQLT_CHR, 60, 832},
|
|
23
|
+
{"VALUE7", SQLT_CHR, 60, 832},
|
|
24
|
+
{"VALUE8", SQLT_CHR, 60, 832},
|
|
25
|
+
{"VALUE9", SQLT_CHR, 60, 832},
|
|
26
|
+
{"VALUE10", SQLT_CHR, 60, 832},
|
|
27
|
+
{NULL, 0, 0, 832}
|
|
28
28
|
};
|
|
29
|
-
if (embulk_output_oracle_prepareDirPathStream(context, "EXAMPLE",
|
|
29
|
+
if (embulk_output_oracle_prepareDirPathStream(context, "EXAMPLE", colDefs)) {
|
|
30
30
|
return OCI_ERROR;
|
|
31
31
|
}
|
|
32
32
|
|
|
@@ -131,7 +131,12 @@ public class OracleOutputPluginTest
|
|
|
131
131
|
@Test
|
|
132
132
|
public void testInsert() throws Exception
|
|
133
133
|
{
|
|
134
|
-
|
|
134
|
+
// cannot test with Oracle 11g JDBC driver for Oracle 12c,
|
|
135
|
+
// because the driver returns sqlType=1111 for NCHAR/NVARCHAR2,
|
|
136
|
+
// and ColumnSetterFactory#newCoalesceColumnSetter throws Exception.
|
|
137
|
+
// even if setting {value_type: string} for NCHAR/NVARCHAR2,
|
|
138
|
+
// PreparedStatement#setNull(parameterIndex, sqlType=1111) throws Exception.
|
|
139
|
+
invoke(test12c, "testInsert");
|
|
135
140
|
}
|
|
136
141
|
|
|
137
142
|
@Test
|
|
@@ -143,13 +148,19 @@ public class OracleOutputPluginTest
|
|
|
143
148
|
@Test
|
|
144
149
|
public void testInsertEmpty() throws Exception
|
|
145
150
|
{
|
|
146
|
-
invoke("testInsertEmpty");
|
|
151
|
+
invoke(test12c, "testInsertEmpty");
|
|
147
152
|
}
|
|
148
153
|
|
|
149
154
|
@Test
|
|
150
155
|
public void testTruncateInsert() throws Exception
|
|
151
156
|
{
|
|
152
|
-
invoke("testTruncateInsert");
|
|
157
|
+
invoke(test12c, "testTruncateInsert");
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
@Test
|
|
161
|
+
public void testTruncateInsertOCIMethod() throws Exception
|
|
162
|
+
{
|
|
163
|
+
invoke(test12c, "testTruncateInsertOCIMethod");
|
|
153
164
|
}
|
|
154
165
|
|
|
155
166
|
@Test
|
|
@@ -161,7 +172,7 @@ public class OracleOutputPluginTest
|
|
|
161
172
|
@Test
|
|
162
173
|
public void testInsertDirect() throws Exception
|
|
163
174
|
{
|
|
164
|
-
invoke("testInsertDirect");
|
|
175
|
+
invoke(test12c, "testInsertDirect");
|
|
165
176
|
}
|
|
166
177
|
|
|
167
178
|
@Test
|
|
@@ -173,67 +184,72 @@ public class OracleOutputPluginTest
|
|
|
173
184
|
@Test
|
|
174
185
|
public void testInsertDirectEmpty() throws Exception
|
|
175
186
|
{
|
|
176
|
-
invoke("testInsertDirectEmpty");
|
|
187
|
+
invoke(test12c, "testInsertDirectEmpty");
|
|
177
188
|
}
|
|
178
189
|
|
|
179
190
|
@Test
|
|
180
191
|
public void testInsertDirectDirectMethod() throws Exception
|
|
181
192
|
{
|
|
182
|
-
|
|
183
|
-
invoke(test11g, "testInsertDirectDirectMethod");
|
|
193
|
+
invoke(test12c, "testInsertDirectDirectMethod");
|
|
184
194
|
}
|
|
185
195
|
|
|
186
196
|
@Test
|
|
187
197
|
public void testInsertDirectOCIMethod() throws Exception
|
|
188
198
|
{
|
|
189
|
-
invoke("testInsertDirectOCIMethod");
|
|
199
|
+
invoke(test12c, "testInsertDirectOCIMethod");
|
|
190
200
|
}
|
|
191
201
|
|
|
192
202
|
@Test
|
|
193
203
|
public void testInsertDirectOCIMethodSplit() throws Exception
|
|
194
204
|
{
|
|
195
|
-
invoke("testInsertDirectOCIMethodSplit");
|
|
205
|
+
invoke(test12c, "testInsertDirectOCIMethodSplit");
|
|
196
206
|
}
|
|
197
207
|
|
|
198
208
|
@Test
|
|
199
209
|
public void testUrl() throws Exception
|
|
200
210
|
{
|
|
201
|
-
invoke("testUrl");
|
|
211
|
+
invoke(test12c, "testUrl");
|
|
202
212
|
}
|
|
203
213
|
|
|
204
214
|
@Test
|
|
205
215
|
public void testReplace() throws Exception
|
|
206
216
|
{
|
|
207
|
-
invoke("testReplace");
|
|
217
|
+
invoke(test12c, "testReplace");
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
@Test
|
|
221
|
+
public void testReplaceOCIMethod() throws Exception
|
|
222
|
+
{
|
|
223
|
+
invoke(test12c, "testReplaceOCIMethod");
|
|
208
224
|
}
|
|
209
225
|
|
|
210
226
|
@Test
|
|
211
227
|
public void testReplaceEmpty() throws Exception
|
|
212
228
|
{
|
|
213
|
-
invoke("testReplaceEmpty");
|
|
229
|
+
invoke(test12c, "testReplaceEmpty");
|
|
214
230
|
}
|
|
215
231
|
|
|
216
232
|
@Test
|
|
217
233
|
public void testReplaceLongName() throws Exception
|
|
218
234
|
{
|
|
219
|
-
invoke("testReplaceLongName");
|
|
235
|
+
invoke(test12c, "testReplaceLongName");
|
|
220
236
|
}
|
|
221
237
|
|
|
222
238
|
@Test
|
|
223
239
|
public void testReplaceLongNameMultibyte() throws Exception
|
|
224
240
|
{
|
|
225
|
-
invoke("testReplaceLongNameMultibyte");
|
|
241
|
+
invoke(test12c, "testReplaceLongNameMultibyte");
|
|
226
242
|
}
|
|
227
243
|
|
|
228
244
|
@Test
|
|
229
245
|
public void testReplaceCreate() throws Exception
|
|
230
246
|
{
|
|
231
|
-
invoke("testReplaceCreate");
|
|
247
|
+
invoke(test12c, "testReplaceCreate");
|
|
232
248
|
}
|
|
233
249
|
|
|
234
250
|
@Test
|
|
235
251
|
public void testStringTimestamp() throws Exception
|
|
236
252
|
{
|
|
237
|
-
invoke("testStringTimestamp");
|
|
253
|
+
invoke(test12c, "testStringTimestamp");
|
|
238
254
|
}
|
|
239
255
|
}
|
|
@@ -65,8 +65,8 @@ public class OracleOutputPluginTestImpl
|
|
|
65
65
|
|
|
66
66
|
} catch (SQLException e) {
|
|
67
67
|
System.err.println(e);
|
|
68
|
-
//throw new RuntimeException("You should prepare a schema on Oracle (database = 'TESTDB', user = 'TEST_USER', password = 'test_pw', charset = UTF-8).");
|
|
69
|
-
System.err.println("Warning: prepare a schema on Oracle (database = 'TESTDB', user = 'TEST_USER', password = 'test_pw', charset = UTF-8).");
|
|
68
|
+
//throw new RuntimeException("You should prepare a schema on Oracle 12c (database = 'TESTDB', user = 'TEST_USER', password = 'test_pw', charset = UTF-8).");
|
|
69
|
+
System.err.println("Warning: prepare a schema on Oracle 12c (database = 'TESTDB', user = 'TEST_USER', password = 'test_pw', charset = UTF-8).");
|
|
70
70
|
// for example
|
|
71
71
|
// CREATE USER EMBULK_USER IDENTIFIED BY "embulk_pw";
|
|
72
72
|
// GRANT DBA TO EMBULK_USER;
|
|
@@ -125,6 +125,19 @@ public class OracleOutputPluginTestImpl
|
|
|
125
125
|
assertTable(table);
|
|
126
126
|
}
|
|
127
127
|
|
|
128
|
+
public void testTruncateInsertOCIMethod() throws Exception
|
|
129
|
+
{
|
|
130
|
+
String table = "TEST1";
|
|
131
|
+
|
|
132
|
+
dropTable(table);
|
|
133
|
+
createTable(table);
|
|
134
|
+
insertRecord(table);
|
|
135
|
+
|
|
136
|
+
run("/yml/test-truncate-insert-oci-method.yml");
|
|
137
|
+
|
|
138
|
+
assertTable(table);
|
|
139
|
+
}
|
|
140
|
+
|
|
128
141
|
public void testTruncateInsertCreate() throws Exception
|
|
129
142
|
{
|
|
130
143
|
String table = "TEST1";
|
|
@@ -233,6 +246,18 @@ public class OracleOutputPluginTestImpl
|
|
|
233
246
|
assertGeneratedTable2(table);
|
|
234
247
|
}
|
|
235
248
|
|
|
249
|
+
public void testReplaceOCIMethod() throws Exception
|
|
250
|
+
{
|
|
251
|
+
String table = "TEST1";
|
|
252
|
+
|
|
253
|
+
dropTable(table);
|
|
254
|
+
createTable(table);
|
|
255
|
+
|
|
256
|
+
run("/yml/test-replace-oci-method.yml");
|
|
257
|
+
|
|
258
|
+
assertGeneratedTable2(table);
|
|
259
|
+
}
|
|
260
|
+
|
|
236
261
|
public void testReplaceEmpty() throws Exception
|
|
237
262
|
{
|
|
238
263
|
String table = "TEST1";
|
|
@@ -300,8 +325,9 @@ public class OracleOutputPluginTestImpl
|
|
|
300
325
|
{
|
|
301
326
|
String sql = String.format("CREATE TABLE %s ("
|
|
302
327
|
+ "ID CHAR(4),"
|
|
303
|
-
+ "VARCHAR2_ITEM VARCHAR2(
|
|
304
|
-
+ "
|
|
328
|
+
+ "VARCHAR2_ITEM VARCHAR2(6),"
|
|
329
|
+
+ "NVARCHAR2_ITEM NVARCHAR2(6),"
|
|
330
|
+
+ "INTEGER_ITEM NUMBER(4,0),"
|
|
305
331
|
+ "NUMBER_ITEM NUMBER(10,2),"
|
|
306
332
|
+ "DATE_ITEM DATE,"
|
|
307
333
|
+ "TIMESTAMP_ITEM TIMESTAMP,"
|
|
@@ -311,7 +337,7 @@ public class OracleOutputPluginTestImpl
|
|
|
311
337
|
|
|
312
338
|
private void insertRecord(String table) throws SQLException
|
|
313
339
|
{
|
|
314
|
-
executeSQL(String.format("INSERT INTO %s VALUES('9999', NULL, NULL, NULL, NULL, NULL)", table));
|
|
340
|
+
executeSQL(String.format("INSERT INTO %s VALUES('9999', NULL, NULL, NULL, NULL, NULL, NULL)", table));
|
|
315
341
|
}
|
|
316
342
|
|
|
317
343
|
private void assertTable(String table) throws Exception
|
|
@@ -322,9 +348,9 @@ public class OracleOutputPluginTestImpl
|
|
|
322
348
|
List<List<Object>> rows = select(table);
|
|
323
349
|
|
|
324
350
|
/*
|
|
325
|
-
A001,ABCDE,0,123.45,2015/03/05,2015/03/05 12:34:56
|
|
326
|
-
A002
|
|
327
|
-
A003
|
|
351
|
+
A001,ABCDE,abcde,,0,123.45,2015/03/05,2015/03/05 12:34:56
|
|
352
|
+
A002,AB,abcdef,-9999,-99999999.99,2015/03/06,2015/03/06 23:59:59
|
|
353
|
+
A003,,,,,,
|
|
328
354
|
*/
|
|
329
355
|
|
|
330
356
|
assertEquals(3, rows.size());
|
|
@@ -333,6 +359,7 @@ public class OracleOutputPluginTestImpl
|
|
|
333
359
|
Iterator<Object> i2 = i1.next().iterator();
|
|
334
360
|
assertEquals("A001", i2.next());
|
|
335
361
|
assertEquals("ABCDE", i2.next());
|
|
362
|
+
assertEquals("abcde", i2.next());
|
|
336
363
|
assertEquals(new BigDecimal("0"), i2.next());
|
|
337
364
|
assertEquals(new BigDecimal("123.45"), i2.next());
|
|
338
365
|
assertEquals(toTimestamp("2015/03/05 00:00:00", timeZone), i2.next());
|
|
@@ -341,7 +368,8 @@ public class OracleOutputPluginTestImpl
|
|
|
341
368
|
{
|
|
342
369
|
Iterator<Object> i2 = i1.next().iterator();
|
|
343
370
|
assertEquals("A002", i2.next());
|
|
344
|
-
assertEquals("
|
|
371
|
+
assertEquals("AB", i2.next());
|
|
372
|
+
assertEquals("abcdef", i2.next());
|
|
345
373
|
assertEquals(new BigDecimal("-9999"), i2.next());
|
|
346
374
|
assertEquals(new BigDecimal("-99999999.99"), i2.next());
|
|
347
375
|
assertEquals(toTimestamp("2015/03/06 00:00:00", timeZone), i2.next());
|
|
@@ -355,6 +383,7 @@ public class OracleOutputPluginTestImpl
|
|
|
355
383
|
assertEquals(null, i2.next());
|
|
356
384
|
assertEquals(null, i2.next());
|
|
357
385
|
assertEquals(null, i2.next());
|
|
386
|
+
assertEquals(null, i2.next());
|
|
358
387
|
}
|
|
359
388
|
}
|
|
360
389
|
|
|
@@ -372,9 +401,9 @@ public class OracleOutputPluginTestImpl
|
|
|
372
401
|
List<List<Object>> rows = select(table);
|
|
373
402
|
|
|
374
403
|
/*
|
|
375
|
-
A001,ABCDE,0,123.45,2015/03/05,2015/03/05 12:34:56
|
|
376
|
-
A002
|
|
377
|
-
A003
|
|
404
|
+
A001,ABCDE,abcde,0,123.45,2015/03/05,2015/03/05 12:34:56
|
|
405
|
+
A002,AB,abcdef,-9999,-99999999.99,2015/03/06,2015/03/06 23:59:59
|
|
406
|
+
A003,,,,,,
|
|
378
407
|
*/
|
|
379
408
|
|
|
380
409
|
assertEquals(3, rows.size());
|
|
@@ -383,6 +412,7 @@ public class OracleOutputPluginTestImpl
|
|
|
383
412
|
Iterator<Object> i2 = i1.next().iterator();
|
|
384
413
|
assertEquals("A001", i2.next());
|
|
385
414
|
assertEquals("ABCDE", i2.next());
|
|
415
|
+
assertEquals("abcde", i2.next());
|
|
386
416
|
assertEquals(new BigDecimal("0"), i2.next());
|
|
387
417
|
assertEquals("123.45", i2.next());
|
|
388
418
|
assertEquals(toOracleTimestamp("2015/03/05 00:00:00", timeZone), i2.next());
|
|
@@ -391,7 +421,8 @@ public class OracleOutputPluginTestImpl
|
|
|
391
421
|
{
|
|
392
422
|
Iterator<Object> i2 = i1.next().iterator();
|
|
393
423
|
assertEquals("A002", i2.next());
|
|
394
|
-
assertEquals("
|
|
424
|
+
assertEquals("AB", i2.next());
|
|
425
|
+
assertEquals("abcdef", i2.next());
|
|
395
426
|
assertEquals(new BigDecimal("-9999"), i2.next());
|
|
396
427
|
assertEquals("-99999999.99", i2.next());
|
|
397
428
|
assertEquals(toOracleTimestamp("2015/03/06 00:00:00", timeZone), i2.next());
|
|
@@ -405,6 +436,7 @@ public class OracleOutputPluginTestImpl
|
|
|
405
436
|
assertEquals(null, i2.next());
|
|
406
437
|
assertEquals(null, i2.next());
|
|
407
438
|
assertEquals(null, i2.next());
|
|
439
|
+
assertEquals(null, i2.next());
|
|
408
440
|
}
|
|
409
441
|
}
|
|
410
442
|
|
|
@@ -416,9 +448,9 @@ public class OracleOutputPluginTestImpl
|
|
|
416
448
|
List<List<Object>> rows = select(table);
|
|
417
449
|
|
|
418
450
|
/*
|
|
419
|
-
A001,ABCDE,0,123.45,2015/03/05,2015/03/05 12:34:56
|
|
420
|
-
A002
|
|
421
|
-
A003
|
|
451
|
+
A001,ABCDE,abcde,0,123.45,2015/03/05,2015/03/05 12:34:56
|
|
452
|
+
A002,AB,abcdef,-9999,-99999999.99,2015/03/06,2015/03/06 23:59:59
|
|
453
|
+
A003,,,,,,
|
|
422
454
|
*/
|
|
423
455
|
|
|
424
456
|
assertEquals(3, rows.size());
|
|
@@ -427,6 +459,7 @@ public class OracleOutputPluginTestImpl
|
|
|
427
459
|
Iterator<Object> i2 = i1.next().iterator();
|
|
428
460
|
assertEquals("A001", i2.next());
|
|
429
461
|
assertEquals("ABCDE", i2.next());
|
|
462
|
+
assertEquals("abcde", i2.next());
|
|
430
463
|
assertEquals(new BigDecimal("0"), i2.next());
|
|
431
464
|
assertEquals(new BigDecimal("123.45"), i2.next());
|
|
432
465
|
assertEquals(toTimestamp("2015/03/05 00:00:00", timeZone), i2.next());
|
|
@@ -435,7 +468,8 @@ public class OracleOutputPluginTestImpl
|
|
|
435
468
|
{
|
|
436
469
|
Iterator<Object> i2 = i1.next().iterator();
|
|
437
470
|
assertEquals("A002", i2.next());
|
|
438
|
-
assertEquals("
|
|
471
|
+
assertEquals("AB", i2.next());
|
|
472
|
+
assertEquals("abcdef", i2.next());
|
|
439
473
|
assertEquals(new BigDecimal("-9999"), i2.next());
|
|
440
474
|
assertEquals(new BigDecimal("-99999999.99"), i2.next());
|
|
441
475
|
assertEquals(toTimestamp("2015/03/06 00:00:00", timeZone), i2.next());
|
|
@@ -449,6 +483,7 @@ public class OracleOutputPluginTestImpl
|
|
|
449
483
|
assertEquals(null, i2.next());
|
|
450
484
|
assertEquals(null, i2.next());
|
|
451
485
|
assertEquals(null, i2.next());
|
|
486
|
+
assertEquals(null, i2.next());
|
|
452
487
|
}
|
|
453
488
|
}
|
|
454
489
|
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
A001,ABCDE,0,123.45,2015/03/05,2015/03/05 12:34:56
|
|
2
|
-
A002
|
|
3
|
-
A003
|
|
1
|
+
A001,ABCDE,abcde,0,123.45,2015/03/05,2015/03/05 12:34:56
|
|
2
|
+
A002,AB,abcdef,-9999,-99999999.99,2015/03/06,2015/03/06 23:59:59
|
|
3
|
+
A003,,,,,,
|
|
@@ -10,6 +10,7 @@ in:
|
|
|
10
10
|
columns:
|
|
11
11
|
- {name: ID, type: string}
|
|
12
12
|
- {name: VARCHAR2_ITEM, type: string}
|
|
13
|
+
- {name: NVARCHAR2_ITEM, type: string}
|
|
13
14
|
- {name: INTEGER_ITEM, type: long}
|
|
14
15
|
- {name: NUMBER_ITEM, type: string}
|
|
15
16
|
- {name: DATE_ITEM, type: timestamp, format: '%Y/%m/%d'}
|
|
@@ -10,6 +10,7 @@ in:
|
|
|
10
10
|
columns:
|
|
11
11
|
- {name: ID, type: string}
|
|
12
12
|
- {name: VARCHAR2_ITEM, type: string}
|
|
13
|
+
- {name: NVARCHAR2_ITEM, type: string}
|
|
13
14
|
- {name: INTEGER_ITEM, type: long}
|
|
14
15
|
- {name: NUMBER_ITEM, type: string}
|
|
15
16
|
- {name: DATE_ITEM, type: timestamp, format: '%Y/%m/%d'}
|
|
@@ -10,6 +10,7 @@ in:
|
|
|
10
10
|
columns:
|
|
11
11
|
- {name: ID, type: string}
|
|
12
12
|
- {name: VARCHAR2_ITEM, type: string}
|
|
13
|
+
- {name: NVARCHAR2_ITEM, type: string}
|
|
13
14
|
- {name: INTEGER_ITEM, type: long}
|
|
14
15
|
- {name: NUMBER_ITEM, type: string}
|
|
15
16
|
- {name: DATE_ITEM, type: timestamp, format: '%Y/%m/%d'}
|
|
@@ -10,6 +10,7 @@ in:
|
|
|
10
10
|
columns:
|
|
11
11
|
- {name: ID, type: string}
|
|
12
12
|
- {name: VARCHAR2_ITEM, type: string}
|
|
13
|
+
- {name: NVARCHAR2_ITEM, type: string}
|
|
13
14
|
- {name: INTEGER_ITEM, type: long}
|
|
14
15
|
- {name: NUMBER_ITEM, type: string}
|
|
15
16
|
- {name: DATE_ITEM, type: timestamp, format: '%Y/%m/%d'}
|
|
@@ -10,6 +10,7 @@ in:
|
|
|
10
10
|
columns:
|
|
11
11
|
- {name: ID, type: string}
|
|
12
12
|
- {name: VARCHAR2_ITEM, type: string}
|
|
13
|
+
- {name: NVARCHAR2_ITEM, type: string}
|
|
13
14
|
- {name: INTEGER_ITEM, type: long}
|
|
14
15
|
- {name: NUMBER_ITEM, type: string}
|
|
15
16
|
- {name: DATE_ITEM, type: timestamp, format: '%Y/%m/%d'}
|
|
@@ -10,6 +10,7 @@ in:
|
|
|
10
10
|
columns:
|
|
11
11
|
- {name: ID, type: string}
|
|
12
12
|
- {name: VARCHAR2_ITEM, type: string}
|
|
13
|
+
- {name: NVARCHAR2_ITEM, type: string}
|
|
13
14
|
- {name: INTEGER_ITEM, type: long}
|
|
14
15
|
- {name: NUMBER_ITEM, type: string}
|
|
15
16
|
- {name: DATE_ITEM, type: timestamp, format: '%Y/%m/%d'}
|
|
@@ -10,6 +10,7 @@ in:
|
|
|
10
10
|
columns:
|
|
11
11
|
- {name: ID, type: string}
|
|
12
12
|
- {name: VARCHAR2_ITEM, type: string}
|
|
13
|
+
- {name: NVARCHAR2_ITEM, type: string}
|
|
13
14
|
- {name: INTEGER_ITEM, type: long}
|
|
14
15
|
- {name: NUMBER_ITEM, type: string}
|
|
15
16
|
- {name: DATE_ITEM, type: timestamp, format: '%Y/%m/%d'}
|
|
@@ -10,6 +10,7 @@ in:
|
|
|
10
10
|
columns:
|
|
11
11
|
- {name: ID, type: string}
|
|
12
12
|
- {name: VARCHAR2_ITEM, type: string}
|
|
13
|
+
- {name: NVARCHAR2_ITEM, type: string}
|
|
13
14
|
- {name: INTEGER_ITEM, type: long}
|
|
14
15
|
- {name: NUMBER_ITEM, type: string}
|
|
15
16
|
- {name: DATE_ITEM, type: timestamp, format: '%Y/%m/%d'}
|
|
@@ -23,7 +24,8 @@ out:
|
|
|
23
24
|
table: TEST1
|
|
24
25
|
mode: replace
|
|
25
26
|
column_options:
|
|
26
|
-
VARCHAR2_ITEM: {type: 'VARCHAR2(
|
|
27
|
+
VARCHAR2_ITEM: {type: 'VARCHAR2(6)'}
|
|
28
|
+
NVARCHAR2_ITEM: {type: 'NVARCHAR2(6)'}
|
|
27
29
|
INTEGER_ITEM: {type: 'NUMBER(4,0)'}
|
|
28
30
|
NUMBER_ITEM: {type: 'NUMBER(10,2)'}
|
|
29
31
|
DATE_ITEM: {type: 'DATE'}
|
|
@@ -10,6 +10,7 @@ in:
|
|
|
10
10
|
columns:
|
|
11
11
|
- {name: ID, type: string}
|
|
12
12
|
- {name: VARCHAR2_ITEM, type: string}
|
|
13
|
+
- {name: NVARCHAR2_ITEM, type: string}
|
|
13
14
|
- {name: INTEGER_ITEM, type: long}
|
|
14
15
|
- {name: NUMBER_ITEM, type: string}
|
|
15
16
|
- {name: DATE_ITEM, type: timestamp, format: '%Y/%m/%d'}
|
|
@@ -23,7 +24,8 @@ out:
|
|
|
23
24
|
table: TEST123456789012345678
|
|
24
25
|
mode: replace
|
|
25
26
|
column_options:
|
|
26
|
-
VARCHAR2_ITEM: {type: 'VARCHAR2(
|
|
27
|
+
VARCHAR2_ITEM: {type: 'VARCHAR2(6)'}
|
|
28
|
+
NVARCHAR2_ITEM: {type: 'NVARCHAR2(6)'}
|
|
27
29
|
INTEGER_ITEM: {type: 'NUMBER(4,0)'}
|
|
28
30
|
NUMBER_ITEM: {type: 'NUMBER(10,2)'}
|
|
29
31
|
DATE_ITEM: {type: 'DATE'}
|
|
@@ -10,6 +10,7 @@ in:
|
|
|
10
10
|
columns:
|
|
11
11
|
- {name: ID, type: string}
|
|
12
12
|
- {name: VARCHAR2_ITEM, type: string}
|
|
13
|
+
- {name: NVARCHAR2_ITEM, type: string}
|
|
13
14
|
- {name: INTEGER_ITEM, type: long}
|
|
14
15
|
- {name: NUMBER_ITEM, type: string}
|
|
15
16
|
- {name: DATE_ITEM, type: timestamp, format: '%Y/%m/%d'}
|
|
@@ -23,7 +24,8 @@ out:
|
|
|
23
24
|
table: TEST12345678901234567890123456
|
|
24
25
|
mode: replace
|
|
25
26
|
column_options:
|
|
26
|
-
VARCHAR2_ITEM: {type: 'VARCHAR2(
|
|
27
|
+
VARCHAR2_ITEM: {type: 'VARCHAR2(6)'}
|
|
28
|
+
NVARCHAR2_ITEM: {type: 'NVARCHAR2(6)'}
|
|
27
29
|
INTEGER_ITEM: {type: 'NUMBER(4,0)'}
|
|
28
30
|
NUMBER_ITEM: {type: 'NUMBER(10,2)'}
|
|
29
31
|
DATE_ITEM: {type: 'DATE'}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
in:
|
|
2
|
+
type: file
|
|
3
|
+
path_prefix: '/data/test1/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: 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: replace
|
|
26
|
+
insert_method: oci
|
|
27
|
+
column_options:
|
|
28
|
+
VARCHAR2_ITEM: {type: 'VARCHAR2(6)'}
|
|
29
|
+
NVARCHAR2_ITEM: {type: 'NVARCHAR2(6)'}
|
|
30
|
+
INTEGER_ITEM: {type: 'NUMBER(4,0)'}
|
|
31
|
+
NUMBER_ITEM: {type: 'NUMBER(10,2)'}
|
|
32
|
+
DATE_ITEM: {type: 'DATE'}
|
|
33
|
+
TIMESTAMP_ITEM: {type: 'TIMESTAMP'}
|
|
34
|
+
#driver_path: driver/ojdbc7.jar
|
|
@@ -10,6 +10,7 @@ in:
|
|
|
10
10
|
columns:
|
|
11
11
|
- {name: ID, type: string}
|
|
12
12
|
- {name: VARCHAR2_ITEM, type: string}
|
|
13
|
+
- {name: NVARCHAR2_ITEM, type: string}
|
|
13
14
|
- {name: INTEGER_ITEM, type: long}
|
|
14
15
|
- {name: NUMBER_ITEM, type: string}
|
|
15
16
|
- {name: DATE_ITEM, type: timestamp, format: '%Y/%m/%d'}
|
|
@@ -23,7 +24,8 @@ out:
|
|
|
23
24
|
table: TEST1
|
|
24
25
|
mode: replace
|
|
25
26
|
column_options:
|
|
26
|
-
VARCHAR2_ITEM: {type: 'VARCHAR2(
|
|
27
|
+
VARCHAR2_ITEM: {type: 'VARCHAR2(6)'}
|
|
28
|
+
NVARCHAR2_ITEM: {type: 'NVARCHAR2(6)'}
|
|
27
29
|
INTEGER_ITEM: {type: 'NUMBER(4,0)'}
|
|
28
30
|
NUMBER_ITEM: {type: 'NUMBER(10,2)'}
|
|
29
31
|
DATE_ITEM: {type: 'DATE'}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
in:
|
|
2
|
+
type: file
|
|
3
|
+
path_prefix: '/data/test1/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: 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: truncate_insert
|
|
26
|
+
insert_method: oci
|
|
27
|
+
#driver_path: driver/ojdbc7.jar
|
|
@@ -10,6 +10,7 @@ in:
|
|
|
10
10
|
columns:
|
|
11
11
|
- {name: ID, type: string}
|
|
12
12
|
- {name: VARCHAR2_ITEM, type: string}
|
|
13
|
+
- {name: NVARCHAR2_ITEM, type: string}
|
|
13
14
|
- {name: INTEGER_ITEM, type: long}
|
|
14
15
|
- {name: NUMBER_ITEM, type: string}
|
|
15
16
|
- {name: DATE_ITEM, type: timestamp, format: '%Y/%m/%d'}
|
|
@@ -10,6 +10,7 @@ in:
|
|
|
10
10
|
columns:
|
|
11
11
|
- {name: ID, type: string}
|
|
12
12
|
- {name: VARCHAR2_ITEM, type: string}
|
|
13
|
+
- {name: NVARCHAR2_ITEM, type: string}
|
|
13
14
|
- {name: INTEGER_ITEM, type: long}
|
|
14
15
|
- {name: NUMBER_ITEM, type: string}
|
|
15
16
|
- {name: DATE_ITEM, type: timestamp, format: '%Y/%m/%d'}
|
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.
|
|
4
|
+
version: 0.4.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:
|
|
11
|
+
date: 2016-01-04 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: Inserts or updates records to a table.
|
|
14
14
|
email:
|
|
@@ -19,6 +19,7 @@ extra_rdoc_files: []
|
|
|
19
19
|
files:
|
|
20
20
|
- README.md
|
|
21
21
|
- build.gradle
|
|
22
|
+
- lib/embulk/linux_x64/libembulk-output-oracle.so
|
|
22
23
|
- lib/embulk/output/oracle.rb
|
|
23
24
|
- lib/embulk/win_x64/embulk-output-oracle.dll
|
|
24
25
|
- src/main/cpp/common/dir-path-load.cpp
|
|
@@ -66,12 +67,14 @@ files:
|
|
|
66
67
|
- src/test/resources/yml/test-replace-empty.yml
|
|
67
68
|
- src/test/resources/yml/test-replace-long-name-multibyte.yml
|
|
68
69
|
- src/test/resources/yml/test-replace-long-name.yml
|
|
70
|
+
- src/test/resources/yml/test-replace-oci-method.yml
|
|
69
71
|
- src/test/resources/yml/test-replace.yml
|
|
70
72
|
- src/test/resources/yml/test-string-timestamp.yml
|
|
73
|
+
- src/test/resources/yml/test-truncate-insert-oci-method.yml
|
|
71
74
|
- src/test/resources/yml/test-truncate-insert.yml
|
|
72
75
|
- src/test/resources/yml/test-url.yml
|
|
73
|
-
- classpath/embulk-output-jdbc-0.4.
|
|
74
|
-
- classpath/embulk-output-oracle-0.4.
|
|
76
|
+
- classpath/embulk-output-jdbc-0.4.4.jar
|
|
77
|
+
- classpath/embulk-output-oracle-0.4.4.jar
|
|
75
78
|
homepage: https://github.com/embulk/embulk-output-jdbc
|
|
76
79
|
licenses:
|
|
77
80
|
- Apache 2.0
|
|
Binary file
|