embulk-output-oracle 0.7.8 → 0.7.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/classpath/embulk-output-jdbc-0.7.9.jar +0 -0
- data/classpath/{embulk-output-oracle-0.7.8.jar → embulk-output-oracle-0.7.9.jar} +0 -0
- data/src/main/java/org/embulk/output/OracleOutputPlugin.java +14 -1
- data/src/main/java/org/embulk/output/oracle/DirectBatchInsert.java +5 -6
- data/src/main/java/org/embulk/output/oracle/OracleOutputConnection.java +27 -38
- metadata +4 -4
- data/classpath/embulk-output-jdbc-0.7.8.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: ca1526b2ef4b47df791546e857435f62a4cd24c2
|
4
|
+
data.tar.gz: dda1b751b35040326ecd19a054ed9ebc8a90d20c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5f309bc65a52b1848e9684900a82804107387f35b2070cfb54b8a72f3d9db9c8233e8da1e962574ac5f4b8f3042df0e03b7ec28af096607f649c2c6b0be35ed8
|
7
|
+
data.tar.gz: b9e324bb613f72f91139beb146f94db2eb8b7699398767fe160b476c38bb6420e2c496abb0cae43f105fbd4507e886c2f73cedab2a0c2f3c3b2d9b6736a403ea
|
data/README.md
CHANGED
@@ -16,6 +16,8 @@ Oracle output plugin for Embulk loads records to Oracle.
|
|
16
16
|
- **user**: database login user name (string, required)
|
17
17
|
- **password**: database login password (string, default: "")
|
18
18
|
- **database**: destination database name (string, required if url is not set or insert_method is "oci")
|
19
|
+
- **schema** destination schema name (string, optional)
|
20
|
+
- **temp_schema**: schema name for intermediate tables. by default, intermediate tables will be created in the same schema as destination table. replace mode doesn't support temp_schema. (string, optional)
|
19
21
|
- **url**: URL of the JDBC connection (string, optional)
|
20
22
|
- **table**: destination table name (string, required)
|
21
23
|
- **options**: extra connection properties (hash, default: {})
|
Binary file
|
Binary file
|
@@ -42,6 +42,10 @@ public class OracleOutputPlugin
|
|
42
42
|
@ConfigDefault("null")
|
43
43
|
public Optional<String> getSchema();
|
44
44
|
|
45
|
+
@Config("temp_schema")
|
46
|
+
@ConfigDefault("null")
|
47
|
+
public Optional<String> getTempSchema();
|
48
|
+
|
45
49
|
@Config("url")
|
46
50
|
@ConfigDefault("null")
|
47
51
|
public Optional<String> getUrl();
|
@@ -122,6 +126,16 @@ public class OracleOutputPlugin
|
|
122
126
|
return new OracleOutputConnector(url, props, oracleTask.getSchema().orNull(), oracleTask.getInsertMethod() == InsertMethod.direct);
|
123
127
|
}
|
124
128
|
|
129
|
+
@Override
|
130
|
+
protected TableIdentifier buildIntermediateTableId(JdbcOutputConnection con, PluginTask task, String tableName) {
|
131
|
+
OraclePluginTask oracleTask = (OraclePluginTask) task;
|
132
|
+
// replace mode doesn't support temp_schema because ALTER TABLE doesn't support schema.
|
133
|
+
if (oracleTask.getTempSchema().isPresent() && oracleTask.getMode() != Mode.REPLACE) {
|
134
|
+
return new TableIdentifier(null, oracleTask.getTempSchema().get(), tableName);
|
135
|
+
}
|
136
|
+
return super.buildIntermediateTableId(con, task, tableName);
|
137
|
+
}
|
138
|
+
|
125
139
|
@Override
|
126
140
|
protected BatchInsert newBatchInsert(PluginTask task, Optional<MergeConfig> mergeConfig) throws IOException, SQLException
|
127
141
|
{
|
@@ -144,7 +158,6 @@ public class OracleOutputPlugin
|
|
144
158
|
String.format("%s:%d/%s", oracleTask.getHost().get(), oracleTask.getPort(), oracleTask.getDatabase().get()),
|
145
159
|
oracleTask.getUser(),
|
146
160
|
oracleTask.getPassword(),
|
147
|
-
oracleTask.getSchema().orNull(),
|
148
161
|
charset,
|
149
162
|
nationalCharset,
|
150
163
|
oracleTask.getBatchSize());
|
@@ -14,6 +14,7 @@ import java.util.List;
|
|
14
14
|
import org.embulk.output.jdbc.BatchInsert;
|
15
15
|
import org.embulk.output.jdbc.JdbcColumn;
|
16
16
|
import org.embulk.output.jdbc.JdbcSchema;
|
17
|
+
import org.embulk.output.jdbc.TableIdentifier;
|
17
18
|
import org.embulk.output.jdbc.TimestampFormat;
|
18
19
|
import org.embulk.output.oracle.oci.ColumnDefinition;
|
19
20
|
import org.embulk.output.oracle.oci.OCI;
|
@@ -31,7 +32,6 @@ public class DirectBatchInsert implements BatchInsert
|
|
31
32
|
private final String database;
|
32
33
|
private final String user;
|
33
34
|
private final String password;
|
34
|
-
private final String schema;
|
35
35
|
private final OracleCharset charset;
|
36
36
|
private final OracleCharset nationalCharset;
|
37
37
|
private final int batchSize;
|
@@ -41,20 +41,19 @@ public class DirectBatchInsert implements BatchInsert
|
|
41
41
|
private DateFormat[] formats;
|
42
42
|
|
43
43
|
|
44
|
-
public DirectBatchInsert(String database, String user, String password,
|
44
|
+
public DirectBatchInsert(String database, String user, String password,
|
45
45
|
OracleCharset charset, OracleCharset nationalCharset, int batchSize)
|
46
46
|
{
|
47
47
|
this.database = database;
|
48
48
|
this.user = user;
|
49
49
|
this.password = password;
|
50
|
-
this.schema = schema;
|
51
50
|
this.charset = charset;
|
52
51
|
this.nationalCharset = nationalCharset;
|
53
52
|
this.batchSize = batchSize;
|
54
53
|
}
|
55
54
|
|
56
55
|
@Override
|
57
|
-
public void prepare(
|
56
|
+
public void prepare(TableIdentifier loadTable, JdbcSchema insertSchema) throws SQLException
|
58
57
|
{
|
59
58
|
|
60
59
|
/*
|
@@ -141,8 +140,8 @@ public class DirectBatchInsert implements BatchInsert
|
|
141
140
|
|
142
141
|
}
|
143
142
|
|
144
|
-
TableDefinition tableDefinition = new TableDefinition(
|
145
|
-
ociKey = Arrays.asList(database, user, loadTable);
|
143
|
+
TableDefinition tableDefinition = new TableDefinition(loadTable.getSchemaName(), loadTable.getTableName(), columns);
|
144
|
+
ociKey = Arrays.asList(database, user, loadTable.getTableName());
|
146
145
|
OCIWrapper oci = ociManager.open(ociKey, database, user, password, tableDefinition, batchSize);
|
147
146
|
|
148
147
|
buffer = new RowBuffer(oci, tableDefinition);
|
@@ -11,10 +11,11 @@ import java.util.HashMap;
|
|
11
11
|
import java.util.List;
|
12
12
|
import java.util.Map;
|
13
13
|
|
14
|
-
import org.embulk.output.jdbc.JdbcOutputConnection;
|
15
14
|
import org.embulk.output.jdbc.JdbcColumn;
|
15
|
+
import org.embulk.output.jdbc.JdbcOutputConnection;
|
16
16
|
import org.embulk.output.jdbc.JdbcSchema;
|
17
17
|
import org.embulk.output.jdbc.MergeConfig;
|
18
|
+
import org.embulk.output.jdbc.TableIdentifier;
|
18
19
|
|
19
20
|
public class OracleOutputConnection
|
20
21
|
extends JdbcOutputConnection
|
@@ -63,52 +64,28 @@ public class OracleOutputConnection
|
|
63
64
|
}
|
64
65
|
|
65
66
|
@Override
|
66
|
-
public void dropTableIfExists(
|
67
|
+
public void dropTableIfExists(TableIdentifier table) throws SQLException
|
67
68
|
{
|
68
|
-
if (tableExists(
|
69
|
-
dropTable(
|
69
|
+
if (tableExists(table)) {
|
70
|
+
dropTable(table);
|
70
71
|
}
|
71
72
|
}
|
72
73
|
|
73
74
|
@Override
|
74
|
-
protected void dropTableIfExists(Statement stmt,
|
75
|
-
if (tableExists(
|
76
|
-
dropTable(stmt,
|
75
|
+
protected void dropTableIfExists(Statement stmt, TableIdentifier table) throws SQLException {
|
76
|
+
if (tableExists(table)) {
|
77
|
+
dropTable(stmt, table);
|
77
78
|
}
|
78
79
|
}
|
79
80
|
|
80
81
|
@Override
|
81
|
-
public void createTableIfNotExists(
|
82
|
+
public void createTableIfNotExists(TableIdentifier table, JdbcSchema schema) throws SQLException
|
82
83
|
{
|
83
|
-
if (!tableExists(
|
84
|
-
createTable(
|
84
|
+
if (!tableExists(table)) {
|
85
|
+
createTable(table, schema);
|
85
86
|
}
|
86
87
|
}
|
87
88
|
|
88
|
-
public void createTable(String tableName, JdbcSchema schema) throws SQLException
|
89
|
-
{
|
90
|
-
Statement stmt = connection.createStatement();
|
91
|
-
try {
|
92
|
-
String sql = buildCreateTableSql(tableName, schema);
|
93
|
-
executeUpdate(stmt, sql);
|
94
|
-
commitIfNecessary(connection);
|
95
|
-
} catch (SQLException ex) {
|
96
|
-
throw safeRollback(connection, ex);
|
97
|
-
} finally {
|
98
|
-
stmt.close();
|
99
|
-
}
|
100
|
-
}
|
101
|
-
|
102
|
-
protected String buildCreateTableSql(String name, JdbcSchema schema)
|
103
|
-
{
|
104
|
-
StringBuilder sb = new StringBuilder();
|
105
|
-
|
106
|
-
sb.append("CREATE TABLE ");
|
107
|
-
quoteIdentifierString(sb, name);
|
108
|
-
sb.append(buildCreateTableSchemaSql(schema));
|
109
|
-
return sb.toString();
|
110
|
-
}
|
111
|
-
|
112
89
|
private static String getSchema(Connection connection) throws SQLException
|
113
90
|
{
|
114
91
|
// Because old Oracle JDBC drivers don't support Connection#getSchema method.
|
@@ -124,7 +101,19 @@ public class OracleOutputConnection
|
|
124
101
|
}
|
125
102
|
|
126
103
|
@Override
|
127
|
-
protected String
|
104
|
+
protected String buildRenameTableSql(TableIdentifier fromTable, TableIdentifier toTable)
|
105
|
+
{
|
106
|
+
// ALTER TABLE doesn't support schema
|
107
|
+
StringBuilder sb = new StringBuilder();
|
108
|
+
sb.append("ALTER TABLE ");
|
109
|
+
quoteIdentifierString(sb, fromTable.getTableName());
|
110
|
+
sb.append(" RENAME TO ");
|
111
|
+
quoteIdentifierString(sb, toTable.getTableName());
|
112
|
+
return sb.toString();
|
113
|
+
}
|
114
|
+
|
115
|
+
@Override
|
116
|
+
protected String buildPreparedInsertSql(TableIdentifier toTable, JdbcSchema toTableSchema) throws SQLException
|
128
117
|
{
|
129
118
|
String sql = super.buildPreparedInsertSql(toTable, toTableSchema);
|
130
119
|
if (direct) {
|
@@ -199,12 +188,12 @@ public class OracleOutputConnection
|
|
199
188
|
}
|
200
189
|
|
201
190
|
@Override
|
202
|
-
protected String buildCollectMergeSql(List<
|
191
|
+
protected String buildCollectMergeSql(List<TableIdentifier> fromTables, JdbcSchema schema, TableIdentifier toTable, MergeConfig mergeConfig) throws SQLException
|
203
192
|
{
|
204
193
|
StringBuilder sb = new StringBuilder();
|
205
194
|
|
206
195
|
sb.append("MERGE INTO ");
|
207
|
-
sb.append(
|
196
|
+
sb.append(quoteTableIdentifier(toTable));
|
208
197
|
sb.append(" T");
|
209
198
|
sb.append(" USING (");
|
210
199
|
for (int i = 0; i < fromTables.size(); i++) {
|
@@ -212,7 +201,7 @@ public class OracleOutputConnection
|
|
212
201
|
sb.append(" SELECT ");
|
213
202
|
sb.append(buildColumns(schema, ""));
|
214
203
|
sb.append(" FROM ");
|
215
|
-
sb.append(
|
204
|
+
sb.append(quoteTableIdentifier(fromTables.get(i)));
|
216
205
|
}
|
217
206
|
sb.append(") S");
|
218
207
|
sb.append(" ON (");
|
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.7.
|
4
|
+
version: 0.7.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sadayuki Furuhashi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-06-23 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Inserts or updates records to a table.
|
14
14
|
email:
|
@@ -19,8 +19,8 @@ extra_rdoc_files: []
|
|
19
19
|
files:
|
20
20
|
- README.md
|
21
21
|
- build.gradle
|
22
|
-
- classpath/embulk-output-jdbc-0.7.
|
23
|
-
- classpath/embulk-output-oracle-0.7.
|
22
|
+
- classpath/embulk-output-jdbc-0.7.9.jar
|
23
|
+
- classpath/embulk-output-oracle-0.7.9.jar
|
24
24
|
- lib/embulk/native/x86_64-linux/libembulk-output-oracle-oci.so
|
25
25
|
- lib/embulk/native/x86_64-windows/embulk-output-oracle-oci.dll
|
26
26
|
- lib/embulk/output/oracle.rb
|
Binary file
|