embulk-output-jdbc 0.4.2 → 0.4.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: 0a490e2eac0e4a99d84d946d6c36c67e6dddb087
4
- data.tar.gz: 27e23980d6cccc521575fe9d18f50b0cfd1ea641
3
+ metadata.gz: 8d53fa63e0610150767ab330b29bf436707ed8ef
4
+ data.tar.gz: cca3319be7428f46e64c76abb47caf9cc03edb8a
5
5
  SHA512:
6
- metadata.gz: db82ee6612664a6eebdbccaba36437c85ecae78ab05bda0ef09e1b49500b10aff2ee247a9e9b80460404fa37ae44e7c8d538fbcc454434854f04a55d8be1f9e7
7
- data.tar.gz: 4b659c34dfd93468553647cbbc79f40f9c13e1031f95df5f118ff81cc28a55c174ab9960e1bf108deb7b17edfc04f686711952042207002b9e2a8877d5371f09
6
+ metadata.gz: 188f1e9a3acc891c531ea531b2d7dac8c31070a2efe85645116bec8f1def2ce2380c743bf40e4001f2ddb96826322ac32c134a63c9a6afe87ca5993d3fef068f
7
+ data.tar.gz: bb9836e2bc55673a5943ff955d2046812bbeacf84984aa1cfed7b053ea4b4d14a5b3c9c41db1a7f24c08962e08515647e28d8515fa851cceeccaff35b2e58dec
@@ -92,6 +92,9 @@ public abstract class AbstractJdbcOutputPlugin
92
92
  public void setFeatures(Features features);
93
93
  public Features getFeatures();
94
94
 
95
+ public Optional<JdbcSchema> getNewTableSchema();
96
+ public void setNewTableSchema(Optional<JdbcSchema> schema);
97
+
95
98
  public JdbcSchema getTargetTableSchema();
96
99
  public void setTargetTableSchema(JdbcSchema schema);
97
100
 
@@ -433,14 +436,17 @@ public abstract class AbstractJdbcOutputPlugin
433
436
  JdbcSchema targetTableSchema;
434
437
  if (initialTargetTableSchema.isPresent()) {
435
438
  targetTableSchema = initialTargetTableSchema.get();
439
+ task.setNewTableSchema(Optional.<JdbcSchema>absent());
436
440
  } else if (task.getIntermediateTables().isPresent() && !task.getIntermediateTables().get().isEmpty()) {
437
441
  String firstItermTable = task.getIntermediateTables().get().get(0);
438
442
  targetTableSchema = newJdbcSchemaFromTableIfExists(con, firstItermTable).get();
443
+ task.setNewTableSchema(Optional.of(newTableSchema));
439
444
  } else {
440
445
  // also create the target table if not exists
441
446
  // CREATE TABLE IF NOT EXISTS xyz
442
447
  con.createTableIfNotExists(task.getTable(), newTableSchema);
443
448
  targetTableSchema = newJdbcSchemaFromTableIfExists(con, task.getTable()).get();
449
+ task.setNewTableSchema(Optional.<JdbcSchema>absent());
444
450
  }
445
451
  task.setTargetTableSchema(matchSchemaByColumnNames(schema, targetTableSchema));
446
452
 
@@ -588,16 +594,25 @@ public abstract class AbstractJdbcOutputPlugin
588
594
 
589
595
  case INSERT:
590
596
  // aggregate insert into target
597
+ if (task.getNewTableSchema().isPresent()) {
598
+ con.createTableIfNotExists(task.getTable(), task.getNewTableSchema().get());
599
+ }
591
600
  con.collectInsert(task.getIntermediateTables().get(), schema, task.getTable(), false);
592
601
  break;
593
602
 
594
603
  case TRUNCATE_INSERT:
595
604
  // truncate & aggregate insert into target
605
+ if (task.getNewTableSchema().isPresent()) {
606
+ con.createTableIfNotExists(task.getTable(), task.getNewTableSchema().get());
607
+ }
596
608
  con.collectInsert(task.getIntermediateTables().get(), schema, task.getTable(), true);
597
609
  break;
598
610
 
599
611
  case MERGE:
600
612
  // aggregate merge into target
613
+ if (task.getNewTableSchema().isPresent()) {
614
+ con.createTableIfNotExists(task.getTable(), task.getNewTableSchema().get());
615
+ }
601
616
  con.collectMerge(task.getIntermediateTables().get(), schema, task.getTable(), task.getMergeKeys().get());
602
617
  break;
603
618
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: embulk-output-jdbc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.4.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: 2015-12-08 00:00:00.000000000 Z
11
+ date: 2015-12-17 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Inserts or updates records to a table.
14
14
  email:
@@ -53,7 +53,7 @@ files:
53
53
  - src/main/java/org/embulk/output/jdbc/setter/SqlTimestampColumnSetter.java
54
54
  - src/main/java/org/embulk/output/jdbc/setter/StringColumnSetter.java
55
55
  - src/test/java/org/embulk/output/TestJdbcOutputPlugin.java
56
- - classpath/embulk-output-jdbc-0.4.2.jar
56
+ - classpath/embulk-output-jdbc-0.4.3.jar
57
57
  homepage: https://github.com/embulk/embulk-output-jdbc
58
58
  licenses:
59
59
  - Apache 2.0