embulk-output-sqlserver 0.8.2 → 0.8.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a0eddd477e809123693ab12675860d1f704b620c
4
- data.tar.gz: 2d8cbf8fd8cfd85806b8eff879954caf16225800
3
+ metadata.gz: ab40cc336da42a9437f0b4a8ec1928e144ec0f28
4
+ data.tar.gz: 53b18f070e754cc3d7bd2fb76daecfd1d4fd3782
5
5
  SHA512:
6
- metadata.gz: aa332ea6d815c01aab521bb2b4f22b5d846858db0bc8dfbd922e5dd48327b52b192d08ece8154b939216660a4323947252247e39d59af09742dd9552bc18c4f9
7
- data.tar.gz: fd0286fe07a6ce64ad53f427660ed607e733ae2c311ebeb9eac50a6a947d507e747568f0407bac5810d347429d9b1f1cda2c610a5a38f53b69e316b89d3a1a22
6
+ metadata.gz: 31e2b132a400055182386085c3ab56e00896dc89db87b166c60772fc750bfac02ae0cb7a079a35afc03dbaa7fb421f176b6d700fb93e1d23470fac1c5afc29ff
7
+ data.tar.gz: 4d409facf4724f1d166211799bcb2993e39460cd21cb2790966fffe9f285dced7d14e168f37ca666dc6d011bf5ee783a0aed2d5026d3c47d7779087e5526b6c8
data/README.md CHANGED
@@ -28,8 +28,9 @@ embulk "-J-Djava.library.path=C:\drivers" run input-sqlserver.yml
28
28
  - **table**: destination table name (string, required)
29
29
  - **create_table_constraint**: table constraint added to `CREATE TABLE` statement, like `CREATE TABLE <table_name> (<column1> <type1>, <column2> <type2>, ..., <create_table_constraint>) <create_table_option>`.
30
30
  - **create_table_option**: table option added to `CREATE TABLE` statement, like `CREATE TABLE <table_name> (<column1> <type1>, <column2> <type2>, ..., <create_table_constraint>) <create_table_option>`.
31
+ - **transaction_isolation**: transaction isolation level for each connection ("read_uncommitted", "read_committed", "repeatable_read" or "serializable"). if not specified, database default value will be used.
31
32
  - **options**: extra connection properties (hash, default: {})
32
- - **retry_limit**: max retry count for database operations (integer, default: 12)
33
+ - **retry_limit**: max retry count for database operations (integer, default: 12). When intermediate table to create already created by another process, this plugin will retry with another table name to avoid collision.
33
34
  - **retry_wait**: initial retry wait time in milliseconds (integer, default: 1000 (1 second))
34
35
  - **max_retry_wait**: upper limit of retry wait, which will be doubled at every retry (integer, default: 1800000 (30 minutes))
35
36
  - **mode**: "insert", "insert_direct", "truncate_insert" , "replace" or "merge". See below. (string, required)
@@ -9,6 +9,7 @@ import org.embulk.config.ConfigException;
9
9
  import org.embulk.output.jdbc.AbstractJdbcOutputPlugin;
10
10
  import org.embulk.output.jdbc.BatchInsert;
11
11
  import org.embulk.output.jdbc.JdbcOutputConnection;
12
+ import org.embulk.output.jdbc.JdbcOutputConnector;
12
13
  import org.embulk.output.jdbc.MergeConfig;
13
14
  import org.embulk.output.jdbc.StandardBatchInsert;
14
15
  import org.embulk.output.jdbc.TableIdentifier;
@@ -130,7 +131,7 @@ public class SQLServerOutputPlugin
130
131
  }
131
132
 
132
133
  @Override
133
- protected SQLServerOutputConnector getConnector(PluginTask task, boolean retryableMetadataOperation)
134
+ protected JdbcOutputConnector getConnector(PluginTask task, boolean retryableMetadataOperation)
134
135
  {
135
136
  SQLServerPluginTask sqlServerTask = (SQLServerPluginTask) task;
136
137
  boolean useJtdsDriver = false;
@@ -166,7 +167,8 @@ public class SQLServerOutputPlugin
166
167
 
167
168
  UrlAndProperties urlProps = getUrlAndProperties(sqlServerTask, useJtdsDriver);
168
169
  logConnectionProperties(urlProps.getUrl(), urlProps.getProps());
169
- return new SQLServerOutputConnector(urlProps.getUrl(), urlProps.getProps(), sqlServerTask.getSchema().orNull());
170
+ return new SQLServerOutputConnector(urlProps.getUrl(), urlProps.getProps(), sqlServerTask.getSchema().orNull(),
171
+ sqlServerTask.getTransactionIsolation());
170
172
  }
171
173
 
172
174
  private UrlAndProperties getUrlAndProperties(SQLServerPluginTask sqlServerTask, boolean useJtdsDriver)
@@ -219,6 +219,8 @@ public class NativeBatchInsert implements BatchInsert
219
219
  @Override
220
220
  public void flush() throws IOException, SQLException
221
221
  {
222
+ if (batchWeight == 0) return;
223
+
222
224
  logger.info(String.format("Loading %,d rows", batchRows));
223
225
  long startTime = System.currentTimeMillis();
224
226
 
@@ -236,9 +238,6 @@ public class NativeBatchInsert implements BatchInsert
236
238
  @Override
237
239
  public void finish() throws IOException, SQLException
238
240
  {
239
- if (getBatchWeight() != 0) {
240
- flush();
241
- }
242
241
  client.commit(true);
243
242
  }
244
243
 
@@ -14,11 +14,10 @@ import org.embulk.output.jdbc.TableIdentifier;
14
14
  public class SQLServerOutputConnection
15
15
  extends JdbcOutputConnection
16
16
  {
17
- public SQLServerOutputConnection(Connection connection, String schemaName, boolean autoCommit)
17
+ public SQLServerOutputConnection(Connection connection, String schemaName)
18
18
  throws SQLException
19
19
  {
20
20
  super(connection, schemaName);
21
- connection.setAutoCommit(autoCommit);
22
21
  }
23
22
 
24
23
  @Override
@@ -7,13 +7,17 @@ import java.sql.ResultSet;
7
7
  import java.sql.SQLException;
8
8
  import java.util.Properties;
9
9
 
10
- import org.embulk.output.jdbc.JdbcOutputConnector;
10
+ import org.embulk.output.jdbc.JdbcOutputConnection;
11
+ import org.embulk.output.jdbc.AbstractJdbcOutputConnector;
12
+ import org.embulk.output.jdbc.TransactionIsolation;
11
13
  import org.embulk.spi.Exec;
12
14
  import org.slf4j.Logger;
13
15
 
16
+ import com.google.common.base.Optional;
17
+
14
18
 
15
19
  public class SQLServerOutputConnector
16
- implements JdbcOutputConnector
20
+ extends AbstractJdbcOutputConnector
17
21
  {
18
22
  private final Logger logger = Exec.getLogger(getClass());
19
23
 
@@ -21,15 +25,17 @@ public class SQLServerOutputConnector
21
25
  private final Properties properties;
22
26
  private final String schemaName;
23
27
 
24
- public SQLServerOutputConnector(String url, Properties properties, String schemaName)
28
+ public SQLServerOutputConnector(String url, Properties properties, String schemaName,
29
+ Optional<TransactionIsolation> transactionIsolation)
25
30
  {
31
+ super(transactionIsolation);
26
32
  this.url = url;
27
33
  this.properties = properties;
28
34
  this.schemaName = schemaName;
29
35
  }
30
36
 
31
37
  @Override
32
- public SQLServerOutputConnection connect(boolean autoCommit) throws SQLException
38
+ protected JdbcOutputConnection connect() throws SQLException
33
39
  {
34
40
  Connection c = DriverManager.getConnection(url, properties);
35
41
  if (c == null) {
@@ -55,7 +61,7 @@ public class SQLServerOutputConnector
55
61
  }
56
62
 
57
63
  try {
58
- SQLServerOutputConnection con = new SQLServerOutputConnection(c, schemaName, autoCommit);
64
+ SQLServerOutputConnection con = new SQLServerOutputConnection(c, schemaName);
59
65
  c = null;
60
66
  return con;
61
67
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: embulk-output-sqlserver
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.2
4
+ version: 0.8.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sadayuki Furuhashi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-01-30 00:00:00.000000000 Z
11
+ date: 2019-05-07 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.8.2.jar
23
- - classpath/embulk-output-sqlserver-0.8.2.jar
22
+ - classpath/embulk-output-jdbc-0.8.3.jar
23
+ - classpath/embulk-output-sqlserver-0.8.3.jar
24
24
  - classpath/jtds-1.3.1.jar
25
25
  - lib/embulk/output/sqlserver.rb
26
26
  - src/main/java/org/embulk/output/SQLServerOutputPlugin.java